【问题标题】:How to use doxygen to produce a pdf with custom latex stylesheet and commands?如何使用 doxygen 生成带有自定义乳胶样式表和命令的 pdf?
【发布时间】: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。仍然需要挖掘文档和实验......

标签: latex doxygen


【解决方案1】:

当我理解正确时,您想在 LaTeX 输出/生成的 pdf 中使用 LaTeX 命令\mytable。

大多数步骤都是正确的,认为问题在于\mytable 是一个 LaTeX 命令而不是一个 doxygen 命令,所以你必须在 doxygen 解析的注释中说明它。

对此有几种可能性:

  • \latexonly ... \endlatexonly 即在评论中添加:
      \latexonly
      \mytable
      \endlatexonly
    
  • 将其用作公式
    \f[ \mytable \f]
    

当然你可以把上面的sn-ps打包成一个专用的ALIASES。

总之我用过:

Doxyfile

LATEX_EXTRA_STYLESHEET = mystyle.sty

main.cpp

#include <iostream>
/** \page MainPage Main program
 * This program is meant to say hello!
 *
 * \latexonly
 * \mytable
 * \endlatexonly
 *
 * \f[ \mytable \f]
 */
int main() {std::cout << "Hello World!"; return 0;}

mystyle.sty

\NeedsTeXFormat{LaTeX2e}[1999/01/01]
\ProvidesPackage{mystyle}[2018/05/28]

\newcommand*{\mytable}{%
  \begin{tabular}{ll}
    1 & 2 \\
    3 & 4 \\
  \end{tabular}
}

【讨论】:

  • 谢谢!即使我仍然没有完整的解决方案,您的回答也确实有帮助。我更新了帖子。
猜你喜欢
  • 2015-11-25
  • 2011-03-04
  • 1970-01-01
  • 1970-01-01
  • 2011-11-05
  • 2015-01-20
  • 1970-01-01
  • 2017-02-21
  • 1970-01-01
相关资源
最近更新 更多