تصدير كتلة التعليمات البرمجية لوضع org والنتيجة بأنماط مختلفة
سؤال
أقوم بإعداد عرض تقديمي باستخدام org-mode وbabel، وأريد تصديره إلى ملف 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"))
هناك سمات ألوان مختلفة يمكنك استخدامها مع Mint، على سبيل المثال يمكنك وضع هذا الخيار في ملف المؤسسة الخاص بك لاستخدام "monokai":
#+LaTeX_HEADER: \usemintedstyle{monokai}
للحصول على قائمة بالأنماط المدعومة من pygmentize:
pygmentize -L الأنماط
لا تنتمي إلى StackOverflow