[求助] 在org-babel latex代码块使用pgfplots调用gnuplot出错

网上抄的配置,可以在org mode latex 代码块生成图片。

#+PROPERTY: header-args:latex :results file raw drawer :headers '("\\usepackage{tikz}") :imagemagick yes :iminoptions -density 600 :imoutoptions -trim  :eval never-export :output-dir img/  :file (concat (org-id-uuid) ".png")

并且在下面的org block 中写pgfplots也能正常生成图片。

#+header: :headers '("\\usepackage{pgfplots} \\pgfplotsset{compat=1.18}")
#+begin_src latex
\begin{tikzpicture}
\begin{axis}[axis lines=center, xmin=-1.2, xmax=1.2, ymin=-1.2, ymax=1.2,
    ticks=none, axis on top=true, axis line style=thick, axis equal, samples=500]
\addplot [no marks] {x^2};
\end{axis}
\end{tikzpicture}
#+end_src

但对于有些复杂函数,pgfplots画起来有点吃力,需要调用gnuplot。我这里用gnuplot还是画二次函数。

#+header: :headers '("\\usepackage{pgfplots} \\pgfplotsset{compat=1.18}")
#+begin_src latex
\begin{tikzpicture}
  \begin{axis}[axis lines=center, xmin=-1.2, xmax=1.2, ymin=-1.2, ymax=1.2,
    ticks=none, axis on top=true, axis line style=thick, axis equal, samples=500
    ]
    \addplot [no marks] gnuplot [id=quadratic] {x**2};
  \end{axis}
\end{tikzpicture}
#+end_src

执行出现错误,*Org PDF LaTeX Output*的错误信息如下:

This is XeTeX, Version 3.141592653-2.6-0.999994 (TeX Live 2022) (preloaded format=xelatex)
 \write18 enabled.
entering extended mode

(../../../../../../../../var/folders/sz/3yld39q542x3gxz3tdr___rh0000gn/T/babel-
zUB0Qm//../../../../../../../../var/folders/sz/3yld39q542x3gxz3tdr___rh0000gn/T
/babel-zUB0Qm/latex-RLDGdc.tex
LaTeX2e <2021-11-15> patch level 1
L3 programming layer <2022-02-24>
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/article.cls
Document Class: article 2021/10/04 v1.4n Standard LaTeX document class
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2022/texmf-dist/tex/latex/graphics/color.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/graphics-cfg/color.cfg)
(/usr/local/texlive/2022/texmf-dist/tex/latex/graphics-def/xetex.def))
(/usr/local/texlive/2022/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/local/texlive/2022/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/local/texlive/2022/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/local/texlive/2022/texmf-dist/tex/latex/amsmath/amsopn.sty))
(/usr/local/texlive/2022/texmf-dist/tex/latex/fontspec/fontspec.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/l3backend/l3backend-xetex.def
(|extractbb --version))))
(/usr/local/texlive/2022/texmf-dist/tex/latex/fontspec/fontspec-xetex.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/fontenc.sty)
(/usr/local/texlive/2022/texmf-dist/tex/latex/fontspec/fontspec.cfg)))
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/inputenc.sty

