以最后一列为中心的多行垂直文本

以最后一列为中心的多行垂直文本

我搜索了其他文章,试图找到一种方法来垂直对齐多行表格中的最后一列。但是没有成功,无论我怎么尝试,文本都不会移动。代码现在已经到了“被黑”的阶段,如果我删除对象,表格就会死掉(对此我深表歉意!)。

我已经定义

有没有人有什么建议?

我当前的代码如下:

\begin{table}[h]
\newcolumntype{A}{ >{\centering\arraybackslash} m{3.5cm} }
\newcolumntype{B}{ >{\centering\arraybackslash} m{5cm} }
\newcolumntype{C}{ >{\centering\arraybackslash} m{1.5cm} }
\newcolumntype{D}{ >{\centering\arraybackslash} m{2cm} }
\begin{tabular}{|A|B|C|D|D|}
\hline \textbf{Risk Description} & \textbf{Consequences} & \textbf{Severity} & \textbf{Likelihood} & \textbf{Risk} \\
\hline \hline
\multirow{2}{3.5cm}{\centering High pressures at depth}&\multirow{2}{5cm}{\centering Damage to camera’s electrical system.}&\multirow{2}{1.5cm}{\centering 9}& High Risk 4 & High Risk 36 \\[2ex]
\cline{4-5}
& & & Low Risk 3 & Low Risk 27 \\
[2ex]\hline

\multirow{2}{3.5cm}{\centering Leaks in camera housing}&\multirow{2}{5cm}{\centering  Damage to camera’s electrical system.}&\multirow{2}{1.5cm}{\centering 9}& High Risk 4 & High Risk 36 \\[2ex]
\cline{4-5}
& & & Low Risk 3 & Low Risk 27 \\
[2ex]\hline

\multirow{2}{3.5cm}{\centering Poor visibility in turbid water}&\multirow{2}{5cm}{\centering Cameras are unable to see targets and video feed quality suffers.}&\multirow{2}{1.5cm}{\centering 6}& High Risk 7 & High Risk 42 \\[2ex]
\cline{4-5}
& & & Low Risk 3 & Low Risk 18 \\
[2ex]\hline

\end{tabular}
\end{table}

我使用 LaTeX 的时间不长,因此修复此问题的知识基础非常有限。提前感谢您的帮助!

答案1

这是一个已知的错误,之前已经提到过这里

但是,您可以尝试使用其他方法重写表格,因为您根本不需要 -column m。我为您的表格做了这件事,因为在我看来,这会最令人满意。

% arara: pdflatex

\documentclass{article}
\usepackage[landscape]{geometry}
\usepackage{multirow}
\usepackage{booktabs}

\begin{document}
\begin{table}[h]
    \centering
    \begin{tabular}{ccccc}\toprule
        \textbf{Risk Description} & \textbf{Consequences} & \textbf{Severity} & \textbf{Likelihood} & \textbf{Risk} \\
        \midrule
        \multirow{2}{3.5cm}{\centering High pressures at depth}&\multirow{2}{5.2cm}{\centering Damage to camera's electrical system.}&\multirow{2}{*}{9} & High Risk 4 & High Risk $36$ \\
        & & & Low Risk 3 & Low Risk 27 \\\addlinespace      
        \multirow{2}{3.5cm}{\centering Leaks in camera housing}&\multirow{2}{5.2cm}{\centering  Damage to camera's electrical system.}&\multirow{2}{*}{9}& High Risk 4 & High Risk 36 \\
        & & & Low Risk 3 & Low Risk 27 \\\addlinespace      
        \multirow{2}{3.5cm}{\centering Poor visibility in turbid water}&\multirow{2}{5.2cm}{\centering Cameras are unable to see targets and video feed quality suffers.}&\multirow{2}{*}{6}& High Risk 7 & High Risk 42 \\
        & & & Low Risk 3 & Low Risk 18 \\\bottomrule    
    \end{tabular}
\end{table}
\end{document}

在此处输入图片描述

答案2

我通常会避免multirow;这是一个不同的实现。

\documentclass{article}
\usepackage[landscape]{geometry}
\usepackage{array,calc}

\newcommand{\multicell}[3][\centering]{%
  \makebox[#2]{%
    \begin{tabular}{@{}>{#1\arraybackslash}p{#2+2\tabcolsep}@{}}
    #3
    \end{tabular}%
  }%
}


\begin{document}

\begin{table}[htp]
\newcolumntype{A}{ >{\centering\arraybackslash} m{3.5cm} }
\newcolumntype{B}{ >{\centering\arraybackslash} m{5cm} }
\newcolumntype{C}{ >{\centering\arraybackslash} m{1.5cm} }
\newcolumntype{D}{ >{\centering\arraybackslash} p{2cm} }

\begin{tabular}{|A|B|C|D|D|}
\hline
\textbf{Risk Description} & \textbf{Consequences} & \textbf{Severity} & \textbf{Like} & \textbf{Risk} \\
\hline \hline
High pressures at depth &
  Damage to camera’s electrical system. &
  9 &
  \multicell{2cm}{High Risk 4 \\\hline Low Risk 3} &
  \multicell{2cm}{High Risk 36 \\\hline Low Risk 27} \\
\hline
\end{tabular}
\end{table}

\end{document}

在此处输入图片描述

相关内容