Preserve Line Breaks in Pandoc Markdown -> LaTeX Conversion

后端 未结 3 1055
一向
一向 2021-01-01 16:34

I want to convert the following *.md converted into proper LaTeX *.tex.

Lorem *ipsum* something.
Does anyone know lorem by heart?

         


        
3条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-01 16:54

    I figured out another way to address this problem – which is to not change the original *.mds (under version control), but to simply read them in and to have them "pandoced" when building the PDF.

    Here's how:

    Some markdown.md in project root:

    Happy one-sentence-per-line **markdown** stuff.
    And another line – makes for clear git diffs!
    

    And some latexify.tex in project root:

    \documentclass{article}
    \begin{document}
    
    \immediate\write18{pandoc markdown.md -t latex -o tmp.tex}
    \input{tmp.tex}
    
    \end{document}
    

    Works just dandy if you have some markdown components in a latex project, e.g. github READMEs or sth.

    Requires no special package, but compilation with shell-escape enabled.

提交回复
热议问题