未对齐旋转的单元格

未对齐旋转的单元格

我尝试旋转表格中的某些单元格,但它们似乎无缘无故地右对齐。它们还以某种方式扩展了单元格。

\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}

在此处输入图片描述

编辑:@marmot 提出的解决方案更好,但仍然存在一些对齐问题 在此处输入图片描述

答案1

旋转后的单词“medium”比其所在的行高要长。要改善其位置,您需要增加行高(例如添加),此外还要使用@Kurniawan Prihadi 评论中所建议的rule[-3ex]{0pt}{0pt}正确语法。rot

在此处输入图片描述

\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}

或者将“Height”、“Medium”和“Low”替换为“H”、“M”和“L”,并且不旋转它们。您可以在表格最后一行解释这些缩写的含义:

在此处输入图片描述

在我看来,这个解决方案在印刷上更具吸引力。

\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}

答案2

\newcommand*\rot[1]{\rotatebox[origin=r]{90}{ #1 }}

在此处输入图片描述

相关内容