SublimeText / LaTeXTools

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

equation preview in windows texlive 2017? #1148

Open 645978336 opened 7 years ago

645978336 commented 7 years ago

Hello, I am a new user of your amazing working, LaTexTools I just meet some strange problems.
Can you help me? those are my sublime text 3 reports: _20170607184906

_20170607184315

I don't know why I can't preview the equation with everything OK? shouldn't I use texlive 2017?

r-stein commented 7 years ago

Does it work with simpler equations? What's the content of the report (Show Report)? It should work with texlive 2017.

645978336 commented 7 years ago

image No, it doesn't work. and the report is "Failed to convert pdf to png to preview." but I have added the magick.

r-stein commented 7 years ago

If you click on (Show Report) it should open a file, which contains a bug report.

645978336 commented 7 years ago

Yeah, the file in C:\Users****\AppData\Local\Sublime Text 3\Cache\LaTeXTools\internal\preview_math with the suffix 'err' image and I only get one sentence:"Failed to convert pdf to png to preview." in every file

r-stein commented 7 years ago

You may try to restart Sublime Text. Do you have any output in the ST console ctrl+`?

645978336 commented 7 years ago

ST3 console output:

Running "'C:\texlive\2017\bin\win32\pdflatex.EXE' -interaction=nonstopmode 61f2a40c739fed82c5f0e277f5532eef.tex"

Running "'C:\texlive\2017\tlpkg\tlgs\bin\gswin32c.EXE' -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dQUIET -q -sDEVICE=bbox -r72 -dLastPage=1 'C:\Users\Benjamin\AppData\Local\Sublime Text 3\Cache\LaTeXTools\internal\preview_math\61f2a40c739fed82c5f0e277f5532eef.pdf'"

Running "'C:\texlive\2017\tlpkg\tlgs\bin\gswin32c.EXE' -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dQUIET -q -sDEVICE=pngalpha -dLastPage=1 '-sOutputFile=C:\Users\Benjamin\AppData\Local\Sublime Text 3\Cache\LaTeXTools\internal\preview_math\61f2a40c739fed82c5f0e277f5532eef.png' -r1200 -dDownScaleFactor=8 -dTextAlphaBits=4 -dGraphicsAlphaBits=4 'C:\Users\Benjamin\AppData\Local\Sublime Text 3\Cache\LaTeXTools\internal\preview_math\61f2a40c739fed82c5f0e277f5532eef.pdf'"

Is the gswin32c.EXE wrong? Should I install the GhostSrcipt once again?

r-stein commented 7 years ago

It should work with your ghostscript version. I don't know what the issue is.

645978336 commented 7 years ago

ok, I give up, maybe something is wrong.

hsiktas commented 7 years ago

I am seeing the same issue after switching from TeX Live 2016 to 2017. At first it tried to use the convert.exe from system32 and after manually installing ImageMagick the LatexTools System Check now points towards the newly installed magick.exe instead of to the wrong convert.exe.

I also have MacTex 2017 which has the same program versions according to the LaTeXTools System Check and there a no problems with the equation preview.

r-stein commented 7 years ago

It may be worth to add that we aren't using ImageMagick for the preview anymore. It is only used to convert images in the preview, which aren't png, jp(e)g, (gif), pdf, ps, or eps. So we may also remove it from the system check, because other image formats aren't common in latex documents.

The conversation from pdf to png is done via ghostscript, which usually ships with the tex distro. I don't know what the problem is or how to debug the best. You can see the executed commands in the ST console ctrl+` and may try to convert a pdf document via ghostscript and check for errors. You may also try to install a different ghostscript version.

hsiktas commented 7 years ago

In my \AppData\Local\Sublime Text 3\Cache\LaTeXTools\internal\preview_math I can see the pdf output only for a short moment before it is immediately deleted again. All that is left is that .err file which contains only the message Failed to convert pdf to png to preview. which is already shown within Sublime.

Can I somehow disable that instant cleanup of these temp files? This way I could run the failing commands with the same input manually and watch for any errors.

r-stein commented 7 years ago

Yes you can juste delete for loop and restart Sublime Text afterwards to reload the plugin.

hsiktas commented 7 years ago

Is this any helpful? Do I need to set up a proper environment for Ghostscript first? I ran it with PowerShell in the \internal\preview_math\ folder.

C:\texlive\2017\tlpkg\tlgs\bin\gswin32c.EXE -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dQUIET -q -sDEVICE=bbox -r72 -dLastPage=1 'C:\Users\Hakan Siktas\AppData\Local\Sublime Text 3\Cache\LaTeXTools\internal\preview_math\d919d613033be9ef237050652d7cfd47.pdf' GPL Ghostscript 9.21: Can't find initialization file gs_init.ps.

r-stein commented 7 years ago

I also don't know much about ghostscript, but it should automatically create a sane environment when you install ist. You may try to press alt+r and write regedit then open HKEY_LOCAL_MACHINE > SOFTWARE and look for an entry with the name ghostscript in it. This should have the keys GS_DLL and GS_LIB, which point to the corresponding directories. You can check that these values are valid.

