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 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}
share|improve this question
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 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 at 22:51
    
Works for me. See my answer below. –  cfr May 30 at 23:09

1 Answer 1

up vote 0 down vote accepted

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.

share|improve this answer
    
Must have missed one when I did it. It works great. –  Calhistorian May 30 at 23:14

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.