Frage

Ich bereite eine Präsentation im Org-Modus und Babel vor und möchte sie als Beamer-PDF exportieren.

In der Ausgabe haben der Quellcode und die Ergebnisse den gleichen Stil (wörtlich in Latex).Daher ist es schwierig, sie zu unterscheiden.

Wäre es möglich, Quellcode und Ergebnisse mit unterschiedlichen Stilen (vorzugsweise unterschiedlichen Farben) zu exportieren?

Vielen Dank!

War es hilfreich?

Lösung

Du könntest das verwenden minted LaTeX-Paket zur Syntaxhervorhebung des Quellcodes:

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

Ich habe dies in meiner Init-Datei:

(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"))

Es gibt verschiedene Farbthemen, die Sie mit minted verwenden können. Sie können beispielsweise diese Option in Ihre Organisationsdatei einfügen, um „monokai“ zu verwenden:

#+LaTeX_HEADER: \usemintedstyle{monokai}

So erhalten Sie eine Liste der unterstützten Stile von pygmentize:

pygmentize -L Stile

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top