3

I am trying to show the table in a nice way. I tried my best but I could fix the header. Can you help me:

  1. Fix the header as shown in the pic.
  2. Enlarge the text "2016" to fill the space
  3. Align the text vertically in the cells.

At the end of the day, I want to show the data in a nice way. Any suggestion will be appreciated. It is not important to have the borders. You can help me show the table in a nice and just ignore my request above.

enter image description here

My code is here:

\documentclass[11pt]{report}
\usepackage{graphicx}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=3cm,headsep=1.6cm,landscape]{geometry}
\usepackage{fancyhdr}
\usepackage{multirow}
\usepackage{array}
\usepackage{epstopdf}

\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
\newcolumntype{N}{@{}m{0pt}@{}}

\begin{document}
\def\hgt{4pt}
\begin{tabular}{M{1cm}|M{1cm}|M{1cm}|M{1.8cm}|M{1.8cm}|M{1.99cm}|M{1.8cm}|}

& & & Title 1 & Title 2  & Title 3 & Title 4\\ 

\hline

\multicolumn{1}{|c|}{\multirow{12}{*}{\rotatebox[origin=c]{90}{\huge{2016}}}}&      & Jan & 0 & 0 & 3 & 10\\ [\hgt] \cline{3-7}
\multicolumn{1}{|c|}{}  &   1\textsuperscript{st} Q.    & Feb & 0 & 0 & 0 & 10\\ [\hgt] \cline{3-7}
\multicolumn{1}{|c|}{}  &                               & Mar & 0 & 0 & 0 & 10\\ [\hgt] \cline{2-7} 
\multicolumn{1}{|c|}{}  &                               & Apr & 0 & 0 & 1 & 10\\ [\hgt] \cline{3-7}
\multicolumn{1}{|c|}{}  &   2\textsuperscript{nd} Q.    & May & 0 & 0 & 0 & 10\\ [\hgt] \cline{3-7}
\multicolumn{1}{|c|}{}  &                               & Jun & 1 & 1 & 0 & 8\\ [\hgt]  \cline{2-7}
\multicolumn{1}{|c|}{}  &                               & Jul & 1 & 1 & 0 & 7\\ [\hgt] \cline{3-7}
\multicolumn{1}{|c|}{}  & 3\textsuperscript{rd} Q.      & Aug & 2 & 2 & 0 & 5\\ [\hgt] \cline{3-7}
\multicolumn{1}{|c|}{}  &                               & Sep & 1 & 1 & 0 & 4\\ [\hgt] \cline{2-7}
\multicolumn{1}{|c|}{}  &                               & Oct & 2 & 2 & 2 & 2\\ [\hgt] \cline{3-7}
\multicolumn{1}{|c|}{}  & 4\textsuperscript{th} Q.      & Nov & 1 & 1 & 4 & 0\\ [\hgt] \cline{3-7}
\multicolumn{1}{|c|}{}  &                               & Dec & 1 & 1 & 5 & 0\\ [\hgt] \hline
\end{tabular}
\end{document}
  • I'd simply add 2016 as a common header for the first two columns. – egreg Jan 14 '16 at 11:46
3

Here :

\documentclass[11pt]{report}
\usepackage{graphicx}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=3cm,headsep=1.6cm,landscape]{geometry}
\usepackage{fancyhdr}
\usepackage{multirow}
\usepackage{array}
\usepackage{epstopdf}
\usepackage{adjustbox}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
\newcolumntype{N}{@{}m{0pt}@{}}

\begin{document}
\def\hgt{4pt}
\begin{tabular}{M{1cm}|M{1cm}|M{1cm}|M{1.8cm}|M{1.8cm}|M{1.99cm}|M{1.8cm}|}

\cline{4-7}
\multicolumn{3}{c|}{} & Title 1 & Title 2  & Title 3 & Title 4\\ 

\hline

\multicolumn{1}{|c|}{\multirow{12}{*}{\rotatebox[origin=c]{90}{\adjustbox{scale={4}{1}}{\huge{2016}}}}
  }
                      &      & Jan & 0 & 0 & 3 & 10\\ [\hgt] \cline{3-7}
