Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

equation preview in windows texlive 2017? #1148

Open
645978336 opened this issue Jun 7, 2017 · 38 comments
Open

equation preview in windows texlive 2017? #1148

645978336 opened this issue Jun 7, 2017 · 38 comments

Comments

@645978336
Copy link

645978336 commented Jun 7, 2017

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
Copy link
Member

r-stein commented Jun 7, 2017

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

@645978336
Copy link
Author

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
Copy link
Member

r-stein commented Jun 7, 2017

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

@645978336
Copy link
Author

645978336 commented Jun 7, 2017

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
Copy link
Member

r-stein commented Jun 7, 2017

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

@645978336
Copy link
Author

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
Copy link
Member

r-stein commented Jun 7, 2017

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

@645978336
Copy link
Author

ok, I give up, maybe something is wrong.

@hsiktas
Copy link

hsiktas commented Jun 12, 2017

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
Copy link
Member

r-stein commented Jun 12, 2017

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
Copy link

hsiktas commented Jun 12, 2017

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
Copy link
Member

r-stein commented Jun 12, 2017

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

@hsiktas
Copy link

hsiktas commented Jun 12, 2017

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
Copy link
Member

r-stein commented Jun 13, 2017

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
Copy link
Collaborator

ig0774 commented Jun 13, 2017

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
Copy link

hsiktas commented Jun 13, 2017

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
Copy link
Author

thank you!, It works @hsiktas

@taroxd
Copy link

taroxd commented Jul 12, 2017

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
Copy link

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

@cjchristopher
Copy link

@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
Copy link

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
Copy link

med95 commented Mar 19, 2018

Thank you! It works @hsiktas

@CareF
Copy link

CareF commented Apr 2, 2018

Thanks @taroxd . This solution works perfectly.

@gwaterCy
Copy link

gwaterCy commented May 7, 2018

Thanks @taroxd . This solution is really helpful.

@ankitp94
Copy link

Thanks @taroxd

@hqyyqh
Copy link

hqyyqh commented Jul 11, 2018

Thanks @hsiktas . This solution works perfectly.

@hqyyqh
Copy link

hqyyqh commented Jul 11, 2018

Thanks @taroxd

@lirm-math
Copy link

@taroxd Thanks. The solution works perfectly.

@musm
Copy link

musm commented Oct 3, 2018

Thank @taroxd I had the same problem.

@avDec25
Copy link

avDec25 commented Oct 15, 2018

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",

ig0774 added a commit that referenced this issue Oct 23, 2018
In addition to adding the appropriate library paths by default, this commit also should make the
Ghostscript part of preview_utils saner if Ghostscript cannot be found.
@Brightchu
Copy link

Resource\Init

works great!

@avDec25
Copy link

avDec25 commented Apr 1, 2019 via email

@LiuPeng-hot
Copy link

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

@wangfh5
Copy link

wangfh5 commented Dec 23, 2019

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
Copy link

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

@jeckstei
Copy link

jeckstei commented Dec 8, 2020

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
Copy link

note286 commented May 24, 2021

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
Copy link

@taroxd Thanks, It does work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests