ubuntu AUCTEX 无法预览数学公式

大家好: Emacs AUCTEX 无法预览数学公式,之前提供的信息不充分,今天更新以下,希望能解决这个问题。

问题: 点击auctex preview 按钮button ,不能现实预览公式图片,而是一个“禁止进入"的图标no-entry . 右键点击这个图标,显示是postscript error 选择“view error" 显示如下错误信息: 另外:auctex 可以正常编译生成pdf文件,只是不能预览

/usr/local/texlive/2018/bin/x86_64-linux/rungs -dOutputFile\=\(_region_.prv/tmpZtVdYq/pr1-1.png\) -q -dDELAYSAFER -dNOPAUSE -DNOPLATFONTS -dPrinted -dTextAlphaBits\=4 -dGraphicsAlphaBits\=4 -sDEVICE\=png16m -r112.35x112.33
GS>{<</PermitFileReading[(_region_.pdf)(_region_.prv/tmpZtVdYq/preview.dsc)]>> setuserparams .locksafe} stopped pop {DELAYSAFER{.setsafe}if}stopped pop/.preview-BP currentpagedevice/BeginPage get dup null eq{pop{pop}bind}if def<</BeginPage{currentpagedevice/PageSize get dup 0 get 1 ne exch 1 get 1 ne or{.preview-BP 0.152346 0.156252 0.132815 setrgbcolor clippath fill 0.968765 0.968765 0.945327 setrgbcolor}{pop}ifelse}bind/PageSize[1 1]>>setpagedevice/preview-do{/.preview-ST[count 4 roll save]def dup length 0 eq{pop}{setpagedevice}{ifelse exec}stopped{handleerror quit}if .preview-ST aload pop restore}bind def /GS_PDF_ProcSet GS_PDF_ProcSet dup maxlength dict copy dup begin/graphicsbeginpage{//graphicsbeginpage exec 0.968765 0.968765 0.945327 3 copy rg RG}bind store end readonly store  (_region_.prv/tmpZtVdYq/preview.dsc)(r)file /.preview-ST 1 index def dup 0 setfileposition 410()/SubFileDecode filter cvx exec .preview-ST dup dup 410 setfileposition 50()/SubFileDecode filter cvx<<>>preview-do
Error: /undefined in GS_PDF_ProcSet
Operand stack:
Execution stack:
%interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   %loop_continue   --nostringval--   --nostringval--   false   1   %stopped_push   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--
Dictionary stack:
--dict:977/1684(ro)(G)--   --dict:0/20(G)--   --dict:79/200(L)--
Current allocation mode is local
Last OS error: No such file or directory
Current file position is 644

同样右击“禁止进入”图标,选择“view source" 显示:

%%CreationDate: (D:20190724190028+08'00')
%%DocumentMedia: y8.03x27.235 27.235 8.03 70 white ()
%%Pages: 1
/Page null def
/Page# 0 def
/PDFSave null def
/DSCPageCount 0 def
/DoPDFPage {dup /Page# exch store dup dopdfpages } def
(_region_.pdf) (r) file { DELAYSAFER { .setsafe } if } stopped pop
%%Page: 1 1
%%PageMedia: y8.03x27.235
1 DoPDFPage

M-x preview-report-bug 得到的信息如下:

To: [email protected]
Subject: 12.1.2; auctex
From: wzt <wz[email protected]me>
--text follows this line--

Remember to cover the basics.  Including a minimal LaTeX example
file exhibiting the problem might help.

Emacs  : GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30)
 of 2019-06-10
Package: 12.1.2

Run buffer contents:

Running `Preview-LaTeX' on `~/research/manuscripts/_region_' with ``pdflatex  -interaction=nonstopmode -file-line-error \&prv_scratch "/AUCTEXINPUT{" _region_.tex "}"''
This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2018) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
LaTeX2e <2018-04-01> patch level 5
CUSTOMISED FORMAT. Preloaded files:
 article.cls    2014/09/29 v1.4h Standard LaTeX document class
  size11.clo    2014/09/29 v1.4h Standard LaTeX file (size option)
geometry.sty    2018/04/16 v5.8 Page Geometry
  keyval.sty    2014/10/28 v1.15 key=value parser (DPC)
   ifpdf.sty    2017/03/15 v3.2 Provides the ifpdf switch
  ifvtex.sty    2016/05/16 v1.6 Detect VTeX and its facilities (HO)
 ifxetex.sty    2010/09/12 v0.6 Provides ifxetex conditional
