2

I've written some Latex in my doxygen comment that looks like this...

/*!
@note
@latexonly

\documentclass{article}
\usepackage{courier}

\lstset{basicstyle=\footnotesize\ttfamily}

\begin{document}
\fontsize{10pt}{12pt}\selectfont
\newpage
\begin{verbatim}    

CONTENT

\end{verbatim}
\end{document}
@endlatexonly
*/

Produces this after running 'pdflatex'

article courier
basicstyle=
(PageBreak: No text in PDF) 
CONTENT

What am I doing wrong? I just wanted to set the text to a monospace font and have it output verbatim.

Note: I'm running MikTeX 2.9 on windows 7

Update:

I Took a look in the .tex file doxygen makes for the class with this comment and found this.

 \begin{DoxyNote}{Note}

//Everything above

\end{DoxyNote}

Could that create the odd things I'm seeing?

Update 2:

I found this,

Starts a block of text that will be verbatim included in the generated LaTeX documentation only.

So that tells me MiKTeX doesn't like those labels. When doxygen creates the .Tex files this bit shows up in the middle. Does LaTeX have rules about defining a preamble in the middle of a document? This is the first thing I've ever done in LaTeX so I'm not surprised that I'm having issues.

I did some testing and when I remove \documentclass,\begin{document} and \end{document} it didn't get rid of the artifacts but it did fix some other problems I opened another question about funny enough. And then moved to here

albert
  • 1,313
Dan
  • 131
  • Can't help with Doxygen, but doesn't the command \lstset require you to load something like the listings package (i.e., \usepackage{listings})? – jon Aug 13 '13 at 21:41
  • I honestly couldn't tell you I adapted an example from here. I am using \usepackage{courier} right before that line. And from what the link mentioned that was so ttfamily could use it. – Dan Aug 13 '13 at 21:50
  • @jon oh you're right it's for setting listings to courier. Could you tell me how to set the content section to courier correctly then? – Dan Aug 13 '13 at 21:55
  • It (a normal LaTeX document) should work as long as you add the line \usepackage{listings}. The fontsize can more easily be set to 10pt by loading it as an option to your documentclass: \documentclass[10pt]{article}. ... But how that all interacts/works with Doxygen is not something I can competently answer. – jon Aug 13 '13 at 22:08
  • @jon now I'm getting article listings courier basicstyle= :p. I get the feeling this might be Doxygen but lets not count out my noob-ness either. Thanks for trying to help. – Dan Aug 13 '13 at 23:01

1 Answers1

1

EUREKA!

The labels you add in Doxygen comments are inside a \begin{document} or something like it. So preamble (I think that's what definitions like \usepackage are called) aren't valid syntax there.

So what was happening was the \COMMANDS would be absorbed, deemed invalid there and the arguments would come through as plain text.

So the answer was to this is...

/*!
@note
@latexonly
\newpage
\fontsize{10pt}{12pt}\selectfont    
\ttfamily
\begin{verbatim}

CONTENT

\end{verbatim}    
@endlatexonly
*/

Strictly speaking all \ttfamily guarantees is a monospaced font but that's all I wanted. :)

Dan
  • 131