【问题标题】:Configure org mode to use LuaLaTeX配置 org 模式以使用 LuaLaTeX
【发布时间】:2017-01-10 12:02:41
【问题描述】:

我正在使用 emacs 的org-mode 来排版笔记并通过 LaTeX 将它们导出为 pdf。一切正常,除非我使用 Unicode 符号,如

\begin{equation}
  \left( \frac{P^2}{2m} + V(x,y,z) \right) Ψ = E Ψ
\end{equation}

我在哪里使用Ψ。使用#+latex_compiler: lualatex

(setq org-latex-pdf-process
      '("lualatex -shell-escape -interaction nonstopmode %f"
        "lualatex -shell-escape -interaction nonstopmode %f")) 

我已经设法使用 LuaLaTeX 导出或多或少有问题的 PDF,但是公式的预览 (C-c C-x C-l) 对于带有 Unicode 符号的公式的预览是完全损坏的。

我需要在我的 emacs 配置中进行哪些更改才能将 LuaLaTeX 用于org-mode 中与 LaTeX 相关的一切

【问题讨论】:

    标签: unicode emacs latex org-mode


    【解决方案1】:

    将以下代码添加到您的 init 文件中(注意,它会在 org-preview-latex-process-alist 的值中添加一个元素,因此此代码必须在 org 加载后添加 - 您可能还需要(需要'org)):

    ;; lualatex preview
    (setq org-latex-pdf-process
      '("lualatex -shell-escape -interaction nonstopmode %f"
        "lualatex -shell-escape -interaction nonstopmode %f")) 
    
    (setq luamagick '(luamagick :programs ("lualatex" "convert")
           :description "pdf > png"
           :message "you need to install lualatex and imagemagick."
           :use-xcolor t
           :image-input-type "pdf"
           :image-output-type "png"
           :image-size-adjust (1.0 . 1.0)
           :latex-compiler ("lualatex -interaction nonstopmode -output-directory %o %f")
           :image-converter ("convert -density %D -trim -antialias %f -quality 100 %O")))
    
    (add-to-list 'org-preview-latex-process-alist luamagick)
    
    (setq org-preview-latex-default-process 'luamagick)
    

    我必须添加支持数学的字体 (XITS),因此 org 文件本身现在看起来像这样:

    #+LATEX_HEADER: \usepackage{unicode-math}
    #+LATEX_HEADER: \setmainfont{XITS}
    #+LATEX_HEADER: \setmathfont{XITS Math}
    #+LATEX_HEADER: \setmathfont[range={\mathcal,\mathbfcal},StylisticSet=1]{XITS Math}
    
    * A formula for lua
    \begin{equation}
      \left( \frac{P^2}{2m} + V(x,y,z) \right) Ψ = E Ψ
    \end{equation}
    

    导出为 PDF 和预览似乎都可以工作。

    【讨论】:

    • 顺便说一句,这个机制是冯书在 2016 年 5 月添加的,所以你需要一个相当新的组织才能使用它。对于早期版本的 org,您需要修改 org 代码本身。
    【解决方案2】:

    我将 Windows 10 与 Emacs 26.1 一起使用,@NickD 的解决方案对我有用,只做了一些小的改动

    (setq org-latex-pdf-process
      '("lualatex -shell-escape -interaction nonstopmode %f"
        "lualatex -shell-escape -interaction nonstopmode %f"))
    
    (setq luamagick '(luamagick :programs ("lualatex" "magick")
           :description "pdf > png"
           :message "you need to install lualatex and imagemagick."
           :use-xcolor t
           :image-input-type "pdf"
           :image-output-type "png"
           :image-size-adjust (1.0 . 1.0)
           :latex-compiler ("lualatex -interaction nonstopmode -output-directory %o %f")
           :image-converter ("magick convert -density %D -trim -antialias %f -quality 100 %O")))
    
    (add-to-list 'org-preview-latex-process-alist luamagick)
    
    (setq org-preview-latex-default-process 'luamagick)
    

    使用magick 而不是convertconvert 不起作用,因为有一个名为 convert.exe 的默认 Windows 程序

    【讨论】:

      【解决方案3】:

      在您的 org-preview-latex-process-alist 中添加一个 lualatex 条目,如下所示:

      (setq org-preview-latex-process-alist
        '((lualatex :programs ("lualatex" "dvisvgm")
                        :description "dvi > svg"
                        :message "you need to install the programs: lualatex and dvisvgm."
                        :image-input-type "dvi"
                        :image-output-type "svg"
                        :image-size-adjust (1.0 . 1.0)
                        :latex-compiler
                        ("lualatex --interaction=nonstopmode --shell-escape --output-format=dvi --output-directory=%o %f")
                        :image-converter
                        ("dvisvgm %f -n -b min -c %S -o %O"))))
      (setq org-preview-latex-process 'lualatex)
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-01-28
        • 2015-10-19
        • 1970-01-01
        • 2018-07-02
        • 2016-03-28
        • 1970-01-01
        相关资源
        最近更新 更多