2

I'm trying to make one column in a table appear ragged right. I've had some success, depending (inexplicably, to me) on the number of columns. The following works for me:

Attempt 1

\documentclass{article}

\usepackage{graphicx}
\usepackage{dcolumn}

\begin{document}

\begin{tabular}{l>{\everypar{\raggedright}}p{7cm}l}
a & This is a test to see how paragraphs behave in this table & x \\
b & Here's another line of the table, just for the fun of it & y
\end{tabular}

\end{document}

Similarly, if I remove the first and third columns (leaving only the \raggedright column), then it still works.

However, I get errors and alignment problems when I remove the last column. In short, the following does not work:

Attempt 2

\documentclass{article}

\usepackage{graphicx}
\usepackage{dcolumn}

\begin{document}

\begin{tabular}{l>{\everypar{\raggedright}}p{7cm}}
a & This is a test to see how paragraphs behave in this table \\
b & Here's another line of the table, just for the fun of it
\end{tabular}

\end{document}

Can anyone explain why one works but the other doesn't? Also, I couldn't get either to work without the dcolumn package, which seems strange to me because that should be unrelated. Thanks for your help.

6

This is how you should be doing it.

\documentclass{article}

\usepackage{graphicx}
\usepackage{array}

\begin{document}

\begin{tabular}{l>{\raggedright\arraybackslash}p{7cm}}
a & This is a test to see how paragraphs behave in this table \\
b & Here's another line of the table, just for the fun of it
\end{tabular}

\end{document}

enter image description here

  • However, graphicx is not needed. – Dan Oct 30 '13 at 15:33
  • @Dan Oh, yes. I missed it. Copy paste error. :-) – user11232 Oct 30 '13 at 21:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.