将长句子放入表格中

将长句子放入表格中

我希望“既然可以找到真正的医生,为什么还要找一个假装是医生的人?”这句话能适合这个 430pt 的表格。但这句话在“could”之后没有换行,而且总是超出行距。在 tabularx 中,长句子不应该自动换行吗?我该如何修复它? 在此处输入图片描述

\documentclass[11pt]{book}

\usepackage{tabularx,pbox}

\begin{document}

\begin{table}
\begin{tabularx}{430pt}{|c|X|}
\hline
\textbf{Paragraph \#} & \textbf{Description:} \\
\hline
1 & \pbox{20cm}{\emph{Rhetorical questions/Introduction} \\ 
    Why get someone who only \emph{pretends} to be a doctor when you 
    could get a real one? \\ \emph{Relate to audience} \\ Some more sentence
    here.} \\ 

\end{tabularx}
\end{table}
\end{document}

我可以\\在“could”后面插入以手动换行。但这完全违背了目的。

答案1

你不需要\pbox

\documentclass[11pt]{book}

\usepackage{tabularx}

\begin{document}

\begin{table}
\centering

\renewcommand{\tabularxcolumn}{m} % we want center vertical alignment

\begin{tabularx}{\textwidth}{|c|>{\raggedright}X|}
\hline
\textbf{Paragraph \#} & \textbf{Description:} \tabularnewline
\hline
1 & \emph{Rhetorical questions/Introduction} \\
    Why get someone who only \emph{pretends} to be a doctor when you
    could get a real one? \\
    \emph{Relate to audience} \\
    Some more sentence here. \tabularnewline
\hline
\end{tabularx}
\end{table}
\end{document}

在此处输入图片描述

但是,在那么大的空间里,孤零零的数字显得有些丑陋。

这是另一种可能性,没有垂直规则。

\documentclass[11pt]{book}

\usepackage{tabularx,booktabs}

\begin{document}

\begin{table}
\centering
\begin{tabularx}{\textwidth}{c>{\raggedright}X}
\toprule
\textbf{Par.\ \#} & \textbf{Description:} \tabularnewline
\midrule
1 & \emph{Rhetorical questions/Introduction} \\
    Why get someone who only \emph{pretends} to be a doctor when you
    could get a real one? \\
    \emph{Relate to audience} \\
    Some more sentence here. \tabularnewline
\midrule
2 & \emph{Rhetorical questions/Introduction} \\
    Why get someone who only \emph{pretends} to be a doctor when you
    could get a real one? \\
    \emph{Relate to audience} \\
    Some more sentence here. \tabularnewline
\bottomrule
\end{tabularx}
\end{table}
\end{document}

在此处输入图片描述

答案2

问题出现是因为\pbox{20cm}{...}比分配给 类型的列的宽度要宽得多X。您可以明确计算此列的实际宽度(并调整 的第一个参数\pbox),也可以执行以下操作:

\documentclass[11pt]{book}
\usepackage{tabularx,pbox}
\begin{document}
\begin{table}
\begin{tabularx}{430pt}{|c|X|}
\hline
\textbf{Paragraph \#} & \textbf{Description:} \\
\hline
1 & \emph{Rhetorical questions/Introduction} \\
  & Why get someone who only \emph{pretends} to be a doctor when you  get a real one? \\ 
  & \emph{Relate to audience} \\ 
  & Some more sentences here. \\
\hline
\end{tabularx}
\end{table}
\end{document}

相关内容