代码之家  ›  专栏  ›  技术社区  ›  RedPointyJackson

配置组织模式以使用LuaLaTeX

  •  2
  • RedPointyJackson  · 技术社区  · 9 年前

    我在用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用于: 每件事 与乳胶有关 组织模式 ?

    3 回复  |  直到 9 年前
        1
  •  7
  •   NickD    9 年前

    将以下代码添加到您的init文件中(注意:它将一个元素添加到org preview latex进程列表的值中,因此 必须 在组织加载后添加-您可能还需要(require'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和预览似乎都能工作。

        2
  •  2
  •   Sebin Benjamin    6 年前

    我将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 而不是 convert . 转换 不工作,因为有一个名为 convert.exe

        3
  •  0
  •   VitalyR    4 年前

    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)