0

I'm making a planning for some report, and used the LaTeX table generator to change it from Excel to LaTeX. However, if I'm running the generated code, the vertical text gets split up, which I don't want, see image below. Does one of you know how to solve this issue? I want the week number columns to have equal spacing, but cannot manage to do this. I guess it is also the problem with the combination with merged rows and merged columns...

Latex problem vs. desired result

code (only first month):

\usepackage{makecell}
\usepackage{multirow}
\usepackage{colortbl}


\begin{table}
\centering
\begin{tabular}{|c|lllll|} 
\hline
\multicolumn{1}{|r|}{Week number} & 1                                                                         & 2 & 3 & 4 & 5  \\ 
\hline
\multicolumn{1}{|r|}{Month}       & \multicolumn{5}{l|}{January}                                                               \\ 
\hline
\multicolumn{1}{|l|}{Item}        &                                                                           &   &   &   &    \\ 
\hline
1                                 & {\cellcolor[rgb]{0.753,0.753,0.753}}                                      &   &   &   &    \\
2                                 & {\cellcolor[rgb]{0.753,0.753,0.753}}                                      &   &   &   &    \\
3                                 & {\cellcolor[rgb]{0.753,0.753,0.753}}                                      &   &   &   &    \\
4                                 & {\cellcolor[rgb]{0.753,0.753,0.753}}                                      &   &   &   &    \\
5                                 & {\cellcolor[rgb]{0.753,0.753,0.753}}                                      &   &   &   &    \\
6                                 & {\cellcolor[rgb]{0.753,0.753,0.753}}                                      &   &   &   &    \\
7                                 & {\cellcolor[rgb]{0.753,0.753,0.753}}                                      &   &   &   &    \\
8                                 & {\cellcolor[rgb]{0.753,0.753,0.753}}                                      &   &   &   &    \\
9                                 & {\cellcolor[rgb]{0.753,0.753,0.753}}                                      &   &   &   &    \\
A                                 & \multirow{-10}{*}{{\cellcolor[rgb]{0.753,0.753,0.753}}\rotcell{Holidays}} &   &   &   &    \\
\hline
\end{tabular}
\end{table}
5
  • To make your life easier, you can define a color in your preamble and refer back to this definition instead of having to enter the same rgb values over and over again.
    – leandriis
    Jan 9 '20 at 15:34
  • You could also color teh whole row and change the color back to shite for the corresponding cells in the first three rows.
    – leandriis
    Jan 9 '20 at 15:36
  • That would indeed clean up the code, bus as I said, this was generated by the LaTeX table generator (link) where you can just select a color and the latex code is generated with the RGB values. But thank you for the suggestion :)
    – seaver
    Jan 10 '20 at 10:30
  • But what if you later on decide to change the color to a slightly different shade of gray? You would have to edit all occurences of \cellcolor.
    – leandriis
    Jan 10 '20 at 10:32
  • 1
    That is true, it is very convient, however for this report, the color is not that important :P and the effort to change it is not worth the changing it to a 'global' color, haha :P But I definitely agree that preambling is the way to go :)
    – seaver
    Jan 10 '20 at 10:51
0

You can use \rotatebox. Replace the command \multirow{-10}{*}{{\cellcolor[rgb]{0.753,0.753,0.753}}\rotcell{Holidays}} with

\parbox[t]{5mm}{\multirow{-10}{*}{\cellcolor[rgb]{0.753,0.753,0.753}\rotatebox[origin=c]{90}{Holidays}}}

and it should work. The 5mm set the width of your gray column.

2
  • Your code seems to be missing a }.
    – leandriis
    Jan 9 '20 at 15:33
  • Yes you are right, i have added it now
    – Benny
    Jan 9 '20 at 15:40

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.