pandoc --version
產量:Pandoc語法高亮在PDF不工作
pandoc 1.12.2.1
Compiled with texmath 0.6.5.2, highlighting-kate 0.5.5.1.
Syntax highlighting is supported for the following languages:
actionscript, ada, apache, asn1, asp, awk, bash, bibtex, boo, c, changelog, clojure, cmake, coffee, coldfusion, commonlisp, cpp, cs, css, curry, d, diff, djangotemplate, doxygen, doxygenlua, dtd, eiffel, email, erlang, fortran, fsharp, gnuassembler, go, haskell, haxe, html, ini, java, javadoc, javascript, json, jsp, julia, latex, lex, literatecurry, literatehaskell, lua, makefile, mandoc, markdown, matlab, maxima, metafont, mips, modelines, modula2, modula3, monobasic, nasm, noweb, objectivec, objectivecpp, ocaml, octave, pascal, perl, php, pike, postscript, prolog, python, r, relaxngcompact, rhtml, roff, ruby, rust, scala, scheme, sci, sed, sgml, sql, sqlmysql, sqlpostgresql, tcl, texinfo, verilog, vhdl, xml, xorg, xslt, xul, yacc, yaml
Default user data directory: /home/xiaolong/.pandoc
Copyright (C) 2006-2013 John MacFarlane
Web: http://johnmacfarlane.net/pandoc
This is free software; see the source for copying conditions. There is no
warranty, not even for merchantability or fitness for a particular purpose.
我嘗試以下操作:
```python
Python 3.4.3 |Anaconda 2.3.0 (64-bit)| (default, Oct 19 2015, 21:52:17)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import random # seed is determined here, if not set by the developer themself
>>> random.randint(0, 100)
50
>>> random.randint(0, 100)
62
>>> random.randint(0, 100)
53
>>> random.randint(0, 100)
17
>>> random.seed("I am a hashable object.")
>>> random.randint(0, 100)
41
>>> random.seed("I am a hashable object.")
>>> random.randint(0, 100)
41
>>> random.randint(0, 100)
88
>>> random.seed("I am a hashable object.")
>>> random.randint(0, 100)
41
>>> random.randint(0, 100)
88
````````````````````````````````````````````````````````````````````````````````
的命令編譯我的PDF我用的是:
pandoc --read=markdown --table-of-contents --toc-depth=2 --preserve-tabs --standalone --template=template.latex --latex-engine=xelatex Hausarbeit.md --highlight-style=pygments -o Hausarbeit.pdf
這是我在我的template.latex
中的代碼:
$if(highlighting-macros)$
$highlighting-macros$
$endif$
$if(verbatim-in-note)$
\usepackage{fancyvrb}
$endif$
根據Pandoc文檔Pandoc documentation,這應該導致Python語言的高亮文本。但是,該代碼塊中的所有內容只會變成等寬字體,並且不會應用任何顏色。
更重要的是,有編譯時錯誤:
pandoc: Error producing PDF from TeX source.
! LaTeX Error: Environment Shaded undefined.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
\GenericError ...
\endgroup
l.200 \begin{Shaded}
我的猜測是,有一些是在模板失蹤定義Shaded
。我甚至安裝了一些包highlighting-kate
,名爲libghc-highlighting-kate-dev
,因爲我在某處讀過,這是pandoc使用的,但無濟於事,文本保持黑屏。
如何獲得突出顯示的語法?
編輯#1
該錯誤沒有出現,當我簡單地縮進使用標準降價語法的代碼。但在這種情況下,我不會有任何語法高亮本身。
編輯#2
的標籤「PDF」,「巨蟒」和「語法突出」確實是相關的,因爲這是專門關於創建一個PDF文件,特別是關於語法高亮。也可能是因爲在創建的PDF文件中突出顯示python代碼只有問題,所以python標籤也是相關的。請在結束前仔細閱讀問題。
謝謝! R在嘗試讓Pandoc從自定義LaTeX模板生成PDF時遇到了同樣的問題。 **此解決方案適用於我** R使用'knitr'包作爲Pandoc接口 - @Yihui('knitr'包的創建者)註釋[here](http://yihui.name/knitr/)該代碼突出顯示是通過「framed」LaTeX軟件包完成的。也許這對使用Python的人可能會有所幫助。 –
這是必要的,但也顯然包'textcomp'和'xcolor'。 – Zelphir