![使用“重新定义”命令进行 Latex 编译](https://linux22.com/image/356971/%E4%BD%BF%E7%94%A8%E2%80%9C%E9%87%8D%E6%96%B0%E5%AE%9A%E4%B9%89%E2%80%9D%E5%91%BD%E4%BB%A4%E8%BF%9B%E8%A1%8C%20Latex%20%E7%BC%96%E8%AF%91.png)
有没有办法传递这些字符串:
\let\includegraphicsbak\includegraphics
\renewcommand*{\includegraphics}[2][]{\fbox{\includegraphicsbak[#1]{#2}}}
通过命令行?
我试过:
latex "\let\includegraphicsbak\includegraphics \renewcommand*{\includegraphics}[2][]{\fbox{\includegraphicsbak[#1]{#2}}} \input{myfile.tex}"
但显然,它不起作用,因为编译器抱怨“\includegraphics
未定义”(此时)。有什么办法可以解决这个问题吗?
答案1
您可以使用以下方法来延迟重新定义\AtBeginDocument{....}
:
latex "\AtBeginDocument{\let\includegraphicsbak\includegraphics \renewcommand*{\includegraphics}[2][]{\fbox{\includegraphicsbak[#1]{#2}}}} \input{myfile.tex}"