【问题标题】:Pandocs: Md to pdf, support of html-style colors?Pandocs:Md 到 pdf,支持 html 样式的颜色?
【发布时间】:2018-05-01 07:20:30
【问题描述】:

我正在尝试将 .md 转换为包含两种 html 样式颜色的 pdf:

<span style="color:#3297A5">**Like this**</span> 

和数学:

$$
J(\theta) = \frac{1}{2m} [\sum_{i=1}^{m}(h_\theta(x^{(i)})-y^{(i)})^2 + \
lambda\sum_{j=1}^{n}(\theta_j^2)].
$$

使用

pandoc -s -o test.pdf test.md

输出格式和数学很好,但没有颜色。使用这个在线 md 来 pdf 工具http://www.markdowntopdf.com/ 我得到了正确的颜色,但不是 数学,这表明 html 样式颜色的 md 到 pdf 转换是可能的?

【问题讨论】:

    标签: html pdf markdown pandoc


    【解决方案1】:

    如果你想使用 CSS 来改变颜色,你必须使用 wkhtmltopdf 而不是 LaTeX,例如

    $ pandoc input.md --mathjax -t html5 -o output.pdf
    

    (或尝试--mathml 而不是--mathjax,参见pandoc manual

    或者,您可以使用 LaTeX 模板并在那里进行布局。 欲了解更多信息,请参阅http://pandoc.org/MANUAL.html#creating-a-pdf

    【讨论】:

    • 谢谢。会接受你的回答。不同的问题:我推出了一个 python 2.7 env 并运行了conda install -c trentoliphant wkhtmltopdf。包安装并列出,没问题。但是,当我运行pandoc test.md --mathml -t html5 -o test.pdf 时,我得到pandoc: wkhtmltopdf not found. wkhtmltopdf is needed for pdf output. 有什么想法吗?
    • 我对@9​​87654330@不太熟悉,不过你可以试试pandoc --pdf-engine=/path/to/wkhtmltopdf
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-14
    • 2012-08-12
    • 1970-01-01
    • 2015-10-04
    • 2015-02-23
    • 2018-09-22
    相关资源
    最近更新 更多