Information and discussion about graphics, figures & tables in LaTeX documents.
SDavid
Posts: 3 Joined: Thu Jul 21, 2011 8:27 pm
Post
by SDavid » Thu Jul 21, 2011 8:30 pm
Hi,
I am trying to do a time table as in the following code:
Code: Select all
\documentclass[a4paper]{report}
\usepackage{lscape}
\usepackage{multirow}
\usepackage{bigstrut}
\usepackage{array}
\begin{document}
\thispagestyle{empty}
\pagestyle{empty}
\begin{landscape}
\begin{tabular}{*{11}{| m{1.5cm} |}}
\cline{3-11}
& & \multicolumn{9}{|c|}{Week}\\\cline{3-11}
& & Week 1 & Week 2 & Week 3 & Week 4 & Week 5 &Week 6& Week 7 & Week 8 & Week 9 \\\cline{1-11}
\multicolumn{1}{|c|}{\multirow{4}{*}{Course}} & \multicolumn{1}{|c|}{Course 1} & & & & & & & & &\\\cline{2-11}
& \multicolumn{1}{|c|}{Course 2} & & & & & & & & &\\\cline{2-11}
& \multicolumn{1}{|c|}{Course 3} & & & & & & & & &\\\cline{2-11}
& \multicolumn{1}{|c|}{Course 4} & & & & & & & & &\\\cline{1-11}
\end{tabular}
\end{landscape}
\end{document}
and I have some questions:
How to make the area over the first two columns (in the first two rows) completely blank?
How to align the writing in each cell to the center of the cell and maintaining the tabular argument above? I need the effect of |c| and |m{}| together.
Why is there double lines between columns?!
Thanks in advance
NEW: TikZ book now 40% off at Amazon.com for a short time.
Stefan Kottwitz
Site Admin
Posts: 10345 Joined: Mon Mar 10, 2008 9:44 pm
Post
by Stefan Kottwitz » Fri Jul 22, 2011 5:25 pm
Hi SDavid,
welcome to the board!
It's great that you posted a compilable minimal example. So of course I test your code and make suggestions.
Regarding your questions:
Use for example
without |. This overrides the |...| setting in the tabular options.
You can define your own column type which is centered both vertically and horizontally, such as
Code: Select all
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
That's because of your column definition. *{11}{| m{1.5cm} | expands to | m{1.5cm} || m{1.5cm} || m{1.5cm} |... Simply write
Code: Select all
\begin{tabular}{|*{11}{M{1.5cm}|}}
Complete example:
Code: Select all
\documentclass[a4paper]{report}
\usepackage{lscape}
\usepackage{multirow}
\usepackage{bigstrut}
\usepackage{array}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
\begin{document}
\thispagestyle{empty}
\pagestyle{empty}
\begin{landscape}
\begin{tabular}{|*{11}{M{1.5cm}|}}
\cline{3-11}
\multicolumn{2}{c|}{} & \multicolumn{9}{c|}{Week}\\\cline{3-11}
\multicolumn{2}{c|}{} & Week 1 & Week 2 & Week 3 & Week 4 & Week 5 &Week 6& Week 7 & Week 8 & Week 9 \\\cline{1-11}
\multicolumn{1}{|c|}{\multirow{4}{*}{Course}} & \multicolumn{1}{|c|}{Course 1} & & & & & & & & &\\\cline{2-11}
& \multicolumn{1}{|c|}{Course 2} & & & & & & & & &\\\cline{2-11}
& \multicolumn{1}{|c|}{Course 3} & & & & & & & & &\\\cline{2-11}
& \multicolumn{1}{|c|}{Course 4} & & & & & & & & &\\\cline{1-11}
\end{tabular}
\end{landscape}
\end{document}
Btw. in general I recommend to avoid vertical lines in tables, they make reading lines harder.
Stefan
LaTeX.org admin
SDavid
Posts: 3 Joined: Thu Jul 21, 2011 8:27 pm
Post
by SDavid » Fri Jul 22, 2011 9:15 pm
Thank you Stefan, that is perfect.
Regards