\multicolumn{1}{|c|}{}  &   1\textsuperscript{st} Q.    & Feb & 0 & 0 & 0 & 10\\ [\hgt] \cline{3-7}
\multicolumn{1}{|c|}{}  &                               & Mar & 0 & 0 & 0 & 10\\ [\hgt] \cline{2-7} 
\multicolumn{1}{|c|}{}  &                               & Apr & 0 & 0 & 1 & 10\\ [\hgt] \cline{3-7}
\multicolumn{1}{|c|}{}  &   2\textsuperscript{nd} Q.    & May & 0 & 0 & 0 & 10\\ [\hgt] \cline{3-7}
\multicolumn{1}{|c|}{}  &                               & Jun & 1 & 1 & 0 & 8\\ [\hgt]  \cline{2-7}
\multicolumn{1}{|c|}{}  &                               & Jul & 1 & 1 & 0 & 7\\ [\hgt] \cline{3-7}
\multicolumn{1}{|c|}{}  & 3\textsuperscript{rd} Q.      & Aug & 2 & 2 & 0 & 5\\ [\hgt] \cline{3-7}
\multicolumn{1}{|c|}{}  &                               & Sep & 1 & 1 & 0 & 4\\ [\hgt] \cline{2-7}
\multicolumn{1}{|c|}{}  &                               & Oct & 2 & 2 & 2 & 2\\ [\hgt] \cline{3-7}
\multicolumn{1}{|c|}{}  & 4\textsuperscript{th} Q.      & Nov & 1 & 1 & 4 & 0\\ [\hgt] \cline{3-7}
\multicolumn{1}{|c|}{}  &                               & Dec & 1 & 1 & 5 & 0\\ [\hgt] \hline
\end{tabular}
\end{document}

enter image description here

3

I know it's not an answer to your questions, but here's how I'd typeset the table; I offer three alternatives: probably I'd choose the first way, without fixing the column width, so a mixture of 1 and 3, but the final decision depends on the actual table material.

\documentclass{article}
\usepackage[margin=1cm]{geometry}
\usepackage{booktabs,array}

\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
\newcolumntype{N}{@{}m{0pt}@{}}

\begin{document}

\begin{tabular}{c M{1cm}M{1.8cm}M{1.8cm}M{1.99cm}M{1.8cm}}
\toprule

\multicolumn{2}{c}{2016} & Title 1 & Title 2  & Title 3 & Title 4\\ 
\cmidrule(r){1-2} \cmidrule(l){3-6}

1st Q. & Jan & 0 & 0 & 3 & 10 \\
       & Feb & 0 & 0 & 0 & 10 \\
       & Mar & 0 & 0 & 0 & 10 \\
\midrule
2nd Q. & Apr & 0 & 0 & 1 & 10 \\
       & May & 0 & 0 & 0 & 10 \\
       & Jun & 1 & 1 & 0 &  8 \\
\midrule
3rd Q. & Jul & 1 & 1 & 0 &  7 \\
       & Aug & 2 & 2 & 0 &  5 \\
       & Sep & 1 & 1 & 0 &  4 \\
\midrule
4th Q. & Oct & 2 & 2 & 2 &  2 \\
       & Nov & 1 & 1 & 4 &  0 \\
       & Dec & 1 & 1 & 5 &  0 \\
\bottomrule
\end{tabular}

\bigskip

\begin{tabular}{ l c M{1cm}M{1.8cm}M{1.8cm}M{1.99cm}M{1.8cm}}
\toprule

& & & Title 1 & Title 2  & Title 3 & Title 4\\ 
\midrule
2016
& 1st Q. & Jan & 0 & 0 & 3 & 10 \\
&        & Feb & 0 & 0 & 0 & 10 \\
&        & Mar & 0 & 0 & 0 & 10 \\
\cmidrule{2-7}
& 2nd Q. & Apr & 0 & 0 & 1 & 10 \\
&        & May & 0 & 0 & 0 & 10 \\
&        & Jun & 1 & 1 & 0 &  8 \\
\cmidrule{2-7}
& 3rd Q. & Jul & 1 & 1 & 0 &  7 \\
&        & Aug & 2 & 2 & 0 &  5 \\
&        & Sep & 1 & 1 & 0 &  4 \\
\cmidrule{2-7}
& 4th Q. & Oct & 2 & 2 & 2 &  2 \\
&        & Nov & 1 & 1 & 4 &  0 \\
&        & Dec & 1 & 1 & 5 &  0 \\
\bottomrule
\end{tabular}

