我有一张使用包的 3 列布局的 A3 纸multicol
,我在每列上都放了表格。我希望表格垂直伸展 - 这意味着行之间的空间增加 - 以便完全填满列。我想设置的一个额外条件是表格不会移动到其他列(由 定义的分隔符\columnbreak
)。下面我提供了一些示例代码。我已打开包提供参考线showframe
的选项。geometry
代码
主文本
\documentclass[12pt]{article}
\usepackage[centering, showframe, landscape, a3paper, margin = 1cm, top = 0.75cm, bottom = 0.75cm]{geometry}
\usepackage{layout}
\setlength\parindent{0pt}
\pagestyle{empty}
\usepackage{tabularx}
\usepackage{multicol}
\usepackage{calc}
\newcolumntype{N}{>{\raggedright\let\newline\\\arraybackslash}p{1.2em}}
\newenvironment{Group}
{\noindent\tabularx{\linewidth-0.5cm}{@{}NXr}}
{\endtabularx
}
\begin{document}
\begin{multicols*}{3}
\raggedcolumns
\interlinepenalty=10000
% First column
\input{mwe.tex}
\input{mwe.tex}
\columnbreak
% % Second column
\begin{Group}
1 & Lorem ipsum Lorem ipsum Lorem ipsum Lorem \dotfill € & 10.00 \\
1 & Lorem ipsum Lorem ipsum Lorem ipsum Lorem \dotfill € & 10.00 \\
1 & Lorem ipsum Lorem ipsum Lorem ipsum Lorem \dotfill € & 10.00 \\
1 & Lorem ipsum Lorem ipsum Lorem ipsum Lorem \dotfill € & 10.00 \\
1 & Lorem ipsum Lorem ipsum Lorem ipsum Lorem \dotfill € & 10.00 \\
1 & Lorem ipsum Lorem ipsum Lorem ipsum Lorem \dotfill € & 10.00 \\
1 & Lorem ipsum Lorem ipsum Lorem ipsum Lorem \dotfill € & 10.00
\end{Group}
\vspace{1cm}
\input{mwe.tex}
\vspace{0.5cm} % not sure why this can't be 1cm without everything moving, space seems to be there.
\input{mwe.tex}
\columnbreak
% % Third column
\begin{Group}
1 & Lorem ipsum Lorem ipsum Lorem ipsum Lorem \dotfill € & 10.00 \\
1 & Lorem ipsum Lorem ipsum Lorem ipsum Lorem \dotfill € & 10.00 \\
1 & Lorem ipsum Lorem ipsum Lorem ipsum Lorem \dotfill € & 10.00 \\
1 & Lorem ipsum Lorem ipsum Lorem ipsum Lorem \dotfill € & 10.00 \\
1 & Lorem ipsum Lorem ipsum Lorem ipsum Lorem \dotfill € & 10.00 \\
1 & Lorem ipsum Lorem ipsum Lorem ipsum Lorem \dotfill € & 10.00 \\
1 & Lorem ipsum Lorem ipsum Lorem ipsum Lorem \dotfill € & 10.00
\end{Group}
\columnbreak
\end{multicols*}
\end{document}
麦格
\begin{Group}
1 & Lorem ipsum Lorem ipsum Lorem ipsum Lorem \dotfill € & 10.00 \\
1 & Lorem ipsum Lorem ipsum Lorem ipsum Lorem \dotfill € & 10.00 \\
1 & Lorem ipsum Lorem ipsum Lorem ipsum Lorem \dotfill € & 10.00 \\
1 & Lorem ipsum Lorem ipsum Lorem ipsum Lorem \dotfill € & 10.00 \\
1 & Lorem ipsum Lorem ipsum Lorem ipsum Lorem \dotfill € & 10.00 \\
1 & Lorem ipsum Lorem ipsum Lorem ipsum Lorem \dotfill € & 10.00 \\
1 & Lorem ipsum Lorem ipsum Lorem ipsum Lorem \dotfill € & 10.00 \\
1 & Lorem ipsum Lorem ipsum Lorem ipsum Lorem \dotfill € & 10.00 \\
1 & Lorem ipsum Lorem ipsum Lorem ipsum Lorem \dotfill € & 10.00 \\
1 & Lorem ipsum Lorem ipsum Lorem ipsum Lorem \dotfill € & 10.00 \\
1 & Lorem ipsum Lorem ipsum Lorem ipsum Lorem \dotfill € & 10.00 \\
1 & Lorem ipsum Lorem ipsum Lorem ipsum Lorem \dotfill € & 10.00 \\
1 & Lorem ipsum Lorem ipsum Lorem ipsum Lorem \dotfill € & 10.00 \\
1 & Lorem ipsum Lorem ipsum Lorem ipsum Lorem \dotfill € & 10.00 \\
1 & Lorem ipsum Lorem ipsum Lorem ipsum Lorem \dotfill € & 10.00 \\
1 & Lorem ipsum Lorem ipsum Lorem ipsum Lorem \dotfill € & 10.00 \\
1 & Lorem ipsum Lorem ipsum Lorem ipsum Lorem \dotfill € & 10.00 \\
1 & Lorem ipsum Lorem ipsum Lorem ipsum Lorem \dotfill € & 10.00
\end{Group}
编辑
答案1
如果表格是由 TeX 原语直接创建的,则可以允许表格中行之间的可拉伸性,\halign
因为此原语会创建行并将其放入外部垂直列表中,而不会将它们封装到另一个框中。
下面的示例创建了两列,高度\heightofcolumn
和宽度分别为\widthofcolumn
。第一列包含三个表格,它们之间相隔 1cm。第二列仅包含两个表格,因此必须有更多拉伸的 baselineskip。原始级别的框概念是:
\hbox{<column> <kern> <column>}
并且每一个<column>
都是
\vbox to\heighofcolumn{<initialization> <material>}
整个例子如下:
\newdimen\heightofcolumn \heightofcolumn=7cm % for testing purpose
\newdimen\widthofcolumn \widthofcolumn=7cm
\long\def\column#1{%
\vbox to\heightofcolumn{
\hsize=\widthofcolumn
\baselineskip=\dimexpr\baselineskip plus3em minus5pt
\kern\topskip
\hbox to\widthofcolumn {}
\vskip-\baselineskip
#1\par
}%
}
\hbox{%
\column{ % first column
\halign{#\hfil&\ \hfil#\cr % qeuivalent to tabular{lr}
Lorem ipsum & Lorem ipsum \cr
Lorem ipsum & Lorem ipsum L \cr
Lorem ipsum & Lorem ipsum L \cr
Lorem ip & Lorem ipsum Lorem \cr
}
\vskip 1cm
\halign{#\hfil&\ \hfil#\cr % equivalent to tabular{lr}
Lorem ipsum & Lorem ipsum \cr
Lorem ipsum & Lorem ipsum L \cr
Lorem ip & Lorem ipsum Lorem \cr
}
\vskip 1cm
\halign{#\hfil&\ \hfil#\cr % equivalent to tabular{lr}
Lorem ipsum & Lorem ipsum \cr
Lorem ipsum & Lorem ipsum L \cr
Lorem ip & Lorem ipsum Lorem \cr
}
}%
\kern2em % space between columns
\column { % second column
\halign{#\hfil&\ \hfil#\cr % equivalent to tabular{lr}
Lorem ipsum & Lorem ipsum \cr
Lorem ipsum & Lorem ipsum L \cr
Lorem ip & Lorem ipsum Lorem \cr
}
\vskip 2cm
\halign{#\hfil&\ \hfil#\cr % equivalent to tabular{lr}
Lorem ipsum & Lorem ipsum \cr
Lorem ipsum & Lorem ipsum L \cr
Lorem ip & Lorem ipsum Lorem \cr
}
}%
}
注意
\baselineskip=\dimexpr\baselineskip plus3em minus5pt
这提供了行与行之间的可拉伸性和可收缩性。初始化中的其他命令负责正确放置列中的第一行。
编辑如果我们知道表格单元格的宽度,那么我们就不需要使用\halign
原始的或基于的宏\halign
。我们可以像这样构造行
\hbox to\hsize{<box> <text> <box>}
其中<box>
是,\hbox to<given-dimen>{...}
并且<text>
是包含可拉伸胶水的文本(\dotfill
在您的示例中)。我创建了使用给定参数创建单行的宏\r
。整个示例如下:
\newdimen\heightofcolumn \heightofcolumn=7cm
\newdimen\widthofcolumn \widthofcolumn=7cm
\def\r #1\\{\hbox to\hsize{%
\hbox to1.5em{#1\hss}\ignorespaces#2\unskip\hbox to3em{\hss#3\unskip}%
}}
\long\def\column#1{%
\vbox to\heightofcolumn{
\hsize=\widthofcolumn
\baselineskip=\dimexpr\baselineskip plus3em minus5pt
\kern\topskip
\hbox to\widthofcolumn {}
\vskip-\baselineskip
#1\par
}%
}
\hbox{%
\column{
\r 1 & Lorem ipsum Lorem \dotfill € & 10.00 \\
\r 2 & Lorem ipsum Lo \dotfill € & 20.00 \\
\r 3 & Lorem ipsum Lorem \dotfill € & 30.00 \\
\r 1 & Lorem ipsum \dotfill € & 40.00 \\
\r 1 & Lorem ipsum Lorem psum \dotfill € & 110.00 \\
\r 13 & Lorem ipsum Lo \dotfill € & 210.00 \\
\vskip 1cm
\r 1 & Lorem ipsum Lorem \dotfill € & 10.00 \\
\r 2 & Lorem ipsum Lo \dotfill € & 20.00 \\
\vskip 1cm
\r 1 & Lorem ipsum Lorem \dotfill € & 10.00 \\
\r 2 & Lorem ipsum Lo \dotfill € & 20.00 \\
\r 3 & Lorem ipsum Lorem \dotfill € & 30.00 \\
\r 4 & Lorem ipsum L \dotfill € & 40.00 \\
}%
\kern2em % space between columns
\column {
\r 1 & Lorem ipsum Lorem \dotfill € & 10.00 \\
\r 2 & Lorem ipsum Lo \dotfill € & 20.00 \\
\r 3 & Lorem ipsum Lorem \dotfill € & 30.00 \\
\vskip 2cm
\r 1 & Lorem ipsum Lorem \dotfill € & 10.00 \\
\r 2 & Lorem ipsum Lo \dotfill € & 20.00 \\
\r 3 & Lorem ipsum Lorem \dotfill € & 30.00 \\
\r 4 & Lorem ipsum L \dotfill € & 40.00 \\
}%
}