问题描述
我有一个以 pdf 格式发布的 Latex 文档,但我需要以 Word .docx 格式与审阅者共享它。我有一些图像和一堆 tikz 格式的图形在一个单独的 .tex 文件中的一个数字子文件夹。我已经定义了 input@path{{figures/}}
以便我不必将路径放入每个 \input{blah.tex}
调用中。当我将文档发布为 pdf 时,这工作得很好,但是当我尝试使用 pandoc 创建 docx 时,我收到 .tex 文件的 [WARNING] Could not load include file
错误,尽管图像加载正常。
据我所知,pandoc 应该能够从子文件夹加载文件,并且 input@path 应该设置它(this post discuses how to use pandoc parameters to define the input@path)。
我确定这是我的一些基本缺乏理解,但这里有一个最低限度的非工作示例:
example.tex:
\documentclass[11pt,twoside,letterpaper]{article}
\makeatletter
\def\input@path{{figures/}}
\makeatother
\begin{document}
\begin{figure}[H]
\centering
\caption{Tikz Example}
\input{exTikz.tex}
\label{fig:exTikz}
\end{figure}
\end{document}
还有 exTikz.tex(从 https://latex-tutorial.com/tutorials/tikz/ 中提取)
\begin{tikzpicture}
\draw [red,dashed] (-2.5,2.5) rectangle (-1.5,1.5) node [black,below] {Start}; % Draws a rectangle
\draw [thick] (-2,2) % Draws a line
to [out=10,in=190] (2,2)
to [out=10,in=90] (6,0)
to [out=-90,in=30] (-2,-2);
\draw [fill] (5,0.1) rectangle (7,-0.1) node [black,right] {Obstacle}; % Draws another rectangle
\draw [red,fill] (-2,-2) circle [radius=0.2] node [black,below=4] {Point of interest}; % Draws a circle
\end{tikzpicture}
我也试过 --resource-path=figures
无济于事。
我意识到为了使用 .docx 中的图形,我需要使用 lua 过滤器将 tikz 转换为 png ala this post,但首先我需要 pandoc 才能实际访问在应用过滤器之前,\begin{tikzpicture}
段卡在各种 .tex 文件中。
解决方法
Pandoc 不支持 Req
参数。您可以打开功能请求 here。
我建议使用 TeX 将 TikZ 包编译成适当的图形,例如使用 in this Q&A 描述的方法,然后使用 \input@path
将 \renewcommand
更改为 \input
,pandoc 会理解。这也将允许使用 \includegraphics
选项。