\bigskip

\begin{tabular}{ l c c c c c c }
\toprule

& & & Title 1 & Title 2  & Title 3 & Title 4\\ 
\midrule
2016
& 1st Q. & Jan & 0 & 0 & 3 & 10 \\
&        & Feb & 0 & 0 & 0 & 10 \\
&        & Mar & 0 & 0 & 0 & 10 \\
\cmidrule{2-7}
& 2nd Q. & Apr & 0 & 0 & 1 & 10 \\
&        & May & 0 & 0 & 0 & 10 \\
&        & Jun & 1 & 1 & 0 &  8 \\
\cmidrule{2-7}
& 3rd Q. & Jul & 1 & 1 & 0 &  7 \\
&        & Aug & 2 & 2 & 0 &  5 \\
&        & Sep & 1 & 1 & 0 &  4 \\
\cmidrule{2-7}
& 4th Q. & Oct & 2 & 2 & 2 &  2 \\
&        & Nov & 1 & 1 & 4 &  0 \\
&        & Dec & 1 & 1 & 5 &  0 \\
\bottomrule
\end{tabular}


\end{document}

enter image description here

1

Something like this:

enter image description here

After deleting surplus macros and adding \cline on the top of table, your MWE become:

\documentclass[11pt]{report}
\usepackage{graphicx}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=3cm,headsep=1.6cm,landscape]{geometry}
\usepackage{fancyhdr}
\usepackage{array,multirow}
\usepackage{soul}% <-- added for more spacing between numbers in 2016
\usepackage{epstopdf}

\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}

\begin{document}
    \renewcommand{\arraystretch}{1.3}%1.2
\begin{tabular}{|M{1cm}|M{1cm}|M{1cm}|M{1.8cm}|M{1.8cm}|M{1.99cm}|M{1.8cm}|}
    \cline{4-7}
\multicolumn{3}{c|}{}
        & Title 1 & Title 2  & Title 3 & Title 4\\
\hline
\multirow{12}*[-1ex]{\rotatebox[origin=b]{90}{\huge{\so{2016}}}}
    &   \multirow{3}*{1\textsuperscript{st} Q.}
        &   Jan & 0 & 0 & 3 & 10\\ \cline{3-7}
    &   &   Feb & 0 & 0 & 0 & 10\\ \cline{3-7}
    &   &   Mar & 0 & 0 & 0 & 10\\ \cline{2-7}
    &   \multirow{3}*{2\textsuperscript{nd} Q.}                         
        &   Apr & 0 & 0 & 1 & 10\\ \cline{3-7}
    &   &   May & 0 & 0 & 0 & 10\\ \cline{3-7}
    &   &   Jun & 1 & 1 & 0 & 8\\ \cline{2-7}
    &   \multirow{3}*{3\textsuperscript{nd} Q.}
        &   Jul & 1 & 1 & 0 & 7\\ \cline{3-7}
    &   &   Aug & 2 & 2 & 0 & 5\\ \cline{3-7}
    &   &   Sep & 1 & 1 & 0 & 4\\ \cline{2-7}
    &   \multirow{3}*{4\textsuperscript{nd} Q.}
        &   Oct & 2 & 2 & 2 & 2\\ \cline{3-7}
    &   &   Nov & 1 & 1 & 4 & 0\\ \cline{3-7}
    &   &   Dec & 1 & 1 & 5 & 0\\ \hline
\end{tabular}
\end{document}

Upgrade: It seems, that to many is more important s prefer stretched year (2016) than clear, simple and concise MWE code ... so I add one more posibility, how to stretch year number over all rows:

  • delete package soul
  • use \scalebox from graphicx package
  • instead of code line

\multirow{12}*[-1ex]{\rotatebox[origin=b]{90}{\huge{\so{2016}}}}

use

\multirow{12}*[-1ex]{\rotatebox[origin=b]{90}{\scalebox{5}{\tiny{2\quad0\quad1\quad6}}}}

With this changes the table looks as follows:

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.