表格居中似乎不起作用

表格居中似乎不起作用

嗨,我就是无法将第 3 行的文本置于中心。数组包已加载。非常感谢您的帮助。

\centering

\begin{tabular}{|c|m{5cm}|}
\hline
STATE & EVENT \\ 
\hline 
The vase was broken &  \\ 
\hline 
\multicolumn {2} {|c|} {The vase was \colorbox{red!50}{broken}}\\ 
\hline
& The vase was \colorbox{red!50}{broken} \newline by the dog \\ 
\hline 
\end{tabular}

答案1

如果你使第二列居中,它就会起作用:

\documentclass{article}
\usepackage{amsmath,array,xcolor}

\begin{document}

\centering

\begin{tabular}{|c|>{\centering\arraybackslash}m{5cm}|}
\hline
STATE & EVENT \\ 
\hline 
The vase was broken &  \\ 
\hline 
\multicolumn{2}{|c|}{The vase was \colorbox{red!50}{broken}}\\ 
\hline
line & The vase was \colorbox{red!50}{broken} \linebreak by the dog \\ 
\hline 
\end{tabular}

\end{document}

编辑
重新发布更改后的输出

Latex 输出

相关内容