2

I'm trying to rotate some cells in my table, but they seem to be right aligned for no specific reason. They also expand the cells somehow.

\documentclass[a4paper, 11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[left=22.5mm,right=22.5mm,top=30mm,bottom=30mm]{geometry}
\usepackage{setspace}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{ragged2e}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}  % right alligned text in X column
\newcommand*\rot{\rotatebox{90}}

\usepackage{pdflscape}

\begin{document}

\begin{table}
    \centering
    \caption{Risk management plan.}
    \begin{tabularx}{\textwidth}{|c|L|c|L|L|>{\raggedright\arraybackslash}p{1.44cm}|}
    \hline
    \multicolumn{1}{|c|}{\textbf{\#}} &
        \multicolumn{1}{c|}{\textbf{Risk}} &
            \multicolumn{1}{c|}{\textbf{\begin{tabular}[c]{@{}c@{}}Risk\\ level\end{tabular}}} &
                \multicolumn{1}{c|}{\textbf{Mitigation}} &
                    \multicolumn{1}{c|}{\textbf{Monitoring}} &
                        \multicolumn{1}{c|}{\textbf{\begin{tabular}[c]{@{}c@{}}Respon-\\ sibility\end{tabular}}} \\ 
    \hline
    1 & Possible defaulted payment by the client in December & \rot{High} & Make client pay one month in advance & Well documented payment schedule & Project manager \\ 
    \hline
    2 & Subcontractor going out of business & \rot{Low} & Have access to a quick raplacement & Look out for any late payments by the subcontractor & Project manager \\
    \hline
    3 & Property developer going out of business & \rot{Low} & Recover damages in court &  & Project manager \\ 
    \hline
    4 & Bad weather, slowing down civil works & \rot{Medium} & Planing ahead, doing certain tasks under good conditions & Keeping an eye on the weather forecast & Civil CPEng \\
    \hline
    5 & Force Majeure (e.g. earthquake) & \rot{Medium} & Uphold current safety standards regarding natural disasters & Pay attention to warnings of natural catastrophes & Project manager \\
    \hline
    6 & Accidents on the workplace & \rot{Medium} & Adhere to health \& safety standards & Being mindful of oneself and others at work & Project manager \\
    \hline
    7 & Unforeseen physical condidtions of the site & \rot{High} & Complete geotechnical reports on the land & Compare report with actual condidtions weekly & Civil CPEng \\
    \hline
    \end{tabularx}
\end{table}
\end{document}

enter image description here

EDIT: The proposed solution from @marmot is better, but there are still some alignment issues enter image description here

  • 1
    Have you tried to use \rotatebox[origin=r]{90}{Medium} for every entry you're gonna rotate? – Kurniawan Prihadi May 31 at 6:06
  • You need to load graphicx to make @KurniawanPrihadi's suggestion work. Then you can use \newcommand*\rot[1]{\rotatebox[origin=r]{90}{#1}}. – user121799 May 31 at 6:18
  • 4
    I'm voting to close this question as off-topic because is solved by comments. – Zarko May 31 at 6:34
  • 1
    for the "no apparent reason" look at the first case with High the reference point is the bottom left tip of the H and that is on the same baseline as the text in the other cells on the row, so the rotated word is all above that. – David Carlisle May 31 at 8:46
  • 1
    @Zarko You and Herbert should have left the answer to Kurniawan Prihadi and not just use what they suggest in "your" answers. Don't you have enough reputation points? Do you really have to do such things? – user121799 Jun 1 at 15:17
0

Rotated word "medium" is longer than height of the row, where it is. To improve its placement you need to increase row's height (for example with adding rule[-3ex]{0pt}{0pt}) beside use correct syntax for rot as suggested in comment of @Kurniawan Prihadi.

enter image description here

\documentclass[a4paper, 11pt]{article}
\usepackage[hmargin=30mm, vmargin=22.5mm]{geometry}
\usepackage{graphicx}
\newcommand\rot[1]{\rotatebox[origin=r]{90}{#1}}
\usepackage{makecell, tabularx}
\renewcommand\theadfont{\small\bfseries}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}  % right aligned text in X column

\usepackage{pdflscape}

\begin{document}

\begin{table}
    \centering
    \caption{Risk management plan.}
    \begin{tabularx}{\linewidth}{|c|L|c|L|L|>{\raggedright\arraybackslash}p{4em}|}
    \hline
    \thead{\#}  &
        \thead{Risk}  &
            \thead{Risk\\ level} &
                \thead{Mitigation}  &
                    \thead{Monitoring} &
                        \thead{Respon-\\ sibility} \\
    \hline
    1 & Possible defaulted payment by the client in December & \rot{High} & Make client pay one month in advance 
           & Well documented payment schedule 
               & Project manager   \\
    \hline
    2 & Subcontractor going out of business &\rot{Low} & Have access to a quick raplacement 
           & Look out for any late payments by the subcontractor 
               & Project manager   \\
    \hline
    3 & Property developer going out of business & \rot{Low} & Recover damages in court 
           &   & Project manager   \\
    \hline
    4 & Bad weather, slowing down civil works & \rot{Medium} & Planing ahead, doing certain tasks under good conditions 
            & Keeping an eye on the weather forecast 
                & Civil CPEng      \\
    \hline
    5 & Force Majeure (e.g. earthquake) & \rot{Medium} & Uphold current safety standards regarding natural disasters 
            & Pay attention to warnings of natural catastrophes 
                & Project manager  \\
    \hline
    6 & Accidents on the workplace & \rot{Medium} & Adhere to health \& safety standards 
            & Being mindful of oneself and others at work\rule[-3ex]{0pt}{0pt} % <---
                & Project manager  \\
    \hline
    7 & Unforeseen physical conditions of the site & \rot{High} & Complete geotechnical reports on the land 
            & Compare report with actual conditions weekly 
                & Civil CPEng      \\
    \hline
     \end{tabularx}
\end{table}
\end{document}

or replace "Height", "Medium" and "Low" with "H", "M" and "L", and not rotate them. Meaning of this abbreviations you can explain in last row of table:

enter image description here

To my opinion this solution is more typographical appealing.

\documentclass[a4paper, 11pt]{article}
\usepackage[hmargin=30mm, vmargin=22.5mm]{geometry}
\usepackage{makecell, tabularx}
\renewcommand\theadfont{\small\bfseries}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}  % right alligned text in X column

\usepackage{pdflscape}

\begin{document}
\begin{table}
    \centering
    \caption{Risk management plan.}
    \begin{tabularx}{\linewidth}{|c|L|c|L|L|>{\raggedright\arraybackslash}p{4em}|}
    \hline
    \thead{\#}  &
        \thead{Risk}  &
            \thead{Risk\\ level} &
                \thead{Mitigation}  &
                    \thead{Monitoring} &
                        \thead{Respon-\\ sibility} \\
    \hline
    1 & Possible defaulted payment by the client in December & H & Make client pay one month in advance 
          & Well documented payment schedule 
               & Project manager \\
    \hline
    2 & Subcontractor going out of business & L & Have access to a quick raplacement 
          & Look out for any late payments by the subcontractor 
               & Project manager \\
    \hline
    3 & Property developer going out of business & L & Recover damages in court 
          &    & Project manager \\
    \hline
    4 & Bad weather, slowing down civil works & M & Planing ahead, doing certain tasks under good conditions 
           & Keeping an eye on the weather forecast 
                & Civil CPEng \\
    \hline
    5 & Force Majeure (e.g. earthquake) & M & Uphold current safety standards regarding natural disasters 
           & Pay attention to warnings of natural catastrophes 
                 & Project manager \\
    \hline
    6 & Accidents on the workplace & M & Adhere to health \& safety standards 
            & Being mindful of oneself and others at work 
                 & Project manager \\
    \hline
    7 & Unforeseen physical conditions of the site & H & Complete geotechnical reports on the land 
            & Compare report with actual conditions weekly 
                 & Civil CPEng \\
    \hline
    \multicolumn{5}{l}{H: Height,\quad M: M: Medium, \quad L: Low}
    \end{tabularx}
\end{table}
\end{document}
1
\newcommand*\rot[1]{\rotatebox[origin=r]{90}{ #1 }}

enter image description here

  • 1
    This is just copied from this comment!!!!! – user121799 Jun 1 at 15:12
  • You should red carefully what you defined and what I defined. If you do not know what the spaces do, then ask a question ... – user187802 Jun 1 at 16:46
  • If you do not know what academic honesty is, then try to find out more about it. Regardless of whether you call yourself Herbert or Red Cloud: try to be a little bit honest. Why can't you give credit to others? – user121799 Jun 1 at 16:57

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.