Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a multirow used in twocolumn format. The issue is that when I used some circled characters, the column of the table widened to invade the next column.

How can I control the multirow table to fit in one column?

enter image description here

\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 \item command that's not inside a list-making
environment. The error can also be caused by a missing \documentclass
command.
\end{document}
share|improve this question
    
Your columns are too wide; left, centre and right-aligned columns expanded as needed to the contents. To limit this (and allow wrapping), use a paragraph column. You may also consider tabularx's tabularx environment with X-columns. –  Werner Aug 26 '13 at 20:06
    
note that \centering does not take an argument so \centering{ is making the rest of the docuemnt (eg the text in column2) centred not just the table. You could put {\small before the table and } after it, so it fits. –  David Carlisle Aug 26 '13 at 20:18

1 Answer 1

up vote 3 down vote accepted

If you reduce the intercolumn whitespace a bit, to 4pt, eliminate the whitespace to the left of the first column and the right of the final column, and get rid of all vertical column separators (which mostly add clutter), your table will fit inside the column:

enter image description here

\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}

You could further improve the look of the table by loading the booktabs package and use its commands \toprule, \midrule, and \bottomrule instead of the basic LaTeX command \hline. Using booktabs's line-drawing commands leads to much better vertical spacing around the horizontal lines.

enter image description here

\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}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.