1

I'm using Doxygen to generate PDF document. So I need also make use of LaTeX. I generated the default LaTeX style file, i.e. the doxygen.sty. I want to use the latex package listings to make the code block (wrapped by Doxygen commands @code and @endcode) look better, but when I made changes to this part, LaTeX errosr would appear and no PDF file can be output successfully. Am I wrong somewhere? What's the correct way to add new style in the doxygen.sty? Thanks in advance!

Below are default content in doxygen.sty:

% Used by @code ... @endcode
\newenvironment{DoxyCode}{%
  \par%
  \scriptsize%
  \begin{alltt}%
}{%
  \end{alltt}%
  \normalsize%
}

Below are changes I made for the DoxyCode environment:

\RequirePackage{listings}
\RequirePackage[table]{xcolor}
...
% Used by @code ... @endcode
\newenvironment{DoxyCode}{%
  \par%
  \lstset{numbers=left,numberstyle=\tiny}%
  \scriptsize%
  \begin{lstlisting}[language=C]%
}{%
  \end{lstlisting}%
  \normalsize%
}
albert
  • 8,285
  • 3
  • 19
  • 32
Xiangting
  • 11
  • 2
  • 2
    First question that arises is which version of doxygen? Which error messages do you get from pdflatex? Note that the code inside the `DoxyCode` environment is typeset and uses other specific commands like `DoxyCodeLine`, so I don't know whether the listings package can / will give good results. Also it is not a good idea to change doxygen.sty (as you will probably run into possible problems in future versions), better is to create a file for the changed / new settings and use `LATEX_EXTRA_STYLESHEET` – albert Oct 27 '20 at 09:13
  • Hi, @albert, thank you for your answer! I'm using Doxygen 1.8.5 and the error message seems nothing special to me: `! Emergency stop. <*> ./refman.tex *** (job aborted, no legal \end found)`. So if I want to add some new style attributes to the code blocks in the PDF output, what's the proper way to achieve it? Because Doxygen would by default transfer the code block with typeset specified in the first snippet I extracted above, I think it a must to remove this typeset first. – Xiangting Oct 28 '20 at 07:08
  • Well first of all doxygen 1.8.5 is a little bit old (August 23, 2013) so I would definitely advise you to update to the current (1.8.20) version of doxygen. I think that since 1.8.5 also a lot has changed in respect to the listing as generated by doxygen and also other problems have been fixed (also in respect to LaTeX, which LaTeX version are you using?). – albert Oct 28 '20 at 09:37
  • I'm using MikTeX2.9 on Windows10(64bit). Is it a little bit old too? If so, I'll upgrade them all for a try. Thank you! – Xiangting Oct 29 '20 at 02:05
  • This might also be the case I don't know when the MikTeX 2.9 you have, see in the log file e.g. on the your projects resulting latex directory (my version, which is reasonably up to date reports "This is pdfTeX, Version 3.14159265-2.6-1.40.21 (MiKTeX 20.7) (preloaded format=pdflatex 2020.9.10)") – albert Oct 29 '20 at 08:41

0 Answers0