0

I'm trying to create a table that looks like :

enter image description here

but have no idea how to fiddle with the number of varying columns. e.g. "Term Plan" row has 1 column, week 17 has 2 columns, other rows have 3 columns. Would also prefer if the table is page-breakable like this tcolorbox table :

\documentclass[12pt,a4paper]{article}
\usepackage{lipsum}
\usepackage{tcolorbox}
\tcbuselibrary{breakable}
\newtcolorbox{mybox}[1]{colframe=gray,fonttitle=\bfseries,adjusted
title=\centering#1,breakable}

\begin{document}

\begin{mybox}{Stuff}
\lipsum
\end{mybox}

\end{document}

Which upon compiling shows :

enter image description here

Thanks.

2

Here is a way to do it with ltablex which brings the functionalities of longtable to tabularx. Note that such tables can break across pages, but only between rows, not inside a multiline row:

\documentclass {article}
\usepackage[showframe]{geometry}
\usepackage[table, svgnames]{xcolor}
\usepackage{enumitem}

\usepackage{ltablex, ragged2e, bigstrut, multirow, makecell}
\setlength{\bigstrutjot}{10pt}
\setlength{\extrarowheight}{3pt}

\begin{document}

{\keepXColumns\sffamily
\setlist{wide=0pt, leftmargin=*}
\begin{tabularx}{\linewidth}{|c|*{2}{>{\arraybackslash\RaggedRight}X|}}
    \hline
\rowcolor{Gainsboro!60!Lavender} \multicolumn{3}{|c|}{\bfseries TERM PLAN\bigstrut} \\
\hline
\rowcolor{Gainsboro!60!Lavender}\bfseries WEEK & \centering\bfseries LEARNING OUTCOMES & \centering\bfseries TOPICS {\&} SKILLS \bigstrut\tabularnewline
\hline
\endfirsthead
  \multirow{5}{*}{15}
  & \begin{itemize}[nosep, before=\vspace*{-\baselineskip}, after=\vspace*{-\baselineskip}]
\item find the maximum or minimum value of a quadratic function
\item use the maximum or minimum value of a function to sketch the graph or determine the range for a given domain
\end{itemize}
 & \textbf{Quadratic Functions}
\begin{enumerate}[label=4.\arabic*, noitemsep, after=\vspace*{-\dimexpr\baselineskip-3pt}]
\item Maximum/Minimum value of a qua\-dratic expression
\item Roots of a quadratic equation
\item Solving quadratic inequalities
\end{enumerate} \\
\hline
17 & \multicolumn{2}{c}{\makecell{Revision for Continuous Assessment 3\\
 Continuous Assessment 3}\bigstrut} \\
 \hline
\end{tabularx}}

\end{document} 

enter image description here

  • Suppose I'd like to center the number '15' in the first column (push it down towards the center of the row), how do I go about doing that? I've tried \begin{center} \end{center}, \centerline{} and [ ] but they don't seem to work. – Chung Ren Khoo Jul 23 '18 at 13:42
  • 1
    @ChungRenKhoo: You can use \multicolumn and \makecell for the new row, and \multirow for the vertical centring of numbers in the left column. Note the first argument of \multirow is not the number of rows, but the number of lines (more or less). Please see my updated code and screenshot. – Bernard Jul 23 '18 at 13:59
  • What does the second argument for \multirow do? The one you marked with an asterisk. – Chung Ren Khoo Jul 23 '18 at 14:15
  • 1
    @ChungRenKhoo: The second mandatory argument of \multirow sets the width of the multirow cell.* means it has the natural width of its content. In a column with fixed width (p type), you also can use= to stipulate it will have the column width. All this is explained in § 3 of the documentation. – Bernard Jul 23 '18 at 17:26
2

Tables like this can be created using multirow and multicolumn. See the multirow documentation.

This is a MWE for your table:

\documentclass[12pt,a4paper]{article}

\usepackage{multirow}
\usepackage{longtable}

\begin{document}

\begin{longtable}{cll}
\hline
\multicolumn{3}{c}{F}\\
\hline
Week & Learning Outcomes & Topics \& Skills\\
\hline
15 & Text... & Text... \\
\hline
16 & Text... & Text... \\
\hline
17 & \multicolumn{2}{c}{This is demo text}\\
\hline
18 & \multirow{2}{*}{This is demo text} & Hi\\
19 &  & Hi\\
\hline
\end{longtable}

\end{document}

This is the minimum and not actually pretty. It produces the following: Table from MWE

A bit prettier

Something prettier would look like this (using the booktabs package):

\documentclass[12pt,a4paper]{article}

\usepackage{multirow}
\usepackage{longtable}
\usepackage{booktabs}

\begin{document}

\renewcommand{\arraystretch}{1.5} 

\begin{longtable}{cll}
\toprule
\multicolumn{3}{c}{F}\\
\midrule
Week & Learning Outcomes & Topics \& Skills\\
\hline
15 & Text... & Text... \\
\hline
16 & Text... & Text... \\
\hline
17 & \multicolumn{2}{c}{This is demo text}\\
\hline
18 & \multirow{2}{*}{This is demo text} & Hi\\
19 &  & Hi\\
\bottomrule
\end{longtable}

\end{document}

Improved table

  • How do you include vertical lines to separate the columns in this case? – Chung Ren Khoo Jul 23 '18 at 13:12
  • Change \begin{longtable}{cll} to \begin{longtable}{c|l|l}. The vertical bars indicate the vertical bars that separate the columns of the table. – Tom Jul 23 '18 at 13:18
  • I ended up with something like this instead : puu.sh/B1Fe3/9e5839c8c9.png . Also I'm getting a Badbox error, Underfull \vbox (badness 1000). – Chung Ren Khoo Jul 23 '18 at 13:20

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.