組織モードのコード ブロックと結果をさまざまなスタイルでエクスポートする

StackOverflow https://stackoverflow.com//questions/21005885

質問

org-mode と 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 で使用できるさまざまなカラーテーマがあります。たとえば、このオプションを組織ファイルに入れて「monokai」を使用できます。

#+LaTeX_HEADER: \usemintedstyle{monokai}

pygmentize からサポートされているスタイルのリストを取得するには、次のようにします。

ピグメンタイズ -L スタイル

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top