graphicx.sty    2017/06/01 v1.1a Enhanced LaTeX Graphics (DPC,SPQR)
graphics.sty    2017/06/25 v1.2c Standard LaTeX Graphics (DPC,SPQR)
    trig.sty    2016/01/03 v1.10 sin cos tan (DPC)
graphics.cfg    2016/06/04 v1.11 sample graphics configuration
  pdftex.def    2018/01/08 v1.0l Graphics/color driver for pdftex
 grffile.sty    2017/06/30 v1.18 Extended file name support for graphics (HO)
kvoptions.sty    2016/05/16 v3.12 Key value format for package options (HO)
 ltxcmds.sty    2016/05/16 v1.23 LaTeX kernel commands for general use (HO)
kvsetkeys.sty    2016/05/16 v1.17 Key value parser (HO)
infwarerr.sty    2016/05/16 v1.4 Providing info/warning/error messages (HO)
etexcmds.sty    2016/05/16 v1.6 Avoid name clashes with e-TeX commands (HO)
ifluatex.sty    2016/05/16 v1.4 Provides the ifluatex switch (HO)
pdftexcmds.sty    2018/01/30 v0.27 Utility functions of pdfTeX for LuaTeX (HO)
longtable.sty    2014/10/28 v4.11 Multi-page Table package (DPC)
 wrapfig.sty    2003/01/31  v 3.6
rotating.sty    2016/08/11 v2.16d rotated objects in LaTeX
  ifthen.sty    2014/09/29 v1.1c Standard LaTeX ifthen package (DPC)
    ulem.sty    2012/05/18
 amsmath.sty    2017/09/02 v2.17a AMS math features
 amstext.sty    2000/06/29 v2.01 AMS text
  amsgen.sty    1999/11/30 v2.0 generic functions
  amsbsy.sty    1999/11/29 v1.2d Bold Symbols
  amsopn.sty    2016/03/08 v2.02 operator names
textcomp.sty    2017/04/05 v2.0i Standard LaTeX package
  ts1enc.def    2001/06/05 v3.0e (jk/car/fm) Standard LaTeX file
  ts1enc.dfu    2018/04/05 v1.2c UTF-8 support for inputenc
 amssymb.sty    2013/01/14 v3.01 AMS font symbols
amsfonts.sty    2013/01/14 v3.01 Basic AMSFonts s...


 hpdftex.def    2018/02/06 v6.86b Hyperref driver for pdfTeX
rerunfilecheck.sty    2016/05/16 v1.8 Rerun checks for auxiliary files (HO)
    umsa.fd    2013/01/14 v3.01 AMS symbols A
    umsb.fd    2013/01/14 v3.01 AMS symbols B
No file _region_.aux.
(/usr/local/texlive/2018/texmf-dist/tex/latex/base/ts1cmr.fd) (/home/wzt/.emacs.d/elpa/auctex-12.1.2/latex/preview.sty (/usr/local/texlive/2018/texmf-dist/tex/generic/luatex85/luatex85.sty) (/home/wzt/.emacs.d/elpa/auctex-12.1.2/latex/prtightpage.def) (/home/wzt/.emacs.d/elpa/auctex-12.1.2/latex/prauctex.def
No auxiliary output files.

(/home/wzt/.emacs.d/elpa/auctex-12.1.2/latex/prauctex.cfg)) (/home/wzt/.emacs.d/elpa/auctex-12.1.2/latex/prfootnotes.def)
Preview: Fontsize 10.95pt
Preview: PDFoutput 1
*geometry* driver: auto-detecting
*geometry* detected driver: pdftex
[Loading MPS to PDF converter (version 2006.09.02).]
) (/usr/local/texlive/2018/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty (/usr/local/texlive/2018/texmf-dist/tex/latex/oberdiek/grfext.sty) (/usr/local/texlive/2018/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg)) (/usr/local/texlive/2018/texmf-dist/tex/latex/hyperref/nameref.sty (/usr/local/texlive/2018/texmf-dist/tex/generic/oberdiek/gettitlestring.sty))  !name(scratch.tex) !offset(-3) 
./_region_.tex:32: Preview: Snippet 1 started.
l.32 $
Preview: Tightpage -32891 -32891 32891 32891
./_region_.tex:32: Preview: Snippet 1 ended.(462465+0x1725769).
l.32 $x=2$
[1{/usr/local/texlive/2018/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] )
(see the transcript file for additional information)</usr/local/texlive/2018/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi10.pfb></usr/local/texlive/2018/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb>
Output written on _region_.pdf (1 page, 16141 bytes).
Transcript written on _region_.log.

