SublimeText / LaTeXTools

LaTeX plugin for Sublime Text
https://latextools.readthedocs.io/
2.01k stars 365 forks source link

Problem of Math Preview #920

Open ghost opened 7 years ago

ghost commented 7 years ago

I installed the gs and magick, added them to $Path. I can build my pdf, and the picture preview works well, but the Math Preview breaks down. This is the system check. snipaste20161104_233110 And there are my code and the feedback. snipaste20161104_233027

My OS is Windows 10(64bit) My Sublime Text 3 is 3126 Magick is 7.0.3-Q16(64bit) gs is 9.2(32bit)

GerjanOnline commented 7 years ago

I have the same issue

r-stein commented 7 years ago
GerjanOnline commented 7 years ago

@r-stein I have miktex on my path (as well as gs and magick)

The console only prints: Running "pdflatex -interaction=nonstopmode 24762a28fd34ef90e3f6f0512b85e669.tex"

jutongpan commented 7 years ago

I have exactly the same issue.

My Path has: C:\Program Files (x86)\gs\gs9.20\bin;C:\Program Files\ImageMagick-7.0.3-Q16;C:\Program Files (x86)\MiKTeX 2.9\miktex\bin\

System Check: image

Error: image image

ghost commented 7 years ago

I got one way to solve the problem! The problem is happenning when the related packages are not installed. Go to the Cache path of LatexTools, for me it's

"D:\sublime_text_3126\Data\Cache\LaTeXTools\preview_math"

And build the tex in the folder, and console will show u what packages are needed!

ghost commented 7 years ago

And I'm curious about whether these cache will be deleted autoly.

jmbejara commented 7 years ago

@DKJust Thanks for the tip. I couldn't find the files that LatexTools was generating. I'm assuming that they're deleted automatically. I searched for them in the AppData directory, but couldn't find them. That appeared to be the correct place, but I couldn't find the .tex files that were being generated. (I'm on Windows 10.)

For those that can't find the generated files, this is what worked for me. Looking at the code in LaTeXTools/st_preview/preview_math.py, the file that is generated should look something like this:

\documentclass[preview]{standalone}

% import xcolor if available and not already present
\IfFileExists{xcolor.sty}{\usepackage{xcolor}}{}%

% The four packages below are specified in LatexTools.sublime-settings
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{latexsym}
\usepackage{mathtools}
%<<preamble>>
\begin{document}
% set the foreground color
%\IfFileExists{xcolor.sty}{<<set_color>>}{}%
$$
a = b
$$

\end{document}  

I tried compiling this and MikTek installed what it needed. It turns out that in my particular case, I was missing standalone.cls (which depends on preview.sty).

GerjanOnline commented 7 years ago

Thanks @jmbejara! That was the trick.

So for everyone: compile the snippet from @jmbejara in a separate file and install the missing packages (in my case it was: standalone, preview and mathtools). After that the math preview worked.

r-stein commented 7 years ago

Thanks for that investigation, I will improve the system check and the error logging.

zf-z commented 7 years ago

Installed all the missing package: standalone, preview and mathtools, still don't work. ERROR: Failed to run"pdflatex" to creat pdf to preview. Do you figure out what it is the essential problem ? @r-stein

r-stein commented 7 years ago

@zzf-technion you can compile the document provied by @jmbejara via the terminal with pdflatex?

zf-z commented 7 years ago

@r-stein After I downloaded the four documents: mathtools.sty; mhsetup.sty; preview.py and standalone.cls, then put these four documents in the same fold with .tex file, I can compile the .tex and get pdf file.

zf-z commented 7 years ago

but there is still a problem with preview when editing the tex code

r-stein commented 7 years ago

@DKJust The cache has an upper limit

@zzf-technion You need to install that packages for the whole system. Which tex distro are you using?

zf-z commented 7 years ago

@r-stein Struggling for two days, finally the preview works well, thanks for your amazing work, it is really awesome. And the problem I think in your settings, you choose the four preview math template packages: amsmath,amssymb,latexsym,mathtools. so we need to download the four package at first. I suggest in your next help document, you can illustrate this point more straightforward and give the detailed instruction. @r-stein

r-stein commented 7 years ago

@zzf-technion I agree, we are still at handling and narrowing down typical error cases. There is already an PR https://github.com/SublimeText/LaTeXTools/pull/924 to check the availability of the required packages in the system check.

ldurniat commented 7 years ago

The solution suggested by @DKJust WORKS:) but before that I have reinstalled MikTex, GS and imgmagic.

TLCFEM commented 7 years ago

Dear developers,

Do you mind to add gs win 64bit support?

