Skip to content

Commit da98c4f

Browse files
authored
Merge pull request doxygen#11858 from albert-github/feature/issue_11838
issue doxygen#11838 It is not possible to add long tables in pdf documentation
2 parents cf3d453 + 5efb2dd commit da98c4f

File tree

1 file changed

+47
-10
lines changed

1 file changed

+47
-10
lines changed

templates/latex/doxygen.sty

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,19 @@
4545
}
4646
}
4747
\ExplSyntaxOff
48+
49+
\ExplSyntaxOn
50+
\dim_new:N \doxytablewidth
51+
\NewDocumentCommand \doxycalculatetablewidth {}
52+
{
53+
\cs_set_protected:Nn \__tblr_build_whole:
54+
{
55+
\__tblr_get_table_width:
56+
\dim_gset:Nn \doxytablewidth { \tablewidth }
57+
}
58+
}
59+
\ExplSyntaxOff
60+
4861
\RequirePackage{fancyvrb}
4962
\RequirePackage{tabularx}
5063
\RequirePackage{multicol}
@@ -414,12 +427,15 @@
414427
\SetTblrOuter[longtblr]{theme=DoxyTableCaptionTheme,caption={#2},label={#3}}% set table caption and label
415428
\fi%
416429
\fi%
417-
\sbox0{% first render the table in a savebox to calculate the width of the table which will be stored in \wd0
430+
\begingroup
431+
\doxycalculatetablewidth
432+
\sbox0{% first render the table in a savebox to calculate the width of the table which will be stored in \doxytablewidth
418433
\begin{tblr}{hlines,vlines,measure=vbox,colspec={*{#1}{l}}}%
419434
#5
420435
\end{tblr}%
421436
}% end of sbox0
422-
\ifdim\wd0>\linewidth% use flexible columns
437+
\endgroup
438+
\ifdim\doxytablewidth>\linewidth% use flexible columns
423439
% now render the table for real
424440
\begin{longtblr}{hlines,vlines,% automatically set horizontal and vertical cell lines
425441
measure=vbox,% needed to allow nested lists and tables
@@ -443,15 +459,33 @@
443459
% parameters:
444460
% - #1: number of columns
445461
% - #2: 1=table has a heading row, 0=no heading row
446-
\NewDocumentEnvironment{DoxyTableNested}{m m}{%
462+
\NewDocumentEnvironment{DoxyTableNested}{m m +b}{%
463+
\begingroup
464+
\doxycalculatetablewidth
465+
\sbox0{% first render the table in a savebox to calculate the width of the table which will be stored in \doxytablewidth
466+
\begin{tblr}{hlines,vlines,measure=vbox,colspec={*{#1}{l}}}%
467+
#3
468+
\end{tblr}%
469+
}% end of sbox0
470+
\endgroup
471+
\ifdim\doxytablewidth>\linewidth% use flexible columns
447472
% now render the table for real
448473
\begin{tblr}{hlines,vlines,% automatically set horizontal and vertical cell lines
449-
measure=vbox,% needed to allow nested lists and tables
450-
colspec={*{#1}{X[-1]}},% set column type for all columns
451-
rowhead=#2% set which row is the header (0=disable, 1=enable)
452-
}
474+
measure=vbox,% needed to allow nested lists and tables
475+
colspec={*{#1}{X[-1]}},% set column type for all columns
476+
rowhead=#2} % set which row is the header (0=disable, 1=enable)
477+
#3
478+
\end{tblr}%
479+
\else% use fixed left aligned columns
480+
% now render the table for real
481+
\begin{tblr}{hlines,vlines,% automatically set horizontal and vertical cell lines
482+
measure=vbox,% needed to allow nested lists and tables
483+
colspec={*{#1}{l}},% set column type for all columns
484+
rowhead=#2} % set which row is the header (0=disable, 1=enable)
485+
#3
486+
\end{tblr}%
487+
\fi%
453488
}{% no end marker needed anymore
454-
\end{tblr}
455489
}%
456490

457491
% Defines a parameter table
@@ -462,14 +496,17 @@
462496
% #4: Body
463497
\NewDocumentCommand{\DoxyParamTable}{m m +m +m}{%
464498
\SetTblrOuter[longtblr]{theme=DoxyTableBareTheme,entry=none}% set table caption and label
465-
\sbox0{% render table off-screen first to capture its width in \wd0
499+
\begingroup
500+
\doxycalculatetablewidth
501+
\sbox0{% render table off-screen first to capture its width in \doxytablewidth
466502
\begin{tblr}{measure=vbox,colspec={*{#1}{|l}|}}%
467503
\SetCell[c=#1]{l} \tf{#3} \\[1ex]%
468504
\hline%
469505
#4
470506
\end{tblr}%
471507
}%
472-
\ifdim\wd0>\linewidth%
508+
\endgroup
509+
\ifdim\doxytablewidth>\linewidth% use flexible columns
473510
\edef\DoxyTableColSpec{#2X[-1]}%
474511
\else%
475512
\edef\DoxyTableColSpec{#2l}%

0 commit comments

Comments
 (0)