Closed joulev closed 5 years ago
Hi, @joulev thanks for making this issue. I should be able to help with those points.
- Tikz pictures not being recognised.
That's due to a mistake that slipped in earlier where whenever \end{tikzpicture}
is unindented the tikzpicture isn't recognised (fixed in 7a1871543477ea89d0daf1d281be67ab2ea9a030). Hopefully this should be fine in the next release.
- Tikzpictures after
\centertikz
being recognised
I imagine that's because the \end{tikzpicture}
there is indented.
- View tikzpicture button is buggy
That's very dodgy. I did try your example though, and it seemed to work (Using the HEAD
version of this extension though). It's worth noting that I am on linux.
- please change "TikzPicture" to "TikZ picture", or even better "TikZ picture"
Sure! I'll make a commit for that soon.
p.s. Thanks for a rather nicely structured issue with examples :smiley:
The temp file used (in your case) looks like C:\Users\ANHTAN~1\AppData\Local\Temp\vscode-latexworkshop\tikzpreview-problem-tvwtl5\
(though the letters/numbers at the end change each session). You should find the files for the tikzpreview in this folder.
e.g.
It would be very helpful if you would be able to
...Temp\vscode-latexworkshop\tikzpreview-problem-tvwtl5\
looks like you'd expect (has all the right files)preamble.tex
and tikzpicture-XXXXXXX.tex
Hi @tecosaur.
Thanks for your reply. I am trying to reproduce the problems. In fact, I think indentation is the cause here:
As you have fixed, I am looking forward to the next release!
However, even when the environment is indented, if they are nested in something e.g. enumerate
, it seems that only the 1st, 3rd, 5th, etc. are recognized:
As of the output preview, I see nothing actually. latexmkrc
is still reporting that it can't compile. Following your advice, I go to the directory and found
preamble.tex
\documentclass{standalone}
\usepackage{tikz}
\pdfcompresslevel=0
\pdfobjcompresslevel=0
\begin{document}\end{document}
tikzpicture-76543465.tex
(just for example)
%&preamble
\begin{document}
\begin{tikzpicture}[font=\footnotesize,>=stealth]
\draw (0,0) -- (1,1);
\end{tikzpicture}
\end{document}
texput.log
This is pdfTeX, Version 3.14159265-2.6-1.40.20 (MiKTeX 2.9.7050 64-bit) (INITEX) 23 JUL 2019 17:08
**"&pdflatex" mylatexformat.ltx "C:\Users\ANHTAN~1\AppData\Local\Temp\vscode-la
texworkshop\tikzpreview-check-Ou9Dix\preamble.tex"
! Emergency stop.
<*> "&pdflatex"
mylatexformat.ltx "C:\Users\ANHTAN~1\AppData\Local\Temp\vsco...
*** (job aborted, file error in nonstop mode)
No pages of output.
It seems that the files is somehow written incorrectly perhaps, which leads to compilation errors.
Although in my computer it can't compile yet, but by some tests, I found another problem. It seems that \tikzset
in preamble is not recognized.
For example, with the following MWE,
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\tikzset{
->-/.style={
postaction=decorate,
decoration={markings,mark=at position #1 with \arrow{>}}
}
}
\begin{document}
\begin{center}
\begin{tikzpicture}
\draw[->-=0.5] (0,0) -- (3,-2);
\end{tikzpicture}
\end{center}
\end{document}
the \tikzset
line is crucial to compile the figure. However, in both preamble.tex
and tikzpicture-XXX.tex
, I don't see any \tikzset
, i.e. all settings I have in these global \tikzset
s are lost. I think this should also be fixed.
Ok. Seems like the \tikzset
may be the root of all the compile issues. I have a feeling that the regex for it may not deal with nested brackets well. I'll have a look at that and the code lenses and report back.
Have fixed the code lense issue.
Think I fixed the \tikzset
issue. Just had to make some regex that matched up to 3rd level nested brackets β {(?:[^\{\}]+|{(?:[^\{\}]+|{(?:[^\{\}]+|{[^\{\}]+})+})+})+}
. I find it easier spread out over a few lines.
@joulev would you mind testing https://github.com/tecosaur/LaTeX-Workshop/tree/tikzpreview-fixes and letting me know how that goes?
Just in case you havent seen this before, the steps are:
npm install
@tecosaur In fact, I haven't done this before, and I have a bit trouble with it. π
Could you please explain the steps more? I don't think I can get it yet.
@joulev Edit: The easiest way to download the code is to download it as a .zip
file through Github. I wrote about how to clone repositories earlier which you may feel free to skip.
The procedure to clone a repository is with the git
command (https://git-scm.com/). Normally this would just be git clone https://github.com/tecosaur/LaTeX-Workshop.git
but since you want a different branch, you want to specify that as well:
git clone --single-branch --branch tikzpreview-fixes https://github.com/tecosaur/LaTeX-Workshop.git
cd LaTeX-Workshop
npm install
Also possible is to clone the whole thing and then checkout
to the correct branch:
git clone https://github.com/tecosaur/LaTeX-Workshop.git
cd LaTex-Workshop
git checkout tikzpreview-fixes
Once you're there, you can type git log
to check that "Expand maximum bracket nesting in tikzpreview regex" was the latest commit (so you know you have the right branch. Press q
to exit the log.
Now you can try npm install
and hopefully that works. (It might produce a couple warnings, that is to be expected.) Check that you now have a directory called node_modules
. Note: you must run this command from inside the LaTeX-Workshop source directory. Use the cd
(change directory) command to get to it. E.g. if you unzipped inside your Downloads folder: cd C:\User\Username\Downloads\LaTeX-Workshop
. The command also accept relative paths. E.g. cd Downloads\LaTeX-Workshop
will work if your current directory is C:\User\Username\
.
You can now open up the directory in VSCode and launch, but you may also find it easier to instead run npm run compile
which will produce a folder called out
which you can copy to C:\User\Username\.vscode\extensions\james-yu.latex-workshop-7.2.0\
. (This is what launching does except launching restores the original extension when it closes.)
@trevorgunn Thank you very much for your detailed instructions! I think I just succeeded.
@tecosaur In fact, all TikZ pictures are now recognized π. But there are still some problems with compilations in my computer.
I see that preamble.tex
, tikzpicture-XXX.tex
and texput.log
are not different from yesterday.
Checking out the \tikzset
MWE, I can see that \tikzset
is still not recognized.
@joulev I find it interesting that this \tikzset
still isn't recognised. You can see your document and the updated regex here https://regex101.com/r/1xix9x/1 and it looks like it should be included.
Using your \tikzset
MWE it seems to work for me.
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\tikzset{
->-/.style={
postaction=decorate,
decoration={markings,mark=at position #1 with \arrow{>}}
}
}
\pdfcompresslevel=0
\pdfobjcompresslevel=0
\begin{document}\end{document}
%&preamble
\begin{document}
\begin{tikzpicture}
\draw[->-=0.5] (0,0) -- (3,-2);
\end{tikzpicture}
\end{document}
I notice in your compilation log that you are using MiKTeX and have the following line
! LaTeX Error: Environment tikzpicture undefined.
as such my current suspicion is that the preamble.fmt
file isn't being used for the compilation.
For comparison with texlive on Linux I get this:
Of particular note to me is the line CUSTOMISED FORMAT: "preamble "
which doesn't appear on your log.
I'll have a look and see if MiKTeX works differently and come back. Thanks for being a willing test subject :stuck_out_tongue:
@trevorgunn thank you for helping with instructions on how to run the branch.
Ok. @joulev I have no clue why it's not working. I installed MiKTeX on a Win7 VM, pasted the files described in my last comment, and the ran.
pdftex -ini -interaction=nonstopmode -shell-escape -file-line-error -jobname="preamble" "&pdflatex" mylatexformat.ltx "preamble.tex"
latexmk -interaction=batchmode -quiet -pdf tikzpicture-XYZ.tex
And it all worked.
Could you verify that if you do the same that it works for you? If it does can you make sure that the preamble and tikzpicture files that you said were the same are indeed from after you tried my branch. The contents of the files should be the same.
@tecosaur Calling pdftex
from the command line works, calling it with child_process
does not. I have no idea why. pdftex
doesn't produce a log either when run from the extension so I don't think it even tried to run.
What does work:
child_process.spawn('explorer')
so we know the spawn command is workinglatexmk
works (once pdftex
is called manually, the Tikz previewer works normally)I'm out of ideas as to why launching pdftex
with child_process
isn't working.
You do have to run pdftex.exe
rather than pdftex
from the command line, but I'm pretty sure that isn't the issue.
EDIT: There is one more thing. If I uninstall the mylatexformat
package and standalone
class from MikTeX, Running pdftex
with child_process.spawn
does not prompt to install either package. Running pdftex
with child_process.exec
prompts to install mylatexformat
but not standalone
class. This means that pdftex
sees the mylatexformat
argument but not the standalone
class which is contained in the preamble. (Possibly I set up the parameters to child_process.exec
wrong.)
This also means that with child_process.spawn
, the command doesn't run at all because if it did, it would prompt to install mylatexformat
even if it can't find the preamble file.
This is strange. I do hope the way it currently is it isn't a Linux-only feature. @James-Yu @jlelong @tamuratak have any of you tested this feature on windows?
@tecosaur @trevorgunn I haven't tested anything yet (today I am a bit busy), but I am sure I don't use latexmk
. Maybe that is the issue?
Tonight I will try uninstall all LaTeX-Workshop and your branch and start all over again, but use your approach (latexmk
). Hope it works. It is not probable that the feature is Linux-only.
But it is also worth noting that not all users use latexmk
, so it should also work without latexmk
.
We should add documentation about what the requirements are for this feature: standalone
class, mylatexformat
package and latexmk
(which on Windows requires installing perl). Some log messages if these are not present might be beneficial too.
I think it might be possible to switch to pdflatex
(from latexmnk
). Not sure if a single tikz picture could ever need more than one run. This could help with compatibility.
@tecosaur I just checked, and both latexmk
and pdftex
inside VSCode don't work π.
If I run the commands from the command line, both produce no error messages, but there are nothing in the PDF file. But \tikzset
is recognized!
These are the relevant files I think. Ask me if you want more information.
@joulev I am able to reproduce your experience with the preamble (but I don't know where texput.log
came from). However when it comes to running latexmk -pdf {file}
or pdflatex {file}
MiKTeX succeeds to compile. I am afraid I am unable to reproduce your issue. I still have no idea why it looks like the format file isn't loaded.
I'm going to open a PR with the fixes I have made, but with this part of the issue I'm not sure how to proceed.
Since we have dealt with all of the original bullet points, I'll open a new issue dedicated to this compilation issue for the sake of simplicity.
Disable all the other extensions except for LaTeX Workshop, and check that you still see this issue. [Required]
Done.
Make sure to visit the wiki FAQ before filling an issue.
Done.
Describe the bug [Required]
I was (and am) literally very surprised to see the "View TikzPicture" a few days ago – never thought that such a feature will ever be implemented. After some days of using and checking, I think there are still some problems to be considered:
\begin{tikzpicture}[something]
and\end{tikzpicture}
.\centertikz
) (see screenshot below). Even more, two adjacent TikZ pictures are recognized as one.Last, but not least, could you please change "TikzPicture" to "TikZ picture", or even better "TikZ picture"? The official "logo" of the package is "TikZ".
Expected behavior Exactly what we all expect.
Logs [Required]
LaTeX Workshop Output [Required]
I paste the related part (everything that is shown after I pressing the button). The other lines are not related IMHO. ``` [15:26:24] Serving PDF file at http://localhost:51814/viewer.html?file=pdf..QyUzQSU1Q1VzZXJzJTVDQU5IVEFOfjElNUNBcHBEYXRhJTVDTG9jYWwlNUNUZW1wJTVDdnNjb2RlLWxhdGV4d29ya3Nob3AlNUN0aWt6cHJldmlldy1wcm9ibGVtLXR2d3RsNSU1Q3Rpa3pwaWN0dXJlLTcwMzgwODQwLnBkZg [15:26:24] The encoded path is C:\Users\ANHTAN~1\AppData\Local\Temp\vscode-latexworkshop\tikzpreview-problem-tvwtl5\tikzpicture-70380840.pdf [15:26:25] Open PDF tab for C:\Users\ANHTAN~1\AppData\Local\Temp\vscode-latexworkshop\tikzpreview-problem-tvwtl5\tikzpicture-70380840.pdf [15:26:26] No PDF viewer connected for C:\Users\ANHTAN~1\AppData\Local\Temp\vscode-latexworkshop\tikzpreview-problem-tvwtl5\tikzpicture-70380840.pdf [15:26:26] Serving PDF file at http://localhost:51814/viewer.html?file=pdf..QyUzQSU1Q1VzZXJzJTVDQU5IVEFOfjElNUNBcHBEYXRhJTVDTG9jYWwlNUNUZW1wJTVDdnNjb2RlLWxhdGV4d29ya3Nob3AlNUN0aWt6cHJldmlldy1wcm9ibGVtLXR2d3RsNSU1Q3Rpa3pwaWN0dXJlLTcwMzgwODQwLnBkZg [15:26:26] The encoded path is C:\Users\ANHTAN~1\AppData\Local\Temp\vscode-latexworkshop\tikzpreview-problem-tvwtl5\tikzpicture-70380840.pdf [15:26:26] Open PDF tab for C:\Users\ANHTAN~1\AppData\Local\Temp\vscode-latexworkshop\tikzpreview-problem-tvwtl5\tikzpicture-70380840.pdf [15:26:28] Handle data type: open [15:26:28] Handle data type: open [15:26:28] Preview PDF file: c:\Users\ANHTAN~1\AppData\Local\Temp\vscode-latexworkshop\tikzpreview-problem-tvwtl5\tikzpicture-70380840.pdf [15:26:28] Preview PDF file: c:\Users\ANHTAN~1\AppData\Local\Temp\vscode-latexworkshop\tikzpreview-problem-tvwtl5\tikzpicture-70380840.pdf [15:26:28] Handle data type: loaded [15:26:28] Handle data type: loaded ```Developer Tools Console [Required]
`latexmkrc` seems to have trouble compiling the Ti*k*Z pictures. ![a](https://i.stack.imgur.com/oTwLo.png)Screenshots In the following screenshot, there are no buttons.
In the following screenshot, the middle TikZ picture is not recognized.
In the following screenshot, it is expected to be a graph.
Desktop [Required]:
Additional context If necessary, this is my mysterious
\centertikz
command. It is a workaround for centering elements in the middle of the baseline. I can't figure out how it affects the feature, but as I can see, it does affect the feature.