导出组织模式代码块并导致不同的样式
题
我正在使用组织和babel准备演示文稿,并希望导出到Beamer PDF。
在输出中,源代码和结果采用相同的风格(乳胶中的逐字)。因此很难区分它们。
是否有可能以不同的样式(优选不同颜色)?
非常感谢!
解决方案
您可以使用minted
Latex包进行语法突出显示源代码:
C-h v org-latex-listings
...
(setq org-latex-listings 'minted)
causes source code to be exported using the minted package as
opposed to listings. If you want to use minted, you need to add
the minted package to `org-latex-packages-alist', for example
using customize, or with
(require 'ox-latex)
(add-to-list 'org-latex-packages-alist '("" "minted"))
In addition, it is necessary to install pygments
(http://pygments.org), and to configure the variable
`org-latex-pdf-process' so that the -shell-escape option is
passed to pdflatex.
The minted choice has possible repercussions on the preview of
latex fragments (see `org-preview-latex-fragment'). If you run
into previewing problems, please consult
http://orgmode.org/worg/org-tutorials/org-latex-preview.html
.
我在我的init文件中有这个:
(require 'ox-latex)
(add-to-list 'org-latex-packages-alist '("" "minted"))
(setq org-latex-listings 'minted)
(setq org-latex-pdf-process
'("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
"pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
"pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"))
.
有不同的颜色主题,您可以使用minted使用,例如,您可以将此选项放入您的ORG文件中以使用“monokai”:
#+LaTeX_HEADER: \usemintedstyle{monokai}
.
获取来自py datalize的支持样式列表:
py datalize -l样式
不隶属于 StackOverflow