如何使多行单元格中的文本分行显示

如何使多行单元格中的文本分行显示
\documentclass{article}
\usepackage{multirow}

\begin{document}

\begin{table}[htbp]
\centering
\begin{tabular}{ccccp{1cm}p{1cm}p{1cm}p{1cm}p{1cm}p{1cm}p{1cm}}
\hline
 & A & B & C  \\
 & & &  &\\
 \hline
\multirow{2}{*}{This is a really long sentence sentence sentence} & 0 & 6 & 230 \\
& 1 & 5 & 195  \\ \hline
\end{tabular}
\label{table2}
\end{table}


\end{document}

有没有办法让包含“这是一个非常长的句子”的单元格分成两行?在此处输入图片描述

答案1

您可以定义自己的命令并赋予其宽度和文本\breakText{5cm}{text},如下所示:

输出

\documentclass{article}
\usepackage{multirow}

\newcommand{\breakText}[2]{%
  \noindent \parbox{#1}{%
    #2
  }%
}
\begin{document}

  \begin{table}[htbp]
    \centering
    \begin{tabular}{ccccp{1cm}p{1cm}p{1cm}p{1cm}p{1cm}p{1cm}p{1cm}}
      \hline
      & A & B & C  \\
      & & &  &\\
      \hline
      \multirow{2}{*}{\breakText{5cm}{This is a really long sentence sentence sentence}} & 0 & 6 & 230 \\
      & 1 & 5 & 195  \\ \hline
    \end{tabular}
    \label{table2}
  \end{table}
\end{document}

相关内容