How can I strip figures and table during a pandoc LaTeX to Word conversion?

狂风中的少年 提交于 2020-01-15 19:59:48

问题


I am trying to use pandoc to convert a thesis from latex to docx. In general, this works well with the following command:

pandoc input.tex -f latex -t docx -s -o output.docx --bibliography references.bib --csl=mystyle.csl

However, I have an additional requirement that I am unable to fulfill. I want the output to be stripped from any figures and tables that are included in the source files. Reading the pandoc documentation and related stackoverflow question has not helped me so far.

Do you have suggestions on what could do the trick?


回答1:


This is a poster use-case for pandoc filters. The following Lua filter will delete all tables and images:

function Image () return {} end
function Table () return {} end

Save it to a file, say remove-tables-images.lua, and pass the file to pandoc via the --lua-filter parameter:

pandoc input.tex -s -o output.docx \
    --bibliography references.bib --csl=mystyle.csl \
    --lua-filter remove-tables-images.lua


来源:https://stackoverflow.com/questions/57393261/how-can-i-strip-figures-and-table-during-a-pandoc-latex-to-word-conversion

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