Ответ 1
Вы можете использовать пакет 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
У меня это в моем файле инициализации:
(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"))
Существуют разные цветовые темы, которые вы можете использовать с чеканкой, например, вы можете поместить эту опцию в свой файл org для использования "monokai":
#+LaTeX_HEADER: \usemintedstyle{monokai}
чтобы получить список поддерживаемых стилей из pygmentize:
pygmentize -L styles