pandoc skip latex environment

痴心易碎 提交于 2019-12-23 11:56:42

问题


I'm writing mainly in LaTeX, but some co-authors prefer MS Word. To facilitate their work a bit, I would like to convert the .tex file (or the .pdf) to a .docx. The formatting does not need to be perfect, but all of the text, equations, figures etc should be perfectly readable.

I'm currently thinking to take the .tex document, replace all the essential stuff and then let Pandoc do it's magic. For this I would preferably implement my additions as a Pandoc filter. E.g., my tikz pictures would be converted to png using the tikz.py filter provided with Pandoc. The problem I'm facing with this approach is that Pandoc tries to interpret the tikz environment upon conversion from tex into it's internal language and the filters take this internal language as an input. The result is that the tikz code is lost. Is there a way to tell Pandoc to leave any tikzpicture environments alone?

Edit: See the MWE below:

MWE.tex contents:

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
    \draw (0,0) -- (2,2);
\end{tikzpicture}
\end{document}

Output of pandoc -t native MWE.tex

[Para [Str "(0,0)",Space,Str "\8211",Space,Str "(2,2);"]]

The \draw command has completely disappeared as you can see.

来源:https://stackoverflow.com/questions/42906254/pandoc-skip-latex-environment

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