我在 MS Word 中有一个非常长而窄的表格,看起来像这样,我想用 LaTeX 重写它。在每一列的末尾,表格应该继续向右延伸,六列之后应该继续延伸到下一页。
尽管下面的例子中没有出现,但标题“Tix Lap n”应该出现在每列的顶部。
在Word中,这个表极不稳定。
这是我目前得到的代码(根据该问题的答案修改而来:超级表格 + 迷你页面),这样就可以将我想要的六列表格变成两列表格。我很难将它变成六列。我该怎么做呢?
\documentclass[12pt]{article}
\usepackage{supertabular}
\usepackage[a4paper,top=0.3in, bottom = 0.6in, left = 0.3in, right = 0.3in,heightrounded]{geometry}
\usepackage{microtype,textcomp}
\usepackage{array}
\usepackage{multicol}
\usepackage{makecell}
\newcommand\myrows{%
NA & NA & NA \\
NA & NA & NA \\
NA & NA & NA \\
NA & NA & NA \\
NA & NA & NA \\\hline
\multicolumn{3}{|c|}{Layer XYZ}\\ \hline
NA & NA & NA \\
NA & NA & NA \\
NA & NA & NA \\
NA & NA & NA \\
NA & NA & NA}
\newcommand\Myrow{%
\myrows\\
\myrows\\
\myrows\\
\myrows\\
\myrows\\
\myrows\\
\myrows
}
\newcounter{rowno}
\setcounter{rowno}{0}
%==================================================================
\begin{document}
%===============================================================
%This is some dummy text just for demo used here. It is in one column mode.
\twocolumn
\bgroup
\centering
\tablefirsthead{\hline Tix& Lap& n\\\hline}
%
\tablehead{
%\multicolumn{3}{c}%
%{{\bfseries Continued from previous page}} \\
\hline
Tix& Lap & n\\ \hline}
%
\tabletail{
%\hline \multicolumn{3}{|r|}{{Continued}} \\
\hline}
%
\tablelasttail{
%\multicolumn{3}{|r|}{{Concluded}}
\hline}
%
\begin{supertabular}{|ccc|}
\multicolumn{3}{|c|}{Layer G100}\\ \hline
113 & X3 & 1\\
178 & \thead[l]{W4\\+Z1}&1\\
211 & Y3 &12\\
\Myrow\\
\Myrow\\
\end{supertabular}%
\par
\egroup
\onecolumn
\end{document}
呈现为:
版本信息,稍加更新确实能带来好处:
*File List*
article.cls 2007/10/19 v1.4h Standard LaTeX document class
size12.clo 2007/10/19 v1.4h Standard LaTeX file (size option)
supertabular.sty 2004/02/20 v4.1e the supertabular environment
geometry.sty 2010/09/12 v5.6 Page Geometry
keyval.sty 2014/05/08 v1.15 key=value parser (DPC)
ifpdf.sty 2011/01/30 v2.3 Provides the ifpdf switch (HO)
ifvtex.sty 2010/03/01 v1.5 Detect VTeX and its facilities (HO)
ifxetex.sty 2010/09/12 v0.6 Provides ifxetex conditional
microtype.sty 2013/05/23 v2.5a Micro-typographical refinements (RS)
microtype-pdftex.def 2013/05/23 v2.5a Definitions specific to pdftex (RS)
microtype.cfg 2013/05/23 v2.5a microtype main configuration file (RS)
textcomp.sty 2005/09/27 v1.99g Standard LaTeX package
ts1enc.def 2001/06/05 v3.0e (jk/car/fm) Standard LaTeX file
array.sty 2008/09/09 v2.4c Tabular extension package (FMi)
multicol.sty 2014/04/23 v1.8e multicolumn formatting (FMi)
multirow.sty
makecell.sty 2009/08/03 V0.1e Managing of Tab Column Heads and Cells
ts1cmr.fd 1999/05/25 v2.5h Standard LaTeX font definitions
mt-cmr.cfg 2013/05/19 v2.2 microtype config. file: Computer Modern Roman (
RS)
***********
答案1
更新:
使用\multirow
来自multirow
包的替换\thead
,第一列现在是平衡的。
% in preamble
\usepackage{multirow}
% inside "supertabular" environment
113 & X3 & 1 \\
\multirow{2}{*}{178} & W4 & \multirow{2}{*}{1} \\
& +Z1 & \\
完整示例:
\documentclass[12pt]{article}
\usepackage{supertabular}
\usepackage[a4paper,top=0.3in, bottom = 0.6in, left = 0.3in, right = 0.3in, heightrounded]{geometry}
\usepackage{microtype,textcomp}
\usepackage{array}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{makecell}
\newcommand\myrows{%
NA & NA & NA \\
NA & NA & NA \\
NA & NA & NA \\
NA & NA & NA \\
NA & NA & NA \\ \hline
\multicolumn{3}{|c|}{Layer XYZ}\\ \hline
NA & NA & NA \\
NA & NA & NA \\
NA & NA & NA \\
NA & NA & NA \\
NA & NA & NA}
\newcommand\Myrow{%
\myrows\\
\myrows\\
\myrows\\
\myrows\\
\myrows\\
\myrows\\
\myrows
}
\begin{document}
\begin{multicols*}{6}
\let\mcnewpage=\newpage
\makeatletter
\renewcommand\newpage{%
\if@firstcolumn
\hrule width\linewidth height0pt
\columnbreak
\else
\mcnewpage
\fi
}
\makeatother
\tablefirsthead{\hline Tix & Lap & n\\ \hline}
\tablehead {\hline Tix & Lap & n\\ \hline}
\tabletail {\hline}
\tablelasttail {\hline}
\begin{supertabular}{|ccc|}
\multicolumn{3}{|c|}{Layer G100}\\ \hline
113 & X3 & 1 \\
113 & X3 & 1 \\
\multirow{2}{*}{178} & W4 & \multirow{2}{*}{1} \\
& +Z1 & \\
211 & Y3 & 12 \\
\Myrow \\
\Myrow \\
\Myrow \\
\Myrow \\
\end{supertabular}
\end{multicols*}
\end{document}
我的本地版本信息(texlive 2020 及最新包)
*File List*
article.cls 2019/12/20 v1.4l Standard LaTeX document class
size12.clo 2019/12/20 v1.4l Standard LaTeX file (size option)
supertabular.sty 2020/02/02 v4.1g the supertabular environment
geometry.sty 2020/01/02 v5.9 Page Geometry
keyval.sty 2014/10/28 v1.15 key=value parser (DPC)
ifvtex.sty 2019/10/25 v1.7 ifvtex legacy package. Use iftex instead.
iftex.sty 2020/03/06 v1.0d TeX engine tests
array.sty 2019/08/31 v2.4l Tabular extension package (FMi)
multicol.sty 2019/12/09 v1.8y multicolumn formatting (FMi)
multirow.sty 2019/05/31 v2.5 Span multiple rows of a table
makecell.sty 2009/08/03 V0.1e Managing of Tab Column Heads and Cells
l3backend-pdfmode.def 2020-05-05 L3 backend support: PDF mode
***********
原始答案:
以下示例基于此答案多列长表或枚举,注意第一列不平衡。
\documentclass[12pt]{article}
\usepackage{supertabular}
\usepackage[a4paper,top=0.3in, bottom = 0.6in, left = 0.3in, right = 0.3in, heightrounded]{geometry}
\usepackage{microtype,textcomp}
\usepackage{array}
\usepackage{multicol}
\usepackage{makecell}
\newcommand\myrows{%
NA & NA & NA \\
NA & NA & NA \\
NA & NA & NA \\
NA & NA & NA \\
NA & NA & NA \\\hline
\multicolumn{3}{|c|}{Layer XYZ}\\ \hline
NA & NA & NA \\
NA & NA & NA \\
NA & NA & NA \\
NA & NA & NA \\
NA & NA & NA}
\newcommand\Myrow{%
\myrows\\
\myrows\\
\myrows\\
\myrows\\
\myrows\\
\myrows\\
\myrows
}
\newcounter{rowno}
\setcounter{rowno}{0}
%==================================================================
\begin{document}
%===============================================================
%This is some dummy text just for demo used here. It is in one column mode.
\begin{multicols*}{6}
\let\mcnewpage=\newpage
\makeatletter
\renewcommand\newpage{%
\if@firstcolumn
\hrule width\linewidth height0pt
\columnbreak
\else
\mcnewpage
\fi
}
\makeatother
\tablefirsthead{\hline Tix& Lap& n\\\hline}
%
\tablehead{
%\multicolumn{3}{c}%
%{{\bfseries Continued from previous page}} \\
\hline
Tix& Lap & n\\ \hline}
%
\tabletail{
%\hline \multicolumn{3}{|r|}{{Continued}} \\
\hline}
%
\tablelasttail{
%\multicolumn{3}{|r|}{{Concluded}}
\hline}
\begin{supertabular}{|ccc|}
\multicolumn{3}{|c|}{Layer G100}\\ \hline
113 & X3 & 1\\
178 & \thead[l]{W4\\+Z1}&1\\
211 & Y3 &12\\
\Myrow\\
\Myrow\\
\Myrow\\
\Myrow\\
\end{supertabular}
\end{multicols*}
\end{document}