TeX Output exited as expected with code 1 at Wed Jul 24 19:00:28
Running `Preview-PDF2DSC' with ``pdf2dsc _region_.pdf _region_.prv/tmpZtVdYq/preview.dsc''

Preview-PDF2DSC finished at Wed Jul 24 19:00:28
Running `Preview-Ghostscript' with ``/usr/local/texlive/2018/bin/x86_64-linux/rungs -dOutputFile\=\(_region_.prv/tmpZtVdYq/pr1-\%d.png\) -q -dDELAYSAFER -dNOPAUSE -DNOPLATFONTS -dPrinted -dTextAlphaBits\=4 -dGraphicsAlphaBits\=4 -sDEVICE\=png16m -r112.35x112.33''

Preview-Ghostscript finished at Wed Jul 24 19:00:28

current state:
 AUCTeX-version "12.1.2"
 LaTeX-command-style '((""
			"%(PDF)%(latex) %(file-line-error) %(extraopts) %S%(PDFout)")
 image-types '(svg png gif tiff jpeg xpm xbm pbm postscript)
 preview-image-type 'png
 preview-image-creators '((dvipng
			   (open preview-gs-open
			   (place preview-gs-place)
			   (close preview-dvipng-close))
			  (png (open preview-gs-open)
			   (place preview-gs-place)
			   (close preview-gs-close))
			  (jpeg (open preview-gs-open)
			   (place preview-gs-place)
			   (close preview-gs-close))
			  (pnm (open preview-gs-open)
			   (place preview-gs-place)
			   (close preview-gs-close))
			  (tiff (open preview-gs-open)
			   (place preview-gs-place)
			   (close preview-gs-close))
 preview-dvipng-image-type 'png
 preview-dvipng-command "dvipng -picky -noghostscript %d -o %m/prev%%03d.png"
 preview-pdf2dsc-command "pdf2dsc %s.pdf %m/preview.dsc"
 preview-gs-command "/usr/local/texlive/2018/bin/x86_64-linux/rungs"
 preview-gs-options '("-q" "-dDELAYSAFER" "-dNOPAUSE" "-DNOPLATFONTS"
		      "-dPrinted" "-dTextAlphaBits=4"
 preview-gs-image-type-alist '((png png "-sDEVICE=png16m")
			       (dvipng png "-sDEVICE=png16m")
			       (jpeg jpeg "-sDEVICE=jpeg")
			       (pnm pbm "-sDEVICE=pnmraw")
			       (tiff tiff "-sDEVICE=tiff12nc"))
 preview-fast-conversion t
 preview-prefer-TeX-bb nil
 preview-dvips-command "dvips -Pwww -i -E %d -o %m/preview.000"
 preview-fast-dvips-command "dvips -Pwww %d -o %m/preview.ps"
 preview-scale-function 'preview-scale-from-face
 preview-LaTeX-command '("%`%l \"\\nonstopmode\\nofiles\\PassOptionsToPackage{"
			 ("," . preview-required-option-list)
			 "}{preview}\\AtBeginDocument{\\ifx\\ifPreview\\undefined" preview-default-preamble "\\fi}\"%' \"{\\detokenize{\" %t \"}}\"")
 preview-required-option-list '("active" "tightpage" "auctex"
				(preview-preserve-counters "counters"))
 preview-preserve-counters nil
 preview-default-option-list '("displaymath" "floats" "graphics"
			       "textmath" "sections" "footnotes")
 preview-default-preamble '("\\RequirePackage["
			    ("," . preview-default-option-list)
 preview-LaTeX-command-replacements nil
 preview-dump-replacements '(preview-LaTeX-command-replacements
			     ("\\`\\([^ ]+\\)\\(?: +\\(?:\\(--?kanji[= ][^ ]+\\)\\|-\\(?:[^ \\\"]\\|\\\\.\\|\"[^\"]*\"\\)*\\)\\)*\\(.*\\)\\'" "\\1 -ini \\2 -interaction=nonstopmode \"&\\1\" " preview-format-name ".ini \\3")
 preview-undump-replacements '(("\\`\\([^ ]+\\)\\(?: +\\(?:\\(--?kanji[= ][^ ]+\\)\\|-\\(?:[^ \\\"]\\|\\\\.\\|\"[^\"]*\"\\)*\\)\\)*.* \"\\\\input\" \"{\\\\detokenize{\" \\(.*\\) \"}}\"\\'" "\\1 \\2 -interaction=nonstopmode -file-line-error " preview-format-name " \"/AUCTEXINPUT{\" \\3 \"}\"")
 preview-auto-cache-preamble 'ask
 preview-TeX-style-dir "/home/wzt/.emacs.d/elpa/auctex-12.1.2/latex"

