Pandoc: generate compilable .tex from markdown

狂风中的少年 提交于 2019-12-12 19:38:14

问题


I have started using Markdown to write my Latex PDFs, and so far I am impressed by the amount of boilerplate it takes away.

However, I find Markdown not as expressive as Tex, and therefore in some situations would like to write the document in Markdown, convert to tex, then add some Latex-only stuff and only then convert to PDF.

However, converting .md to .tex with Pandoc does not yield an compilable file: it only contains the body of the file, not the "document setup".

Example, the following .md file:

```haskell
data Expr = I Int
```

Converts to:

\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{data} \DataTypeTok{Expr} \FunctionTok{=} \DataTypeTok{I} \DataTypeTok{Int}
\end{Highlighting}
\end{Shaded}

Obviously this is missing some stuff like the document class, start of document and the imported packages. Is there any way to generate this complete file instead of just the body? Or if not, can anyone at least tell me what package the Shaded, Highlighting, KeywordTok, DataTypeTok and FunctionTok commands are pulled from? Then I can add these imports myself.


回答1:


Pandoc creates small snippets by default. Invoke it with the --standalone (or -s) command line flag to get a full document.



来源:https://stackoverflow.com/questions/53228543/pandoc-generate-compilable-tex-from-markdown

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!