Pregunta

Estoy preparando una presentación usando org-mode y babel y quiero exportarla a Beamer PDF.

En la salida, el código fuente y los resultados tienen el mismo estilo (textalmente en látex).Por eso es difícil distinguirlos.

¿Sería posible exportar el código fuente y los resultados con diferentes estilos (preferiblemente de diferente color)?

¡Muchas gracias!

¿Fue útil?

Solución

Podrías usar el minted Paquete LaTeX para resaltar la sintaxis del código fuente:

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

Tengo esto en mi archivo de inicio:

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

Hay diferentes temas de color que puedes usar con minted, por ejemplo, puedes poner esta opción en tu archivo de organización para usar "monokai":

#+LaTeX_HEADER: \usemintedstyle{monokai}

para obtener una lista de los estilos admitidos por pygmentize:

pigmentar -L estilos

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top