【发布时间】:2021-04-21 07:22:54
【问题描述】:
如何使用 doxygen 生成带有自定义 Latex 样式表和命令的 pdf?
我需要记录这段代码:
~\doxygenLaTex> more main.cpp
#include <iostream>
//! \page MainPage Main program
//! This program is meant to say hello!
int main() {std::cout << "Hello World!"; return 0;}
我需要使用我的自定义样式 mystyle.sty 获取一个 pdf 文档,其中包括自定义 LaTex 命令,例如 \mytable,我需要在文档中使用:
~\doxygenLaTex> more mystyle.sty
\NeedsTeXFormat{LaTeX2e}[1999/01/01]
\ProvidesPackage{mystyle}[2018/05/28]
\newcommand*{\mytable}{%
\begin{tabular}{ll}
1 & 2 \\
3 & 4 \\
\end{tabular}
}
\endinput
所以我寻找如何使用 doxygen :
~\doxygenLaTex> ls
Doxyfile main.cpp mainpage.dox mystyle.sty
~\doxygenLaTex> more .\mainpage.dox
//!
//! \mytable
//!
//! \page MainPage
//!
~\doxygenLaTex> grep LATEX_EXTRA_STYLE .\Doxyfile
# The LATEX_EXTRA_STYLESHEET tag can be used to specify additional user-defined
LATEX_EXTRA_STYLESHEET = mystyle.sty
~\doxygenLaTex> grep ALIASES .\Doxyfile
ALIASES = "mytable=\\mytable"
尽管阅读了文档,但它不起作用:我将命令作为文本!运行doxygen; cd latex; make pdf; AcroRd32.exe refman.pdf 给出:
我用谷歌搜索了这个,发现 Doxygen: include custom latex command 或 How to get Doxygen to recognize custom latex command 不幸的是没有帮助我。
尝试了更多的东西,但也没有用:
~\doxygenLaTex> git diff
diff --git a/Doxyfile b/Doxyfile
-ALIASES = "mytable=\\mytable"
+ALIASES = "mytable=\mytable"
~\doxygenLaTex> git diff
diff --git a/Doxyfile b/Doxyfile
-ALIASES = "mytable=\\mytable"
+ALIASES = "mytable=@mytable"
问题似乎是我得到了这种东西:
~\doxygenLaTex\latex> more .\_main_page.tex
This program is meant to say hello!
\textbackslash{}mytable
但不是
~\doxygenLaTex\latex> more .\_main_page.tex
This program is meant to say hello!
\mytable
我错过了什么?
附加问题:有没有办法不使用doxygen.sty,而真的只使用mystyle.sty来避免任何类型的冲突?
~\doxygenLaTex\latex> grep usepackage refman.tex
\usepackage{doxygen}
\usepackage{mystyle}
弗兰克
注意:Windows 10,doxygen 1.9.1
编辑
在发布前进行谷歌搜索时,我测试了\latexonly。这个
~\doxygenLaTex> git diff
diff --git a/Doxyfile b/Doxyfile
-ALIASES = "mytable=\\mytable"
+ALIASES = "\\latexonly mytable=\\mytable \\endlatexonly"
或者这个
~\doxygenLaTex> git diff
diff --git a/Doxyfile b/Doxyfile
-ALIASES = "mytable=\\mytable"
+ALIASES = "\latexonly mytable=\\mytable \endlatexonly"
没有工作。但是,事实上,事实证明是这样的
~\doxygenLaTex> git diff
diff --git a/mainpage.dox b/mainpage.dox
-//! \mytable
+//! \latexonly \mytable \endlatexonly
确实有效并产生了几乎我预期的结果:
但现在我有另一个问题:真正的\mytable 是没有表,需要在此处设置:
~\doxygenLaTex\latex> more .\_main_page.tex
This program is meant to say hello!
\mytable
但实际上在这里
~\doxygenLaTex\latex> more .\refman.tex
\begin{document}
\mytable
有没有办法在这里找到 LaTex 命令?理想情况下不使用doxygen.sty,而真正仅使用mystyle.sty以避免任何形式的冲突?
【问题讨论】:
-
您的新问题隐藏在此处,是一个完全不同的问题,应该在单独的问题中提出,但您应该查看
doxygen -w latex及其生成的文件和设置@987654349 @. -
ALIASES = "\latexonly mytable=\\mytable \endlatexonly"的问题是你可能在这里指的是ALIASES = "mytable=\latexonly mytable=\\mytable \endlatexonly" i.e.ALIASES = name=value` -
对于
ALIASES,你做对了!对于新问题,我想我应该问一个新问题,但正在犹豫!我会看看doxygen -w latex,如果我没有得到任何结果,我会问一个新问题:我的mystyle.sty同时处理页眉和页脚,所以我没有打算使用doxygen -w latex header.tex footer.tex mystyle.sty作为我没有header.tex footer.tex。仍然需要挖掘文档和实验......