pandoc

[原创]使用 Pandoc 实现 Markdown 文件转 PDF 文件

一世执手 提交于 2020-04-25 09:45:26
Markdown 写法简单明快,我十分喜欢,以至于我最近都想使用 Markdown 快速的进行测试说明书的写作,但是考虑到这文档是要进行交接的,一个 .md 的文件在内部传输还是有不便,于是就想到了能不能把 Markdown 转为 PDF 文件作为通用文件。 然后搜索后看到了这样的一篇文章 如何把 Markdown 文件转化为 PDF ,文中提到了很多方法,有使用 .md -->> .html -->> .pdf 的,也有 .md -->> .word -->> .pdf 的,也有 .md -->> .tex -->>.pdf 的。最终考虑到之前曾经使用 LaTex 进行过文章写作,并且 PC 中还有着 LaTex 环境,决定 使用 Pandoc 实现 Markdown 转 PDF 。 <!--more--> Pandoc 介绍 Pandoc 是一个用 haskell 编写的开源文本转换工具,小巧迅速且支持格式广泛,堪称文本转换应用的瑞士军刀。支持很多种输入输出,有关 Pandoc 可以在其 官网 进行详细了解。下载页面可以 点此进入 ,在其中选择合适的版本即可(GitHub 下载不多赘述)。 Markdown 转 PDF 全英文文档转换 在需要转换的文件路径下进行 Shift+鼠标右键 选择此处进入命令行,键入 pandoc input.md -o output.pdf

Pandoc MD to PDF , full size horizontal rule

十年热恋 提交于 2020-04-12 18:06:17
问题 I'm using pandoc (on windows with miktex) with markdown i create a horizontal rule, save that as my source.md --- (or even an hr tag instead) but when I convert to PDF the horizontal rule is a tiny little line in the middle of the page, centered. How do I get it to create one from margin to margin like it does when I convert it to HTML? Edit: I tried a CSS styled DIV tag that creates a rule but it is completely ignored during a pdf output. 回答1: The horizontal rule produces the LaTeX code

Pandoc MD to PDF , full size horizontal rule

两盒软妹~` 提交于 2020-04-12 18:05:34
问题 I'm using pandoc (on windows with miktex) with markdown i create a horizontal rule, save that as my source.md --- (or even an hr tag instead) but when I convert to PDF the horizontal rule is a tiny little line in the middle of the page, centered. How do I get it to create one from margin to margin like it does when I convert it to HTML? Edit: I tried a CSS styled DIV tag that creates a rule but it is completely ignored during a pdf output. 回答1: The horizontal rule produces the LaTeX code

Pandoc MD to PDF , full size horizontal rule

廉价感情. 提交于 2020-04-12 18:04:08
问题 I'm using pandoc (on windows with miktex) with markdown i create a horizontal rule, save that as my source.md --- (or even an hr tag instead) but when I convert to PDF the horizontal rule is a tiny little line in the middle of the page, centered. How do I get it to create one from margin to margin like it does when I convert it to HTML? Edit: I tried a CSS styled DIV tag that creates a rule but it is completely ignored during a pdf output. 回答1: The horizontal rule produces the LaTeX code

markdown、word、pdf文件之间相互转换

女生的网名这么多〃 提交于 2020-03-26 10:17:37
3 月,跳不动了?>>> 现实需求 平常会用markdown去写一些文档,这可以说是程序员的 最爱,但是在实际工作过程中与产品、需求人员以及客户交流更多还是使用word以及pdf等官方文档,直至发现了 Pandoc,它可以将文档在 Markdown、LaTeX、reStructuredText、HTML、Word docx 等多种标记格式之间相互转换,并支持输出 PDF、EPUB、HTML 幻灯片等多种格式。该程序被称为格式转换界的 “瑞士军刀”。 功能介绍 Pandoc 的作者是 John MacFarlane,他是加州大学伯克利分校的哲学系教授。Pandoc 使用 Haskell 语言编写,被作者用来生成讲义、课件和网站等。该程序开源免费,目前以 GPL 协议托管在 Github 网站上。 安装Pandoc 可以直接访问pandoc的官网 https://www.pandoc.org/installing.html ,由于我本地使用的mac系统所以直接找到对应mac版本,然后执行 brew install pandoc brew install pandoc-citeproc 使用文档转换 打开终端直接执行如下命令,如将word转为markdown文档,其他例旧即可,这里注意pandoc不能转换doc格式的需要docx格式的 pandoc project.docx -o

Pandoc fails to render valid LaTeX macro definitions from markdown (and R markdown)

浪尽此生 提交于 2020-03-23 09:36:51
问题 In R, I have character objects that contain LaTeX macro definitions. The challenge is to use these objects in R Markdown documents, so that the macro definitions are rendered correctly when the .Rmd files are converted to LaTeX (and then to PDF). It is a challenge because Pandoc (v2.9.1 and 2.9.2) fails to render some macro-generating code correctly, even when that code is valid LaTeX. Here is a minimal example. First, consider this Rmd file: --- title: "Rendering LaTeX Macros from R Objects"

Pandoc fails to render valid LaTeX macro definitions from markdown (and R markdown)

荒凉一梦 提交于 2020-03-23 09:36:34
问题 In R, I have character objects that contain LaTeX macro definitions. The challenge is to use these objects in R Markdown documents, so that the macro definitions are rendered correctly when the .Rmd files are converted to LaTeX (and then to PDF). It is a challenge because Pandoc (v2.9.1 and 2.9.2) fails to render some macro-generating code correctly, even when that code is valid LaTeX. Here is a minimal example. First, consider this Rmd file: --- title: "Rendering LaTeX Macros from R Objects"

Trying to understand how Pandoc converts from Markdown to Latex

有些话、适合烂在心里 提交于 2020-03-22 05:53:07
问题 I apologize if this is a repeat. I have a Markdown file test.md which has two latex math mode parts: First latex block (in .md file): \begin{flalign} P(1<X) &= \int_{1}^{\infty} f(x) dx \nonumber \\ &= \int_{1}^{4} 0 dx + \int_{4}^{\infty} e^{-(x-4)} dx \nonumber \\ \boldsymbol{P(1<X)} &= \boldsymbol{1} \nonumber \end{flalign} Second latex block (in .md file): \begin{flalign} Expected \; Revenue &= 2.5 \cdot non-passenger \; vehicles + 1.0 \cdot passenger \; vehicles \nonumber \\ &= \$(2.5

bookdown: customize the output filename

青春壹個敷衍的年華 提交于 2020-03-14 11:07:58
问题 This is a follow up to an earlier question I asked here: creating accompanying slides for bookdown project Bookdown allows compiling the file to various format, including multiple pdf . The issue is therefore to give the output different names. If not, the second pdf compile overwrites the first one! In the comments to my earlier question, I wrote: "I just need to understand how to change the file name - because bookdown::pdf_book and bookdown::pdf_document2 output to the same file - which

Defining custom Markdown syntax in RMarkdown / pander

▼魔方 西西 提交于 2020-02-25 06:29:46
问题 In Markdown / RMarkdown, **this** is translated to bold , _this_ is cursive etc. Is it possible to create a custom syntax? For example, that -this- (a word between two dashes) gets translated to something I define myself (via css for html and latex for pdf)? 回答1: Document parsing is done by pandoc. For this kind of customization, one would have to customize pandoc's Markdown reader (written in Haskell), and then use the self-compiled binary for knitting. One way to get close to having custom