Output from running `/usr/local/texlive/2018/bin/x86_64-linux/rungs -h':
GPL Ghostscript 9.26 (2018-11-20)
Copyright (C) 2018 Artifex Software, Inc.  All rights reserved.
Usage: gs [switches] [file1.ps file2.ps ...]
Most frequently used switches: (you can use # in place of =)
 -dNOPAUSE           no pause after page   | -q       `quiet', fewer messages
 -g<width>x<height>  page size in pixels   | -r<res>  pixels/inch resolution
 -sDEVICE=<devname>  select device         | -dBATCH  exit after last file
 -sOutputFile=<file> select output file: - for stdout, |command for pipe,
                                         embed %d or %ld for page #
Input formats: PostScript PostScriptLevel1 PostScriptLevel2 PostScriptLevel3 PDF
Default output device: x11alpha
Available devices:
   alc1900 alc2000 alc4000 alc4100 alc8500 alc8600 alc9100 ap3250 atx23
   atx24 atx38 bbox bit bitcmyk bitrgb bitrgbtags bj10e bj10v bj10vh bj200
   bjc600 bjc800 bjc880j bjccmyk bjccolor bjcgray bjcmono bmp16 bmp16m
   bmp256 bmp32b bmpgray bmpmono bmpsep1 bmpsep8 ccr cdeskjet cdj1600 cdj500
   cdj550 cdj670 cdj850 cdj880 cdj890 cdj970 cdjcolor cdjmono cdnj500 cfax
   chp2200 cif cljet5 cljet5c cljet5pr coslw2p coslwxl cups declj250 deskjet
   devicen dfaxhigh dfaxlow display dj505j djet500 djet500c dl2100 dnj650c
   epl2050 epl2050p epl2120 epl2500 epl2750 epl5800 epl5900 epl6100 epl6200
   eplcolor eplmono eps2write eps9high eps9mid epson epsonc escp escpage
   faxg3 faxg32d faxg4 fmlbp fmpr fpng fs600 gdi gprf hl1240 hl1250 hl7x0
   hpdj1120c hpdj310 hpdj320 hpdj340 hpdj400 hpdj500 hpdj500c hpdj510
   hpdj520 hpdj540 hpdj550c hpdj560c hpdj600 hpdj660c hpdj670c hpdj680c
   hpdj690c hpdj850c hpdj855c hpdj870c hpdj890c hpdjplus hpdjportable ibmpro
   ijs imagen inferno ink_cov inkcov itk24i itk38 jetp3852 jj100 jpeg
   jpegcmyk jpeggray la50 la70 la75 la75plus laserjet lbp310 lbp320 lbp8
   lex2050 lex3200 lex5700 lex7000 lips2p lips3 lips4 lips4v lj250 lj3100sw
   lj4dith lj4dithp lj5gray lj5mono ljet2p ljet3 ljet3d ljet4 ljet4d
   ljet4pjl ljetplus ln03 lp1800 lp1900 lp2000 lp2200 lp2400 lp2500 lp2563
   lp3000c lp7500 lp7700 lp7900 lp8000 lp8000c lp8100 lp8200c lp8300c
   lp8300f lp8400f lp8500c lp8600 lp8600f lp8700 lp8800c lp8900 lp9000b
   lp9000c lp9100 lp9200b lp9200c lp9300 lp9400 lp9500c lp9600 lp9600s
   lp9800c lps4500 lps6500 lq850 lxm3200 lxm5700m m8510 md1xMono md2k
   md50Eco md50Mono md5k mgr4 mgr8 mgrgray2 mgrgray4 mgrgray8 mgrmono miff24
   mj500c mj6000c mj700v2c mj8000c ml600 necp6 npdl nullpage oce9050 oki182
   oki4w okiibm oprp opvp paintjet pam pamcmyk32 pamcmyk4 pbm pbmraw pcl3
   pclm pcx16 pcx24b pcx256 pcxcmyk pcxgray pcxmono pdfimage24 pdfimage32
   pdfimage8 pdfwrite pdfwrite pdfwrite pgm pgmraw pgnm pgnmraw photoex
   picty180 pj pjetxl pjxl pjxl300 pkm pkmraw pksm pksmraw plan plan9bm
   planc plang plank planm plib plibc plibg plibk plibm png16 png16m png256
   png48 pngalpha pnggray pngmono pngmonod pnm pnmraw ppm ppmraw pr1000
   pr1000_4 pr150 pr201 ps2write psdcmyk psdcmykog psdrgb pwgraster pxlcolor
   pxlmono r4081 rinkj rpdl samsunggdi sj48 spotcmyk st800 stcolor t4693d2
   t4693d4 t4693d8 tek4696 tiff12nc tiff24nc tiff32nc tiff48nc tiff64nc
   tiffcrle tiffg3 tiffg32d tiffg4 tiffgray tifflzw tiffpack tiffscaled
   tiffscaled24 tiffscaled32 tiffscaled4 tiffscaled8 tiffsep tiffsep1
   txtwrite uniprint x11 x11alpha x11cmyk x11cmyk2 x11cmyk4 x11cmyk8
   x11gray2 x11gray4 x11mono xcf xes xpswrite