Package inputenc Warning: inputenc package ignored with utf8 based engines.

) (/usr/local/texlive/2022/texmf-dist/tex/latex/base/fontenc.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/lm/t1lmr.fd))
(/usr/local/texlive/2022/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2022/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/local/texlive/2022/texmf-dist/tex/latex/graphics-cfg/graphics.cfg)))
(/usr/local/texlive/2022/texmf-dist/tex/latex/tools/longtable.sty)
(/usr/local/texlive/2022/texmf-dist/tex/latex/wrapfig/wrapfig.sty)
(/usr/local/texlive/2022/texmf-dist/tex/latex/graphics/rotating.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/ifthen.sty))
(/usr/local/texlive/2022/texmf-dist/tex/generic/ulem/ulem.sty)
(/usr/local/texlive/2022/texmf-dist/tex/latex/amsfonts/amssymb.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/amsfonts/amsfonts.sty))
(/usr/local/texlive/2022/texmf-dist/tex/latex/capt-of/capt-of.sty)
(/usr/local/texlive/2022/texmf-dist/tex/latex/pgfplots/pgfplots.sty
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgfplots/pgfplots.revision.tex)
(/usr/local/texlive/2022/texmf-dist/tex/latex/pgf/frontendlayer/tikz.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/pgf/basiclayer/pgf.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/pgf/utilities/pgfrcs.sty
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/utilities/pgfutil-common.te
x
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/utilities/pgfutil-common-li
sts.tex))
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/utilities/pgfutil-latex.def
) (/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/utilities/pgfrcs.code.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/pgf.revision.tex)))
(/usr/local/texlive/2022/texmf-dist/tex/latex/pgf/basiclayer/pgfcore.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/pgf/systemlayer/pgfsys.sty
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/systemlayer/pgfsys.code.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/utilities/pgfkeysfiltered.c
ode.tex))
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/systemlayer/pgf.cfg)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/systemlayer/pgfsys-xetex.de
f
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/systemlayer/pgfsys-dvipdfmx
.def
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/systemlayer/pgfsys-common-p
df.def))))
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/systemlayer/pgfsyssoftpath.
code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/systemlayer/pgfsysprotocol.
code.tex)) (/usr/local/texlive/2022/texmf-dist/tex/latex/xcolor/xcolor.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/graphics-cfg/color.cfg))
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcore.code.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmath.code.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathcalc.code.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathutil.code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathparser.code.tex
)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.code.
tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.basic
.code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.trigo
nometric.code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.rando
m.code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.compa
rison.code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.base.
code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.round
.code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.misc.
code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.integ
erarithmetics.code.tex)))
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathfloat.code.tex)
) (/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfint.code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepoints.co
de.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathconst
ruct.code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathusage
.code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcorescopes.co
de.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcoregraphicst
ate.code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcoretransform
ations.code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcorequick.cod
e.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreobjects.c
ode.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathproce
ssing.code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcorearrows.co
de.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreshade.cod
e.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreimage.cod
e.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreexternal.
code.tex))
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcorelayers.co
de.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcoretranspare
ncy.code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepatterns.
code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcorerdf.code.
tex)))
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/modules/pgfmoduleshapes.cod
e.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/modules/pgfmoduleplot.code.
tex)
(/usr/local/texlive/2022/texmf-dist/tex/latex/pgf/compatibility/pgfcomp-version
-0-65.sty)
(/usr/local/texlive/2022/texmf-dist/tex/latex/pgf/compatibility/pgfcomp-version
-1-18.sty))
(/usr/local/texlive/2022/texmf-dist/tex/latex/pgf/utilities/pgffor.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/pgf/utilities/pgfkeys.sty
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex)
) (/usr/local/texlive/2022/texmf-dist/tex/latex/pgf/math/pgfmath.sty
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmath.code.tex))
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/utilities/pgffor.code.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmath.code.tex)))
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/frontendlayer/tikz/tikz.cod
e.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/libraries/pgflibraryplothan
dlers.code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/modules/pgfmodulematrix.cod
e.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/frontendlayer/tikz/librarie
s/tikzlibrarytopaths.code.tex)))
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgfplots/pgfplots.code.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgfplots/pgfplotscore.code.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgfplots/sys/pgfplotssysgeneric
.code.tex))
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgfplots/libs/pgfplotslibrary.c
ode.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplot
soldpgfsupp_loader.code.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/libraries/pgflibraryfpu.cod
e.tex))
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgfplots/util/pgfplotsutil.code
.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgfplots/liststructure/pgfplots
liststructure.code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgfplots/liststructure/pgfplots
liststructureext.code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgfplots/liststructure/pgfplots
array.code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgfplots/liststructure/pgfplots
matrix.code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgfplots/numtable/pgfplotstable
shared.code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgfplots/liststructure/pgfplots
deque.code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgfplots/util/pgfplotsbinary.co
de.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgfplots/util/pgfplotsbinary.da
ta.code.tex))
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgfplots/util/pgfplotsutil.verb
.code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgfplots/libs/pgflibrarypgfplot
s.surfshading.code.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots
.surfshading.pgfsys-xetex.def
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgfplots/sys/pgflibrarypgfplots
.surfshading.pgfsys-dvipdfmx.def))))
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgfplots/util/pgfplotscolormap.
code.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgfplots/util/pgfplotscolor.cod
e.tex))
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgfplots/pgfplotsstackedplots.c
ode.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgfplots/pgfplotsplothandlers.c
ode.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgfplots/pgfplotsmeshplothandle
r.code.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgfplots/pgfplotsmeshplotimage.
code.tex)))
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgfplots/pgfplots.scaling.code.
tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessin
g.code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgfplots/pgfplots.errorbars.cod
e.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgfplots/pgfplots.markers.code.
tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgfplots/pgfplotsticks.code.tex
)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgfplots/pgfplots.paths.code.te
x)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/frontendlayer/tikz/librarie
s/tikzlibrarydecorations.code.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/modules/pgfmoduledecoration
s.code.tex))
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/frontendlayer/tikz/librarie
s/tikzlibrarydecorations.pathmorphing.code.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/libraries/decorations/pgfli
brarydecorations.pathmorphing.code.tex))
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/frontendlayer/tikz/librarie
s/tikzlibrarydecorations.pathreplacing.code.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/libraries/decorations/pgfli
brarydecorations.pathreplacing.code.tex))
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplo
ts.contourlua.code.tex))
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/frontendlayer/tikz/librarie
s/tikzlibraryplotmarks.code.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/libraries/pgflibraryplotmar
ks.code.tex)))
(../../../../../../../../var/folders/sz/3yld39q542x3gxz3tdr___rh0000gn/T/babel-
zUB0Qm//latex-RLDGdc.aux)
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/ts1cmr.fd)line 0: Cannot load input from 'latex-RLDGdc.quadratic.gnuplot'

