# Fit long sentence into table

I would like the sentence "Why get someone who only pretends to be a doctor when you could get a real one?" to fit into this 430pt table. But the sentence doesn't break after "could" and keeps running out of line. Shouldn't long sentences automatically break into paragraph in tabularx? How can I fix it?

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

I could insert \\ after "could" to manually break the line. But that would totally defeat the purpose.

You need no \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}

However, the number all alone in that big space is rather ugly.

Here's another possibility, without vertical rules.

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

• Does \tabularnewline mean to introduce new row? I think it's clearer than \. Your table looks pretty btw. But I'm wondering how come the vertical rules don't connect at the corners? Jun 2 '14 at 9:02
• @pineapple If you use \toprule and friends, you mustn't use vertical rules. That's the principle booktabs is based on. Jun 2 '14 at 9:08

The problem arises because \pbox{20cm}{...} is quite a bit wider than what's assigned to the column of type X. You could either calculate explicitly how wide this column really is (and adjust the first argument of \pbox) or you do something as follows:

\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}
• Since X is a special p{...} coulnd't you just get away with using \newline instead of those & + \ combos? Thus getting the same one row structure as the OP. Jun 2 '14 at 6:58
• @daleif - I guess the optimal adjustment depends in part on where the OP wants the 1 in first column placed: on the first row of the material on the right, or centered vertically with respect to the material on the right.
– Mico
Jun 2 '14 at 7:30
• @Mico: I changed \pbox to 11.5cm, and it worked perfectly. Those & also gave the same result, but words will have em dash at the end of the line. Jun 2 '14 at 7:36
• @pineapple - Glad things are working for you now.
– Mico
Jun 2 '14 at 7:40
• @Mico: Thank you! I like \pbox because it centers the 1, like you said, vertically w.r.t the description. Jun 2 '14 at 7:46