I have gs installed but a 64bit version and I do not want to reinstall a 32bit one.

r-stein commented 7 years ago

@TLCFEM We don't use ghostscript directly. We use ImageMagick (to convert pdfs to preview pngs), which uses ghostscript as dependency. So we cannot do anything about this. You may verify, that you have a 64bit ImageMagick installation and investigate into that direction. If you can convert a pdf to a png via the convert test.pdf test.png command in a cmd/shell, this feature should also work.

TLCFEM commented 7 years ago

Thanks now problem fixed

FichteFoll commented 7 years ago

Also encountering this. Compiling the template once made the pdflatex-related error disappear, since I was missing standalone and preview. I do now realize that these packages are chcked for in the Check System output, but it's not obvious what you should do to fix this, unless you visit this issue.

Now that it can't convert the pdf to an image, the error message should definitely mention that you need to install ImageMagick and ghostscript (on Windows), since the feature is auto-enabled and doesn't require you do read any documentation. Linking to the readme would be enough, imo.

r-stein commented 7 years ago

@FichteFoll I agree, that the troubleshooting still needs to improve. We could create a wiki page for it and add a (Help) button, which opens that page in the browser.

ntvy95 commented 7 years ago

I have checked the system and below is my result:

Program Location Status Version


sublime C:\Program Files\Sublime Text 3\sublime_text.exe available Sublime Text Build 3126 texify C:\Program Files\MiKTeX 2.9\miktex\bin\x64\texify.exe available MiKTeX Compiler Driver 2.9.6300 (MiKTeX 2.9.6350 64-bit) pdflatex C:\Program Files\MiKTeX 2.9\miktex\bin\x64\pdflatex.exe available MiKTeX-pdfTeX 2.9.6354 (1.40.18) (MiKTeX 2.9.6350 64-bit) xelatex C:\Program Files\MiKTeX 2.9\miktex\bin\x64\xelatex.exe available MiKTeX-XeTeX 2.9.6300 (0.99998) (MiKTeX 2.9.6350 64-bit) lualatex C:\Program Files\MiKTeX 2.9\miktex\bin\x64\lualatex.exe available This is LuaTeX, Version 1.0.4 (MiKTeX 2.9.6350 64-bit) biber C:\Program Files\MiKTeX 2.9\miktex\bin\x64\biber.exe available biber version: 2.7 bibtex C:\Program Files\MiKTeX 2.9\miktex\bin\x64\bibtex.exe available MiKTeX-BibTeX (MiKTeX 2.9.6350 64-bit) bibtex8 C:\Program Files\MiKTeX 2.9\miktex\bin\x64\bibtex8.exe available This is 8-bit Big BibTeX version 0.99d kpsewhich C:\Program Files\MiKTeX 2.9\miktex\bin\x64\kpsewhich.exe available MiKTeX 2.9.6350 64-bit magick C:\Program Files\ImageMagick-7.0.6-Q16\magick.exe available ImageMagick 7.0.6-0 Q16 x64 2017-06-11 http://www.imagemagick.org ghostscript C:\Program Files\MiKTeX 2.9\miktex\bin\x64\mgs.exe available 9.19

Packages for equation preview Status


standalone available preview available xcolor available amsmath available amssymb available latexsym available mathtools available

Builder Status


traditional available

Builder Setting Value


command latexmk -cd -f -%E -interaction=nonstopmode -synctex=1 display_log False linux {}
osx {}
program xelatex windows {}

TeX Root

D:\Thesis\Reports\TEXReport\test.tex

LaTeX Engine

xelatex

Viewer Status Location


sumatra available C:\Program Files\SumatraPDF\SumatraPDF.exe

However, I am still not able to preview the math. The error still says:

Failed to run 'pdflatex' to create pdf to preview

hyrious commented 7 years ago

Same issue above, but here is the quick solution: Click (Show Report); Copy contents between -----BEGIN DOCUMENT----- and -----END DOCUMENT----- to a TeX file like 1.tex. Then compile it by hand: pdflatex 1.tex. The tex engine will automatically install missing packages. (And this issue has been solved.) From my circumstance, the missing packages are luatex85 and mptopdf. Hope to help you.

LGro commented 6 years ago

Thanks @hyrious, I was missing the specific luatex85, even though another luatex package was installed.

htharoldht commented 6 years ago

We don't use ghostscript directly. We use ImageMagick (to convert pdfs to preview pngs), which uses ghostscript as dependency. So we cannot do anything about this. You may verify, that you have a 64bit ImageMagick installation and investigate into that direction. If you can convert a pdf to a png via the convert test.pdf test.png command in a cmd/shell, this feature should also work.

