通过CLI的libreoffice writers2latex选项

问题描述

LibreOffice Writer提供了一种将文档导出为LaTeX的方法。但是,我需要使用相应的终端命令批量处理许多文件

soffice --convert-to tex my-file.odt --headless

soffice --convert-to tex:org.openoffice.da.writer2latex my-file.odt --headless

这很好,直到我尝试遵循有关如何将某些选项传递给转换器的说明(请参阅http://writer2latex.sourceforge.net/doc1.6/user-manual7.htmlenter link description here)为止。

soffice --convert-to tex:org.openoffice.da.writer2latex:inputencoding=utf8 my-file.odt --headless

上面的命令应导致包含行\usepackage[utf8]{inputenc}的tex代码,但实际上我得到了\usepackage[ascii]{inputenc}。使用Writer GUI,可以为导出设置编码和许多其他选项,并获得预期的结果。

由于writer2latex没有活跃的开发人员社区,我希望在stackoverflow上解决此问题。

解决方法

出现上述问题的原因可能是LibreOffice(v6)和w2l(v1.0.2,v1.4.0,v1.2.1,v1.6.1)之间的版本冲突。使用w2l的当前Alpha版本1.9.3至少对jar文件有效:

java -jar /some/path/writer2latex19/writer2latex.jar -latex \
        -use_color=false \
        -backend=pdftex \
        -inputencoding=utf8 \
        -multilingual=false \
        -float_figures=true \
        -ignore_hard_page_breaks=true \
        -ignore_double_spaces=true \
        -no_preamble=true \
        -formatting=ignore_most \
your.odt