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 practicing LaTeX by recreating tables from one of my professor's textbooks. I came across an example I can't recreate entirely. The problem is that vertical lines in between cells of the table are not complete. This is particularly perplexing to me because it seems the leftmost vertical line is unaffected by whatever is affecting the center vertical line(s).

My syntax follows:

\documentclass{article}
\begin{document}
\begin{table}
\begin{tabular}{c|c|c}
\hline
\\[1pt]
&\multicolumn{2}{c}{Time of Occurrence of Independent and}\\
&\multicolumn{2}{c}{Dependent Variables}\\
\\[1pt]
\hline
\\[1pt]
&Prior to Initiation of Study&After Initiation of Study\\
\\[1pt]
\hline
\\[1pt]
Subject Classified on Basis&Retrospective cohort study&Prospective study (follow-up\\
of Independent Variable&(historical cohort study)&study, longitudinal study,\\
&&cohort study)\\
\\[1pt]
\hline
\\[1pt]
Subject Classified on Basis&Case-control study&\\
of Dependent Variable&(case-referent study)&\\
\\[1pt]
\hline
\end{tabular}
\end{table}
\end{document}

output

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

For now, this is just an answer to your question, since there are better way of obtaining your desired output.

Whenever you terminate a row in a tabular without fully completing it, LaTeX does not insert the necessary vertical lines. This happens in your case when you use \\[1pt]. I've replaced these with & & \\[1pt]. So, even though the cells are empty, you need to note them as existing in order to keep the vertical lines.

Note that it is also not necessary to wrap a tabular inside a table. It doesn't hurt here though.

enter image description here

\documentclass{article}
\begin{document}
\begin{table}
  \begin{tabular}{c|c|c}
    \hline
    \\[1pt]
    & \multicolumn{2}{c}{Time of Occurrence of Independent and} \\
    & \multicolumn{2}{c}{Dependent Variables} \\
    & \multicolumn{1}{c}{} & \\[1pt]
    \hline
    & & \\[1pt]
    & Prior to Initiation of Study&After Initiation of Study \\
    & & \\[1pt]
    \hline
    & & \\[1pt]
    Subject Classified on Basis & Retrospective cohort study & Prospective study (follow-up \\
    of Independent Variable & (historical cohort study) & study, longitudinal study, \\
    & & cohort study) \\
    & & \\[1pt]
    \hline
    & & \\[1pt]
    Subject Classified on Basis & Case-control study & \\
    of Dependent Variable & (case-referent study) & \\
    & & \\[1pt]
    \hline
  \end{tabular}
\end{table}
\end{document}
share|improve this answer
    
So, essentially, the spacing command \[1pt] creates a new row which must have, at the very least an & for it to follow the layout {c|c|c}? Also, can you point me in the direction of the better ways to achieve what I was looking for? I'm always interested in learning new techniques. –  Daniel Apr 19 '12 at 3:22
add comment

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.