Search path:
   /usr/share/ghostscript/9.26/Resource/Init :
   /usr/share/ghostscript/9.26/lib :
   /usr/share/ghostscript/9.26/Resource/Font :
   /usr/share/ghostscript/fonts : /var/lib/ghostscript/fonts :
   /usr/share/cups/fonts : /usr/share/ghostscript/fonts :
   /usr/local/lib/ghostscript/fonts : /usr/share/fonts
Ghostscript is also using fontconfig to search for font files
For more information, see /usr/share/doc/ghostscript/Use.htm.
On debian system you may need to install ghostscript-doc package.
Please report bugs to bugs.ghostscript.com.


ubuntu 18.04

GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30)
 of 2019-06-10
auctex --verion 12.1.2
gs --version 9.26
latex-math-preview 20170522.1455 

emacs preview 参数设置中的 Preview Tex Style Dir 路径是: /home/wzt/.emacs.d/elpa/auctex-12.1.2/latex

该路径下文件为:preview.sty 在该目录下

ls /home/wzt/.emacs.d/elpa/auctex-12.1.2/latex

bootstrap.ins prcounters.def prlyx.def prtracingall.def Makefile.in preview.dtx prshowbox.def README prauctex.cfg preview.sty prshowlabels.def prauctex.def prfootnotes.def prtightpage.def

所用的.tex 文件,只是写一个简单的公式:$x=2$。如下:

% Created 2019-07-01 一 18:26
% Intended LaTeX compiler: xelatex
 pdfcreator={Emacs 27.0.50 (Org mode 9.1.9)}, 




  1. 因为“禁止进入”图标,显示的是“postscript error" 所以可能和ghostscript 有关。
  2. postscript error 内容显示 Error: /undefined in GS_PDF_ProcSet, 感觉是GS_PDF_ProcSet 这个变量没有定义,这个应该是postscript 语言定义的,我不懂这中语言,大家有懂得,应该能分析出哪里出了问题。


是的,编译成PDF 没有问题。


用tlmgr 查看了一下,安装了的,版本是44883(11.91)

楼主请问你解决这个问题了吗? 我的也是这样





  • 我在这里


找到了这个We consider the reason of the problem is that preview-latex relies on GS_PDF_ProcSet, which was removed in Ghostscript 9.27,

  • 然后我降级gs到9.26,但是在每次打开emacs第一次SPC m p p的时候会用Preview-DviPS出错。


  • 但是我看楼主好像本来就是gs 9.26(

谢谢,提供的信息,很有用,链接里已经描述的很清楚了。我也确信是链接里描述的原因。就是GS_PDF_ProcSet这个变量会被调用,目的是调整预览公式的前景色,然而悲催的是,这个变量被gs抛弃了。我没有完全解决这个问题,只能做到,前景色是黑色的的效果,后来就放弃了(具体怎么做,想不起来了,不过链接里有方法,就是直接把前景色设置为黑色,这样auctex就不调用GS_PDF_ProcSet这个变量,也就不会报错了)。 PS:我主要是推导公式用,后来发现了texmacs这个神器,就不再关注这个bug了。不过还是希望能彻底解决这个问题。





1 个赞