问题描述
刚刚在学校论坛看到一个帖子,大意是老师要求把已经送审的学位论文从latex改成word(???)
深感震惊和同情之余,想知道是否有比生成pdf后转word更好的方法呢?
解决思路
知乎的一条回答看起来挺靠谱的:
LaTeX(XeLaTeX)写的文档如何一键转为word? - 印第安老斑鸠的回答 - 知乎
https://www.zhihu.com/question/31850346/answer/279270892
于是打算用我的学位论文实验一下。
step 1 pandoc安装 – Win10
Pandoc主页:https://pandoc.org/
If you need to convert files from one markup format into another, pandoc is your swiss-army knife. Pandoc can convert between the following formats:
看上去是一款强大的格式转换工具。
- 下载链接:https://github.com/jgm/pandoc/releases/tag/2.18
- 安装并添加环境变量:C:\Program Files\Pandoc
- 测试是否安装成功:pandoc --help
Step 2 开始转换
尝试1
pandoc main.tex -o output.docx -w docx --pdf-engine xelatex
- 报错:
Error at "main.tex" (line 19, column 17):
unexpected ()
\begin{document}
- 解决方法:https://blog.youkuaiyun.com/yangzhang001/article/details/105884400
- 发现是一个表格中的某些符号导致的,删除错误的符号即可
- 导出成功,但没有格式、没有参考文献、没有公式标号等。
尝试2
pandoc mainword.tex -o output.docx -w docx --pdf-engine xelatex --filter pandoc-crossref --bibliography=reference.bib
- 报错:Could not find executable pandoc-crossref
- 安装pandoc-crossref: https://github.com/lierdakil/pandoc-crossref/releases/tag/v0.3.12.2a
- 无法得到正确的参考文献格式
尝试3
pandoc mainword.tex --bibliography=reference.bib --filter pandoc-crossref --citeproc -o output.docx -w docx --pdf-engine xelatex
- 格式不对,参考文献无法识别\citing{}
尝试4
pandoc mainword.tex --bibliography=reference.bib --filter pandoc-crossref --citeproc --reference-doc=template1.docx -o output.docx -w docx --pdf-engine xelatex
结果
- 结果如下
- 结论
- 基本上是目前最好的结果了,但是效果还是不行
- 但图片需要是jpg这种格式,不能是pdf格式
- 很多自定义latex命令,如\citing,无法使用
- 可读性良好,如果老师只是为了批注已经足够了
- 交叉引用 OK
- 文字、公式无乱码
- png格式图片显示良好
- 考虑到Adobe大量的文字乱码,感觉还是这个方案要好一些
- 但假如老师的目的不是方便修改,那就没办法了
- 基本上是目前最好的结果了,但是效果还是不行