表格用 x 行填充页面

表格用 x 行填充页面

我正在写一份文档,将打印出来用于实践研讨会。我想在讲义的背面添加一些页面,其中包含填满页面边缘的带格表格。然后学员可以使用这些页面来写评论、问题等,作为他们的笔记或反馈。

我希望能够说:绘制一个有 和 2 列的表格width = \textwidthheight = \textheight第一列宽 3 厘米,另一列填充剩余空间。此外,我只想指定行高并绘制一个带规则的表格,而无需明确编码每一行。

答案1

我借用了一些代码exam.cls并对其进行了稍微的修改,以定义一个\myruledpage具有两个强制参数的命令;第一个给出规则第一列的长度,第二个控制规则之间的分隔;一个简单的例子:

\documentclass{article}
\usepackage[paperheight=10cm]{geometry}% just for the example
\makeatletter
% Code taken from exam.cls and modified
\newlength\linefillheight
\newlength\linefillthickness
\setlength\linefillheight{.25in}
\setlength\linefillthickness{0.1pt}

\newcommand\linefill[1]{\leavevmode
    \rule{#1}{\linefillthickness}\ \leaders\hrule height \linefillthickness \hfill\kern\z@}

\newcommand\fillwithlines[2]{%
  \begingroup
  \ifhmode
    \par
  \fi
  \hrule height \z@
  \nobreak
  \setbox0=\hbox to \hsize{\hskip \@totalleftmargin
          \vrule height \linefillheight depth \z@ width \z@
          \linefill{#2}}%
  % We use \cleaders (rather than \leaders) so that a given
  % vertical space will always produce the same number of lines
  % no matter where on the page it happens to start:
  \cleaders \copy0 \vskip #1 \hbox{}%
  \endgroup
}
\makeatother

\newcommand\myruledpage[2]{%
  \setlength\linefillheight{#2}
  \fillwithlines{\stretch{1}}{#1}
\newpage}

\begin{document}

\myruledpage{3cm}{1cm}
\myruledpage{5cm}{10pt}
\myruledpage{.5\textwidth}{4pt}

\end{document}

在此处输入图片描述

答案2

从您的目标陈述中,我不清楚您是否希望在表格中使用各种水平线。我假设情况并非如此,因为参与者对不同主题的评论长度可能相差很大;因此,我假设您只希望在每个表格的顶部(用于分隔标题行)和最底部使用水平线。考虑到这一点,我建议使用包tabularx以及booktabs包。后者对于绘制间距合适的水平线非常有用。

以下 MWE 说明了如何做到这一点。

\documentclass{article}      
\usepackage{tabularx,booktabs}
\begin{document}

\begin{table}
\begin{tabularx}{\textwidth}{@{} p{3cm} X} % "X" column seizes remaining space
\toprule  
Topic & Comment\\
\midrule
\phantom{x}\\[0.9\textheight]
\bottomrule
\end{tabularx}
\end{table}
\end{document}

相关内容