OS: win10 distro: texlive2018 ImageMagick: 7.0.8-9 Q16 x64

@r-stein I have already read your reply to the ask of add GS, but when I use convert test.pdf test.jpg via cmd, there are the error

"convert.exe: FailedToExecuteCommand `"gswin32c.exe" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72"  "-sOutputFile=C:/Users/17600/AppData/Local/Temp/magick-13116UbtUwAlJBI5u%d" "-fC:/Users/17600/AppData/Local/Temp/magick-13116NMVazDoZMXFr" "-fC:/Users/17600/AppData/Local/Temp/magick-13116hlk6Mn8TdIOr"' (系统找不到指定的文件。
) @ error/delegate.c/ExternalDelegateCommand/459.
convert.exe: PDFDelegateFailed `系统找不到指定的文件。
' @ error/pdf.c/ReadPDFImage/794.
convert.exe: no images defined `test4.png' @ error/convert.c/ConvertImageCommand/3275."

After I searched from the Internet, I find out that I have to install GS. Is it the deference between MikTex and TeXLive? Do you have any idea to skip this step?

alexboche commented 5 years ago

Latex beginner here. I am trying to get the preview of math equations and symbols within the document (not in a separate file or pane). I think this is called phantoms? It is not working (unless I'm missing a special button I'm supposed to press to get that). I tried compiling the following file per some instructions above

\documentclass[preview]{standalone}

% import xcolor if available and not already present
\IfFileExists{xcolor.sty}{\usepackage{xcolor}}{}%

% The four packages below are specified in LatexTools.sublime-settings
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{latexsym}
\usepackage{mathtools}
%<<preamble>>
\begin{document}
% set the foreground color
%\IfFileExists{xcolor.sty}{<<set_color>>}{}%
$$
a = b
$$
\end{document}  

To compile it, I went into Windows 10 power shell terminal into the directory where that file is stored . I called that file file_from_internet.tex . I typed in pdflatex file_from_internet.tex. The result was an error message: "! LaTeX Error: File standalone.cls' not found. Type X to quit or <RETURN> to proceed, or enter new name. (Default extension: cls)" I then pressed enter. I then got the message " LaTeX Error: Filemathtools.sty' not found." after pressing enter again, no new missing packages were mentioned. How do I install these missing packages? I am able to get the PDF to generate but I'm just trying to get the within file preview without generating a separate file or pane. thank you.

ig0774 commented 5 years ago

Assuming you’re using MiKTeX, from the PowerShell console type mpm --install=standalone and a similar command for mathtools.

alexboche commented 5 years ago

Thank you for your reply. Yes I believe I am using MiKTeX. When I run the command mpm --install=standalone in powershell, I get the following output:

Sorry, but "MiKTeX Package Manager" did not succeed.
The log file hopefully contains the information to get MiKTeX going again:
  C:/Users/alex/AppData/Local/MiKTeX/2.9/miktex/log/mpmcli.log
You may want to visit the MiKTeX project page, if you need help.

Looking at the log file mentioned in that message, the last two lines say

2019-08-06 03:49:01,540-0700 FATAL mpmcli - Info: 
url="ftp://ftp.fernuni-hagen.de/pub/mirrors/www.ctan.org/systems/win32/miktex/tm/packages/"

I tried going to that URL but my browser would not load it. After executing the command mpm --install=mathtools, I get the same message as after running the other command above and two new lines are added to the log file:

2019-08-06 03:49:01,540-0700 FATAL mpmcli - Source: Libraries\MiKTeX\PackageManager\RestRemoteService.cpp
2019-08-06 03:49:01,540-0700 FATAL mpmcli - Line: 263

Here's the full output of the log after executing both of these commands (I'm pretty sure that only last few lines are interesting and I already reproduced those above). Any suggestions? Thanks!

r-stein commented 5 years ago

@alexboche I would just change the remote. Run mpm without arguments or open the MiKTeX Console from the start menu. Then open Settings > General > Package Installation and change the remote.

alexboche commented 5 years ago

I changed the remote by typing mpm in power shell and then going to Settings > General > Package Installation , and setting it to "packages are installed from: a random package repository on the Internet". Then I went back to the terminal and installed the packages as directed above. Now it is working! There is no preview for symbols within single dollar signs, but I think that is just not a feature of this package. Thank you.

r-stein commented 5 years ago

@alexboche That is a feature not a bug ;). The equation preview is controlled by a scope selector. You can just open your LaTeXTools settings Preferences > Package Settings > LaTeXTools > Settings (User) and then change preview_math_scope from "text.tex.latex meta.environment.math.block" to "text.tex.latex meta.environment.math".