1

In the following school timetable for my 4 kids I am trying to use array and the m{} command (vertical align middle) to get the word Peter to be vertically aligned in its cell, (at the cmidrule), because this is the vertical centre. Similarly, the word Sonya should be vertically aligned within her row. The horizontal rules are provided by booktabs. My problem is that the children names are not being vertically centred.

The effect I want is like this

As a follow-up question, if I (I know it looks bad, I'm just asking hypothetically) wanted the names in the first column to have both centred vertical alignment (m{}) and centred horizontal alignment (c), what is the best method? Should I use hfill inside a m{} column?

I have read similar questions such as this one but I'm not sure they're identical because I'm not using multirow or multicol. Also, the solution here requires a manual height estimate, whereas I am looking for something automatic.

The almost-MWE is as follows:

\documentclass[10pt,oneside]{article}
\usepackage[landscape, margin=0.2in]{geometry}
\usepackage{booktabs,array}
\newlength{\cwidth}
\setlength{\cwidth}{1.4in}
\begin{document}

\section{School Timetable}

\begin{tabular}{m{\cwidth}p{\cwidth}p{\cwidth}p{\cwidth}p{\cwidth}p{\cwidth}@{}} \toprule

&\textbf{Mon}&\textbf{Tues}&\textbf{Wed}&\textbf{Thurs}&\textbf{Fri}\\ \midrule
 \textbf{Peter}&
Creative Arts\newline HSIE\newline Science &
English\newline Maths\newline Science\newline PDHPE---no sports&
Maths\newline TAS\newline Sport&
TAS\newline English\newline Science\newline Maths&
HSIE\newline Creative Arts\newline English \\ 
 \cmidrule(r){2-6}  
&English\newline HSIE\newline Science\newline PDHPE---no sports&
Science\newline Creative Arts\newline PDHPE---sports\newline English&
Maths\newline TAS\newline Sport&
PDHPE---sports\newline Maths\newline Creative Arts\newline TAS&
Science\newline English\newline Maths\newline HSIE\\ \midrule

\textbf{Sonya}&
&
&
&
Sport uniform\newline Library\newline Homework collected&
Homework issued \\ \midrule

\textbf{Michael}&
Sport Uniform&
Library&
&
Homework collected&
Homework issued\\ \midrule

\textbf{Andrew}&
Sport Uniform&
Library&
&
Homework collected&
Homework issued\\ \bottomrule
\end{tabular}
\end{document}
2

With makecell and multirow, you have the first column horizontally centred by default (but it may be changed). The makecell package allows for a common formatting and linebreaks in table cells, with the thead,\makecell, \multirowthead,``multirowcell commands:

\documentclass[10pt,oneside]{article}
\usepackage[landscape, margin=0.2in, showframe]{geometry}
\usepackage{booktabs,array, makecell, multirow}
\newlength{\cwidth}
\setlength{\cwidth}{1.4in}
\renewcommand\theadfont{\normalsize\bfseries}

\begin{document}

\section{School Timetable}

\begin{center}
  \begin{tabular}{m{\cwidth}p{\cwidth}p{\cwidth}p{\cwidth}p{\cwidth}p{\cwidth}@{}} \toprule
                    & \textbf{Mon} & \textbf{Tues} & \textbf{Wed} & \textbf{Thurs} & \textbf{Fri} \\%
    \midrule
    \multirowthead{8}[-\aboverulesep]{\textbf{Peter}}%
    & Creative Arts\newline HSIE\newline Science %
    & English\newline Maths\newline Science\newline PDHPE---no sports %
    & Maths\newline TAS\newline Sport %
    & TAS\newline English\newline Science\newline Maths%
    & HSIE\newline Creative Arts\newline English \\ %
    \cmidrule(r){2-6}
    & English\newline HSIE\newline Science\newline PDHPE---no sports%
    & Science\newline Creative Arts\newline PDHPE---sports\newline English%
    & Maths\newline TAS\newline Sport& PDHPE---sports\newline Maths\newline Creative Arts\newline TAS %
    & Science\newline English\newline Maths\newline HSIE \\%
    \midrule
    \multirowthead{3}{Sonya}&&&&%
    Sport uniform\newline Library\newline Homework collected & Homework issued \\%
    \midrule
    \thead{Michael} & Sport Uniform & Library & & Homework collected & Homework issued \\%
    \midrule
    \thead{Andrew} & Sport Uniform&
    Library&
    &
    Homework collected & Homework issued\\%
    \bottomrule
  \end{tabular}
\end{center}

\end{document} 

enter image description here

0

Using the multirow package :

\multirow{8}[4]*{\textbf{Peter}}&

the code :

\documentclass[10pt,oneside]{article}
\usepackage[landscape, margin=0.2in]{geometry}
\usepackage{booktabs,array}
\newlength{\cwidth}
\setlength{\cwidth}{1.4in}
\usepackage{multirow}
\begin{document}

\section{School Timetable}

\begin{tabular}{m{\cwidth}p{\cwidth}p{\cwidth}p{\cwidth}p{\cwidth}p{\cwidth}@{}} \toprule

&\textbf{Mon}&\textbf{Tues}&\textbf{Wed}&\textbf{Thurs}&\textbf{Fri}\\ \midrule
  \multirow{8}[4]*{\textbf{Peter}}&
Creative Arts\newline HSIE\newline Science &
English\newline Maths\newline Science\newline PDHPE---no sports&
Maths\newline TAS\newline Sport&
TAS\newline English\newline Science\newline Maths&
HSIE\newline Creative Arts\newline English \\ 
 \cmidrule(r){2-6}  
&English\newline HSIE\newline Science\newline PDHPE---no sports&
Science\newline Creative Arts\newline PDHPE---sports\newline English&
Maths\newline TAS\newline Sport&
PDHPE---sports\newline Maths\newline Creative Arts\newline TAS&
Science\newline English\newline Maths\newline HSIE\\ \midrule

  \multirow{3}*{\textbf{Sonya}}&
&
&
&
Sport uniform\newline Library\newline Homework collected&
Homework issued \\ \midrule

\textbf{Michael}&
Sport Uniform&
Library&
&
Homework collected&
Homework issued\\ \midrule

\textbf{Andrew}&
Sport Uniform&
Library&
&
Homework collected&
Homework issued\\ \bottomrule
\end{tabular}
\end{document}

enter image description here

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.