system returned with code 256

Package pgfplots notification 'compat/show suggested version=true': document ha
s been generated with the most recent feature set (\pgfplotsset{compat=1.18}).


! Package pgfplots Error: Sorry, the gnuplot-result file 'latex-RLDGdc.quadrati
c.table' could not be found. Maybe you need to enable the shell-escape feature?
 For pdflatex, this is '>> pdflatex -shell-escape'. You can also invoke '>> gnu
plot <file>.gnuplot' manually on the respective gnuplot file..

See the pgfplots package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.46 ... [no marks] gnuplot [id=quadratic] {x**2};
                                                  
[1]
(../../../../../../../../var/folders/sz/3yld39q542x3gxz3tdr___rh0000gn/T/babel-
zUB0Qm/latex-RLDGdc.aux) )
(see the transcript file for additional information)
Output written on ../../../../../../../../var/folders/sz/3yld39q542x3gxz3tdr___
rh0000gn/T/babel-zUB0Qm/latex-RLDGdc.pdf (1 page).
Transcript written on ../../../../../../../../var/folders/sz/3yld39q542x3gxz3td
r___rh0000gn/T/babel-zUB0Qm//latex-RLDGdc.log.

错误为没能调用gnuplot,所以没能生成quadratic.table数据文件,提示说可能原因是没有用 -shell-escape选项,但我的org-latex-pdf-process的设置为("xelatex -shell-escape -interaction nonstopmode -output-directory %o %f" "xelatex -shell-escape -interaction nonstopmode -output-directory %o %f" "xelatex -shell-escape -interaction nonstopmode -output-directory %o %f")

org-babel产生的latex-RLDGdc.tex文件为

\documentclass{article}
\usepackage[usenames]{color}
\usepackage{amsmath}
\usepackage{fontspec}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{capt-of}
\pagestyle{empty}             % do not remove
% The settings below are copied from fullpage.sty
\setlength{\textwidth}{\paperwidth}
\addtolength{\textwidth}{-3cm}
\setlength{\oddsidemargin}{1.5cm}
\addtolength{\oddsidemargin}{-2.54cm}
\setlength{\evensidemargin}{\oddsidemargin}
\setlength{\textheight}{\paperheight}
\addtolength{\textheight}{-\headheight}
\addtolength{\textheight}{-\headsep}
\addtolength{\textheight}{-\footskip}
\addtolength{\textheight}{-3cm}
\setlength{\topmargin}{1.5cm}
\addtolength{\topmargin}{-2.54cm}
\usepackage{pgfplots} \pgfplotsset{compat=1.18}

\begin{document}
\begin{tikzpicture}
  \begin{axis}[axis lines=center, xmin=-1.2, xmax=1.2, ymin=-1.2, ymax=1.2,
    ticks=none, axis on top=true, axis line style=thick, axis equal, samples=500
    ]
    \addplot [no marks] gnuplot [id=quadratic] {x**2};
  \end{axis}
\end{tikzpicture}
\end{document}

手动编译这个latex文件

 xelatex -shell-escape -interaction nonstopmode latex-RLDGdc.tex

就能正常调用gnuplot,生成table数据文件,生成的pdf中图像可以画出来。

问题应该就是在执行org babel latex代码块时,不知道什么原因无法调用gnuplot,但我用org-latex-pdf-process的命令手动编译latex就能生成。

正好我最近研究latex下pgfplot画图这个shell-escape的问题并找到了解决方案,好像就是在论坛里。核心是显示的选项但实际并没有用shell-escape。所以需要手工设置。简单的方法就是配置用快捷键切换:

(after! latex
  (defun TeX-command-toggle-shell-escape ()
        (interactive)
        (setq TeX-command-extra-options
        (cond ((string-match-p "\\_<--shell-escape\\_>" TeX-command-extra-options )
                (replace-regexp-in-string "\\_<--shell-escape\\_>" "" TeX-command-extra-options))
                ((string-empty-p TeX-command-extra-options)"--shell-escape")
                (t(format "--shell-escape %s" TeX-command-extra-options))))
        (message "TeX-command-extra-options : `%s'" TeX-command-extra-options))
  (map! :after latex
        :localleader
        :map LaTeX-mode-map
        :desc "Toggle shell escape"  "t" #'TeX-command-toggle-shell-escape)
)

我用的doom-emacs,在latex文件中我的可以正常运行的。只是在org-babel latex 代码块里面运行不起来。

latex mode是如何配置的?我也是doom-emacs,init中把latex用上即启用auctex,但默认配置就会出现shell-escape这个问题,我发的就是找到的解决办法。也正好学习一下你的配置。

我不用org-babel,不过我理解其过程是不是也是先导出成latex,再调用xelatex编译。那么这个编译的配置和auctex下可能不一样,可以比较一下差异。

我加上这一句,我默认开启。

(setq-default TeX-command-extra-options "-shell-escape") ; or --shell-escape

哦,默认开启感觉不安全。那看来 org babel的latex并不管这个设置