2
votes

How can I set the column width in comments for doxygen?

For the following table I would like to have the first column as small as possible in my LaTeX (PDF) output.

/*!
@brief
blablabla

Name | Description
---- | -----------
AB   | asdf asdf asdf asdf asdf 
*/
2

2 Answers

1
votes

Latex has two ways to make tables (at least as far as I know):

  • with minimal width, but no text wrapping or protection that prevents the table from becoming too wide. You simple get an overfull warning and the table will run off of the page.
  • with a fixed column width; then the text will nicely wrap but one has to select an appropiate width for each column in advance.

Since doxygen cannot guess the table's width, it uses a fixed column width, and currently that is based on \textwidth divided by the number of columns.

I'm thinking about a putting that width in a TeX length variable, so you can overrule it with a special doxygen command, but this has not been implemented yet.

0
votes

I'm using Doxygen 1.8.9.1, and AFAIK today still no Doxygen option exists to turn off the fixed-width in columns. However, you can edit the doxygen.sty file manually.

I was able to achieve what you want by searching for \begin{xtabular} and changing the column markup (i.e. what is between two vertical bars |) for all columns except the last. The p{x.xx\textwidth} command (don't know if I'm using the correct LaTeX terminology) defines the width of each column. By trying, it seems better to also replace the command before that (>{\centering} and >{\raggedleft\hspace{0pt}}).

For example,

   \begin{xtabular}{|>{\centering}p{0.10\textwidth}|%
                     >{\raggedleft\hspace{0pt}}p{0.15\textwidth}|%
                     p{0.678\textwidth}|}}%

would then become:

   \begin{xtabular}{|c|%
                     r|%
                     p{0.678\textwidth}|}}%

Ditching the empty comments and putting everything on one line gives:

   \begin{xtabular}{|c|r|p{0.678\textwidth}|}}

The two-step process then becomes a three-step process: to create a pdf, you

  • run Doxygen,
  • adapt the generated doxygen.sty in the latex subfolder or replace it with your edited version,
  • run Make.bat.

Notes:

  • This of course als means that all your tables end up having a different width.
  • You talk about shrinking the widths of columns, but depending on your naming conventions you possibly end up enlarging your column width (thereby resolving a very ugly looking overflow layout problem). Make sure the last column doesn't fall of the right edge of your paper by making the width of the last column also fluid, or by setting it to a fixed value which is low enough for even the longest names.