ig0774 commented 7 years ago

That "Can't find initialization file..." error message sounds like a messed up GS install. I'm not sure what we can do to alleviate the issue.

hsiktas commented 7 years ago

I installed the latest version of Ghostscript via Chocolatey, manually added C:\Program Files\gs\gs9.21\bin into my PATH environment variable and after a restart of Sublime Text your System Check now recognized the new gswin64c.exe as my Ghostscript binary.

The equation previews are working again. 😀 So it seems that the bundled Ghostscript in TexLive 2017 has some issues on Windows.

645978336 commented 7 years ago

thank you!, It works @hsiktas

taroxd commented 7 years ago

FYI, I set environment variable GS_LIB to path\to\texlive\tlpkg\tlgs\Resource\Init;path\to\texlive\tlpkg\tlgs\kanji and it works now.

KinglittleQ commented 6 years ago

I had the same problem too. But I installed Ghostscript and my problem has been solved !!!

cjchristopher commented 6 years ago

@taroxd 's fix works for the version of GS in texlive 2017 for Windows. The install just seems to not set the relevant paths / registry entries for GS (that is, I can confirm I had no registry entry for ghostscript upon searching).

jhelgert commented 6 years ago

There also seems to be a problem with the bundled ghostscript in MacTex2016 on MacOS. I had the same issue and it was solved by installing ghostscript via homebrew.

med95 commented 6 years ago

Thank you! It works @hsiktas

CareF commented 6 years ago

Thanks @taroxd . This solution works perfectly.

gwaterCy commented 6 years ago

Thanks @taroxd . This solution is really helpful.

ankitp94 commented 6 years ago

Thanks @taroxd

hqyyqh commented 6 years ago

Thanks @hsiktas . This solution works perfectly.

hqyyqh commented 6 years ago

Thanks @taroxd

lirm-math commented 6 years ago

@taroxd Thanks. The solution works perfectly.

musm commented 5 years ago

Thank @taroxd I had the same problem.

avDec25 commented 5 years ago

Installed Chocolatey via PowerShell (admin), as instructed on the page Then installed GhostScript using command: choco install ghostscript

Added path = "C:\Program Files\gs\gs9.24\bin" to environment variable Restarted Sublime Text 3 (Build 3176) + LaTeXTools and it worked.

On Windows 10 (Version 1809: OS build 17763.55) and using Texlive 2018

Also I've changed before: In: Preferences > Package Settings > LaTeX Tools > Settings - User Under heading "windows" changed distro to texlive "distro" : "texlive",

Brightchu commented 5 years ago

Resource\Init

works great!

avDec25 commented 5 years ago

Yes it works, but crashes were frequent

On Mon, Apr 1, 2019, 12:22 PM Brightchu notifications@github.com wrote:

Resource\Init

works great!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/SublimeText/LaTeXTools/issues/1148#issuecomment-478457569, or mute the thread https://github.com/notifications/unsubscribe-auth/ACi4oRnLgfSQcLbmszWOxBAfRbw4E0g-ks5vcayrgaJpZM4Nyi7U .

LiuPeng-hot commented 4 years ago

@taroxd Thanks. This problem waste me too time!!!

wangfh5 commented 4 years ago

I encountered this problem too. All the methods above did not work. But it finally worded after I added path = "C:\Program Files\gs\gs9.50\bin" to user's environment variable. I used to add that path to system's environment variable.

LatitudeZhou commented 4 years ago

Thank you! @hsiktas It really helps me a lot!

jeckstei commented 3 years ago

Recently had this issue too. Choclatey was not necessary to fix it. I just installed the latest 32-bit GhostScript from ghostscript.com and put its \bin directory near the top of the Windows path (see https://www.architectryan.com/2018/03/17/add-to-the-path-on-windows-10/). I restarted Sublime Text and preview now works! Even though the texlive version of ghostscript shows up green in the configuration report, I guess it doesn't actually work.

note286 commented 3 years ago

If you encounter the following error: Failed to convert pdf to png to preview. Add the following two paths to the environment variable, and pay attention to replacing them with your own version of texlive.

C:\texlive\2021\tlpkg\tlgs\Resource\Init
C:\texlive\2021\tlpkg\tlgs\kanji

Here's how I found the solution. After encounter the error, I installed Ghostscript myself at the beginning and added it to the top of the environment variable. However, after checking the system, LaTeXTools prompts me that the path of Ghostscript is still C:\texlive\2021\tlpkg\tlgs\bin\gswin32c.exe. So I run

cd C:\texlive\2021\tlpkg\tlgs\bin
gswin32c.exe

I got GPL Ghostscript 9.54.0: Can't find initialization file gs_init.ps.. I finally found this solution in a blog.

jiandandaoxingfu commented 1 year ago

@taroxd Thanks, It does work.