表格超出页面高度

表格超出页面高度

我用 doxygen 生成的 latex 输出 pdf。结果发现参数描述表总是超出纸张高度。理想情况下应该将其拆分为两页。我不知道该怎么做。请帮忙。谢谢。 在此处输入图片描述

梅威瑟:

\documentclass{book}
\usepackage[table]{xcolor}
\usepackage{longtable_doxygen}
\usepackage{tabu_doxygen}
\usepackage{ifthen}
\ifx\requestedLaTeXdate\undefined
 \usepackage{array}
\else
  \usepackage{array}[=2016-10-06]
\fi

\newenvironment{DoxyParams}[2][]{%
    \tabulinesep=1mm%
    \par%
    \ifthenelse{\equal{#1}{}}%
      {\begin{longtabu*}spread 0pt [l]{|X[-1,l]|X[-1,l]|}}% name + description
    {\ifthenelse{\equal{#1}{1}}%
      {\begin{longtabu*}spread 0pt [l]{|X[-1,l]|X[-1,l]|X[-1,l]|}}% in/out + name + desc
      {\begin{longtabu*}spread 0pt [l]{|X[-1,l]|X[-1,l]|X[-1,l]|X[-1,l]|}}% in/out + type + name + desc
    }
    \multicolumn{2}{l}{\hspace{-6pt}\bfseries\fontseries{bc}\selectfont\color{darkgray} #2}\\[1ex]%
    \hline%
    \endfirsthead%
    \multicolumn{2}{l}{\hspace{-6pt}\bfseries\fontseries{bc}\selectfont\color{darkgray} #2}\\[1ex]%
    \hline%
    \endhead%
}{%
    \end{longtabu*}%
    \vspace{6pt}%
}

\begin{document}
\begin{DoxyParams}{Parameters}
{\em f} & -\/ Kernel to launch. \\
\hline
{\em grid\+DimX} & -\/ Width of grid in blocks. \\
\hline
{\em grid\+DimY} & -\/ Height of grid in blocks. \\
\hline
{\em grid\+DimZ} & -\/ Depth of grid in blocks. \\
\hline
{\em block\+DimX} & -\/ X dimension of each thread block. \\
\hline
{\em block\+DimY} & -\/ Y dimension of each thread block. \\
\hline
{\em block\+DimZ} & -\/ Z dimension of each thread block. \\
\hline
{\em shared\+Mem\+Bytes} & -\/ Dynamic shared-\/memory size per thread block in bytes. \\
\hline
{\em h\+Stream} & -\/ Stream identifier. \\
\hline
{\em kernel\+Params} & -\/ Array of pointers to kernel parameters. \\
\hline
{\em extra} & -\/ Extra options.\\
\hline
\end{DoxyParams}
\end{document}

答案1

  • 我不熟悉doxygen,所以我对你的表格代码的理解非常有限
  • 我将借助一些用于长表的包直接编写您的简单表格longtablexltabular例如最新的tabularray(在下面的 MWE 中使用)
  • 枚举的包都会得到维护,您可以在此站点找到大量有关其使用的示例。
  • 关于doxygen我有点怀疑(它将按预期工作),因为正如我从您的 MWE 中看到的那样,它使用了有缺陷的、没有维护的tabu包,它不再与最新的 LaTeX 版本兼容。
  • 我不明白表格中\+和的含义。因此,我在 MWE 中将它们省略了。-\/
\documentclass{book}
%--------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%
\usepackage{lipsum}                             % for dummy text
%---------------------------------------------------------------%
\usepackage{xcolor}
\usepackage{tabularray}


\begin{document}
\lipsum[1-4]
    \begin{longtblr}[
caption = {My long table},
  label = {tab:...},
                    ]{hlines, vlines,
                      colspec = {Q[l] X[l]},
                      row{1}  = {font=\bfseries, c},
                      rowhead = 1, 
                     }
 f          & Kernel to launch                              \\
grid DimX   &    Width of grid in blocks.                  \\
grid DimY   &   Height of grid in blocks.                 \\
grid DimZ   &   Depth of grid in blocks.                  \\
block DimX  &   X dimension of each thread block.         \\
block DimY  &   Y dimension of each thread block.         \\
block DimZ  &   Z dimension of each thread block.         \\
shared Mem Bytes
            &   Dynamic shared memory size per thread block in bytes. \\
h Stream    &   Stream identifier.                        \\
kernel Params
            &   Array of pointers to kernel parameters.   \\
extra       &   Extra options.                            \\
    \end{longtblr}
\end{document}

通过比较你和我的 MWE,你可以观察到。

  • 建议的解决方案有效
  • 建议的解决方案中的代码更加简洁明了

在此处输入图片描述

(红线表示页面布局)

在这种情况下,第一列的文本应该是斜体,您只需将colspec声明更改为:

colspec = {Q[l, font=\itshape] X[l]},

表格如下所示:

在此处输入图片描述

相关内容