0

I'm trying to write up a table but I'm missing the vertical rows in the last few columns. Anyone have any clues as to how to fix this?

 \setlength\tabcolsep{4pt}
 \begin{tabular}{|l|l|l|l|l|}
 \cline{2-5} 
 \multicolumn{1}{l|}{} & Autumn & Pre-requisites & Spring & Pre-requisites \\\hline 
 \multirow{4}{*}{\textbf{Year 1}} & MATH187 & Either a mark of at least 80 in \\ & & MATH151 OR (in the NSW HSC \\ & & Examination) Mathematics Band \\ & & 4; or Mathematics Ext 1. & MATH188 & MATH187 \\\cline{2-5}  
                             & MATH100 & None & MATH123 & MATH187 or MATH141 with \\ & & & & co-requisites of MATH188 \\ & & & & or MATH142 \\\cline{2-5} 
                             & CSIT110 & None & STAT101 & None \\\cline{2-5}                                         
                             & ACCY111 & None & ACCY112 & ACCY112 \\\hline \hline     
 \multirow{4}{*}{\textbf{Year 2}} & MATH201 & One of MATH110, MATH188 or \\ & & MATH283, or a mark of at least \\ & & 75 in MATH142 or MATH162, or \\ & & enrolment in course code 762A. & MATH202 & MATH201 \\\cline{2-5} 
                             & MATH203 & One of MATH101, MATH188 or \\ & & MATH283 or enrolment in course \\ & & code 762A. & MATH204 & MATH201 \\\cline{2-5} 
                             & MATH222 & One of MATH101, MATH188 or \\ & & enrolment in course code 762A & MATH212 & One of MATH101, MATH188, \\ & & & & MATH283 or enrolment in \\ & & & & course code 762A \\\cline{2-5}     
                             & STAT231 & MATH188 or enrolment in \\ & & course code 762A. & STAT232 & STAT231 \\\cline{2-5} 
\hline
\end{tabular}

The output I get for the code above is: enter image description here

  • 1
    Welcome to TeX.SE! Never present a screen shot of your code. You are just missing some &, e.g. in row 2. – user121799 Apr 3 '18 at 3:48
  • You must post the code itself rather than its screenshot – Al-Motasem Aldaoudeyeh Apr 3 '18 at 3:59
  • @Andy: Answered your "other" question – remco Apr 3 '18 at 5:29
  • 2
    Possible duplicate of Table Missing Rows! Help! – leandriis Apr 3 '18 at 5:30
  • exact duplicate, but code instead of screenshot. Not sure user could edit the question to remove the screenie. – remco Apr 3 '18 at 5:34
2

A version with package booktabs and less lines, column type X of tabularx for a p column type that adapts to the available width:

\documentclass{article}
\usepackage{geometry}
\usepackage{array}
\usepackage{booktabs}
\usepackage{tabularx}
\begin{document}
\noindent
\begin{tabularx}{\linewidth}
                {ll>{\raggedright}Xl>{\raggedright\arraybackslash}X}
  \toprule
  & Autumn & Pre-requisites & Spring & Pre-requisites \\
  \midrule
  \textbf{Year 1} & MATH187
  & Either a mark of at least 80 in
    MATH151 OR (in the NSW HSC
    Examination) Mathematics Band~4; or Mathematics Ext~1.
  & MATH188 & MATH187 \\
  \cmidrule{2-5}
  & MATH100 & None & MATH123
  & MATH187 or MATH141 with co-requisites of MATH188
  or MATH142 \\
  \cmidrule{2-5}
  & CSIT110 & None & STAT101 & None \tabularnewline
  \cmidrule{2-5}
  & ACCY111 & None & ACCY112 & ACCY112 \tabularnewline
  \midrule
  \textbf{Year 2} & MATH201
  & One of MATH110, MATH188 or MATH283, or a mark of at least
    75 in MATH142 or MATH162, or enrolment in course code 762A.
  & MATH202 & MATH201 \\
  \cmidrule{2-5}
  & MATH203
  & One of MATH101, MATH188 or MATH283 or enrolment in course
    code 762A.
  & MATH204 & MATH201 \\
  \cmidrule{2-5}
  & MATH222
  & One of MATH101, MATH188 or enrolment in course code 762A
  & MATH212 & One of MATH101, MATH188, MATH283 or enrolment in
    course code 762A \\
  \cmidrule{2-5}
  & STAT231
  & MATH188 or enrolment in course code 762A.
  & STAT232 & STAT231 \\
  \bottomrule
\end{tabularx}
\end{document}

Result

Or with even less lines by replacing \cmidrule{2-5} by `\addlinespace:

Result

1

You don't have the last two columns because you don't tell Latex you want them: You force newlines in your third column with '\', but that basically tells LaTeX "end the line here", which is what it does. If you add the missing '&', you'll get the vertical lines.

But I think it would be better to specify columns 3 and 5 as "p" columns, like

\begin{tabular}{|l|l|p{.33\textwidth}|l|p{.33\textwidth}|}

And remove your hand formatting in the table contents. Let Latex do the job of deciding where to cut the lines. That would give you for the "year 1" part (after adding the minimum to get it to compile :P)

\documentclass{article}
\begin{document}
\setlength\tabcolsep{4pt}
\begin{tabular}{|l|l|p{.33\textwidth}|l|p{.33\textwidth}|}
  \cline{2-5} 
  \multicolumn{1}{l|}{} & Autumn & Pre-requisites & Spring & Pre-requisites \\
  \hline 
  \multirow{4}{*}{\textbf{Year 1}} & MATH187 & Either a mark of at least 80 in  MATH151 OR (in the NSW HSC  Examination) Mathematics Band  4; or Mathematics Ext 1. & MATH188 & MATH187 \\\cline{2-5}  
  & MATH100 & None & MATH123 & MATH187 or MATH141 with  co-requisites of MATH188 or MATH142 \\\cline{2-5} 
  & CSIT110 & None & STAT101 & None \\\cline{2-5}                                         
  & ACCY111 & None & ACCY112 & ACCY112 \\\hline \hline     
  %same for Year 2.
  \hline
\end{tabular}

Adapt the "Year 2" part the same way.

  • Your MWE doesn't work. – CarLaTeX Jun 2 '18 at 20:27

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.