我有一个以双列格式使用的多行表格。问题是,当我使用一些带圆圈的字符时,表格的列会变宽并侵占下一列。
我如何控制多行表以适合一列?
\documentclass[twocolumn]{article}
\usepackage{multirow}
\usepackage{tikz}
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
\node[shape=circle,draw,inner sep=1pt] (char) {#1};}}
\newcommand{\round}[1]{%
\tikz[baseline=(char.base)]\node[anchor=south west, draw,rectangle, rounded corners, inner sep=1pt, minimum size=5mm,
text height=2mm](char){\ensuremath{#1}} ;}
\begin{document}
\centering{
\begin{tabular}{|c|c|c|c|}
\hline
\multicolumn{2}{|c|}{Team sheet} & Node 3 & Node 7 \\ \hline
\multirow{3}{*}{Time 1}
& Nodes & 12\circled{3}45678 & 123456\circled{7}8\\ & In & \circled{2}\circled{4}\circled{6} & \circled{6}\circled{8} \\
& Out & \circled{3} & \circled{7} \\
\hline
\multirow{3}{*}{Time 2}
& Nodes & 1\circled{2}\circled{3}\circled{4}5\circled{6}78 & 12345\circled{6}\circled{7}\circled{8}\\
& In & \round{1,2,3}\round{3,4,5}\round{3,6,7}& \round{3,6,7}\\
& Out & \round{2,3,4,6} & \round{6,7,8} \\
\hline
\multirow{3}{*}{Time 3}
& Nodes & \circled{1}\circled{2}\circled{3}\circled{4}\circled{5}\circled{6}\circled {7}8 & 12345\circled{6}\circled{7}\circled{8}\\
& In & \round{2,3,4,5,6}\round{2,3,4,6}& \round{3,6,7}\\
& Out & \round{1,2,3,4,5,6} & \round{6,7,8} \\
\hline
\end{tabular}
}
\newpage
TeX encountered an unknown command name. You probably misspelled the
name. If this message occurs when a LaTeX command is being processed,
the command is probably in the wrong place---for example, the error
can be produced by an \verb+\item+ command that's not inside a list-making
environment. The error can also be caused by a missing \verb+\documentclass+
command.
\end{document}
答案1
如果您稍微减少列间空白,即4pt
消除第一列左侧和最后一列右侧的空白,并去掉所有垂直列分隔符(这通常会增加混乱),则表格将适合列内:
\documentclass[twocolumn]{article}
\usepackage{multirow,lipsum,tikz}
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
\node[shape=circle,draw,inner sep=1pt] (char) {#1};}}
\newcommand{\round}[1]{%
\tikz[baseline=(char.base)]%
\node[anchor=south west, draw,rectangle,
rounded corners, inner sep=1pt, minimum size=5mm,
text height=2mm](char){\ensuremath{#1}} ;}
\begin{document}
\begin{center}
\setlength\tabcolsep{4pt} % reduce intercolumn whitespace
\begin{tabular}{@{} lccc @{}}
\hline
\multicolumn{2}{c}{Team sheet} & Node 3 & Node 7 \\
\hline
\multirow{3}{*}{Time 1}
& Nodes & 12\circled{3}45678 & 123456\circled{7}8\\
& In & \circled{2}\circled{4}\circled{6} & \circled{6}\circled{8} \\
& Out & \circled{3} & \circled{7} \\
\hline
\multirow{3}{*}{Time 2}
& Nodes & 1\circled{2}\circled{3}\circled{4}5\circled{6}78 & 12345\circled{6}\circled{7}\circled{8}\\
& In & \round{1,2,3}\round{3,4,5}\round{3,6,7}& \round{3,6,7}\\
& Out & \round{2,3,4,6} & \round{6,7,8} \\
\hline
\multirow{3}{*}{Time 3}
& Nodes & \circled{1}\circled{2}\circled{3}\circled{4}\circled{5}\circled{6}\circled {7}8 & 12345\circled{6}\circled{7}\circled{8}\\
& In & \round{2,3,4,5,6}\round{2,3,4,6}& \round{3,6,7}\\
& Out & \round{1,2,3,4,5,6} & \round{6,7,8} \\
\hline
\end{tabular}
\end{center}
\lipsum[2] % filler text
\newpage
\lipsum[1] % more filler text
\end{document}
booktabs
您可以通过加载包并使用其命令\toprule
、\midrule
和来进一步改善表格的外观,\bottomrule
而不是基本的 LaTeX 命令\hline
。使用 的booktabs
线条绘制命令可以使水平线周围的垂直间距更好。
\documentclass[twocolumn]{article}
\usepackage{multirow,lipsum,tikz,booktabs}
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
\node[shape=circle,draw,inner sep=1pt] (char) {#1};}}
\newcommand{\round}[1]{%
\tikz[baseline=(char.base)]%
\node[anchor=south west, draw,rectangle,
rounded corners, inner sep=1pt, minimum size=5mm,
text height=2mm](char){\ensuremath{#1}} ;}
\begin{document}
\begin{center}
\setlength\tabcolsep{4pt} % reduce intercolumn whitespace
\begin{tabular}{@{} lccc @{}}
\toprule
\multicolumn{2}{c}{Team sheet} & Node 3 & Node 7 \\
\midrule
\multirow{3}{*}{Time 1}
& Nodes & 12\circled{3}45678 & 123456\circled{7}8\\
& In & \circled{2}\circled{4}\circled{6} & \circled{6}\circled{8} \\
& Out & \circled{3} & \circled{7} \\
\midrule
\multirow{3}{*}{Time 2}
& Nodes & 1\circled{2}\circled{3}\circled{4}5\circled{6}78 & 12345\circled{6}\circled{7}\circled{8}\\
& In & \round{1,2,3}\round{3,4,5}\round{3,6,7}& \round{3,6,7}\\
& Out & \round{2,3,4,6} & \round{6,7,8} \\
\midrule
\multirow{3}{*}{Time 3}
& Nodes & \circled{1}\circled{2}\circled{3}\circled{4}\circled{5}\circled{6}\circled {7}8 & 12345\circled{6}\circled{7}\circled{8}\\
& In & \round{2,3,4,5,6}\round{2,3,4,6}& \round{3,6,7}\\
& Out & \round{1,2,3,4,5,6} & \round{6,7,8} \\
\bottomrule
\end{tabular}
\end{center}
\lipsum[2] % filler text
\newpage
\lipsum[1] % more filler text
\end{document}