0

I am having an issue with a tabular table with the \hlines extends past the table edge. I have fixed the problem by using \clines instead, making it go from first to last cell (\cline{1-18}), but this seems forced. Is there a reason not to use \hline?

Note I have left one horizontal line as \hline.

MWE:

\documentclass{article}

\usepackage{multirow}
\usepackage{multicol}
\usepackage{array}

\newcounter{vonecount}
\setcounter{vonecount}{0}
\newcommand{\vone}{\stepcounter{vonecount}\thevonecount}

\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}

\begin{document}

\begin{tabular}{r|C{2mm}|C{2mm}|C{2mm}|C{2mm}|C{2mm}|C{2mm}|C{2mm}|C{2mm}|C{2mm}|C{2mm}|C{2mm}|C{2mm}|C{2mm}|C{2mm}|C{2mm}|C{2mm}|C{2mm}|C{2mm}} 
\cline{1-18}
\multicolumn{1}{|r|}{Section One}                           &   
\multicolumn{17}{>{\centering}p{4in}|}{Part One - Synonyms} \\ 
\cline{1-18}
Question \#     &   
\vone & 
\vone & 
\vone & 
\vone & 
\vone & 
\vone & 
\vone & 
\vone & 
\vone & 
\vone & 
\vone & 
\vone & 
\vone & 
\vone & 
\vone & 
\vone & 
\vone \\
\cline{2-18}
Correct Answer  & 
A & 
A & 
A & 
A & 
A & 
A & 
A & 
A & 
A & 
A & 
A & 
A & 
A & 
A & 
A & 
A & 
A \\
Your Answer     & & & & & & & & & & & & & & & & & &  \\
\cline{1-18}
\multicolumn{1}{|r|}{Section One}                                       &   
\multicolumn{17}{>{\centering}p{4in}|}{Part Two - Sentence Completions} \\ 
\cline{1-18}
Question \#     &   
\vone & 
\vone & 
\vone & 
\vone & 
\vone & 
\vone & 
\vone & 
\vone & 
\vone & 
\vone & 
\vone & 
\vone & 
\vone & 
\vone & 
\vone & 
\vone & 
\vone \\
\cline{2-18}
Correct Answer  &   
A & 
A & 
A & 
A & 
A & 
A & 
A & 
A & 
A & 
A & 
A & 
A & 
A & 
A & 
A & 
A & 
A \\
Your Answer     & & & & & & & & & & & & & & & & & &  \\
\hline
\multirow{2}{*}{Scores}                 &   
\multicolumn{4}{c|}{Correct}            &   
\multicolumn{4}{c|}{Total}              &   
\multicolumn{4}{c|}{Stanine}            &   
\multicolumn{5}{c|}{Percentile Rank}    \\
\cline{2-18}
                        &   
\multicolumn{4}{c|}{}   &   
\multicolumn{4}{c|}{}   &   
\multicolumn{4}{c|}{}   &   
\multicolumn{5}{c|}{}   \\
\cline{2-18}
\end{tabular}

\end{document}
  • 1
    You have defined 19 columns. \hline goes the full width. \cline is only going as far as you tell it. So the former will go roughly 2cm beyond the latter. – cfr May 30 '14 at 22:34
  • However, if I remove a column I have defined. The table doesn't compile whether I remove the extra & or not. – Calhistorian May 30 '14 at 22:51
  • Works for me. See my answer below. – cfr May 30 '14 at 23:09
2

It works fine for me provided I remove the extra & after deleting the 19th column:

Tabular with 18 columns

\documentclass{article}

\usepackage{multirow}
\usepackage{multicol}
\usepackage{array}

\newcounter{vonecount}
\setcounter{vonecount}{0}
\newcommand{\vone}{\stepcounter{vonecount}\thevonecount}

\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}

\begin{document}

\begin{tabular}{r|*{17}{C{2mm}|}}
\hline
\multicolumn{1}{|r|}{Section One}                           &
\multicolumn{17}{>{\centering}p{4in}|}{Part One - Synonyms} \\
\hline
Question \#     &
\vone &
\vone &
\vone &
\vone &
\vone &
\vone &
\vone &
\vone &
\vone &
\vone &
\vone &
\vone &
\vone &
\vone &
\vone &
\vone &
\vone \\
\hline
Correct Answer  &
A &
A &
A &
A &
A &
A &
A &
A &
A &
A &
A &
A &
A &
A &
A &
A &
A \\
Your Answer     & & & & & & & & & & & & & & & & &   \\
\hline
\multicolumn{1}{|r|}{Section One}                                       &
\multicolumn{17}{>{\centering}p{4in}|}{Part Two - Sentence Completions} \\
\hline
Question \#     &
\vone &
\vone &
\vone &
\vone &
\vone &
\vone &
\vone &
\vone &
\vone &
\vone &
\vone &
\vone &
\vone &
\vone &
\vone &
\vone &
\vone \\
\hline
Correct Answer  &
A &
A &
A &
A &
A &
A &
A &
A &
A &
A &
A &
A &
A &
A &
A &
A &
A \\
Your Answer     & & & & & & & & & & & & & & & & &   \\
\hline
\multirow{2}{*}{Scores}                 &
\multicolumn{4}{c|}{Correct}            &
\multicolumn{4}{c|}{Total}              &
\multicolumn{4}{c|}{Stanine}            &
\multicolumn{5}{c|}{Percentile Rank}    \\
\cline{2-18}
                        &
\multicolumn{4}{c|}{}   &
\multicolumn{4}{c|}{}   &
\multicolumn{4}{c|}{}   &
\multicolumn{5}{c|}{}   \\
\hline
\end{tabular}

\end{document}

I'm not sure if that is quite what it is meant to look like but it solves the problem identified in the question. You might want to read the booktabs documentation, though.

  • Must have missed one when I did it. It works great. – Calhistorian May 30 '14 at 23:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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