9

How can I set the column width of the p column(s), to be precisely what's left after the other self adjusting specifiers are done with their work?

Here is a MWE

\documentclass{article}
\begin{document}
\begin{tabular}{|r|c|p{3in}|}
\hline
 One & Two  & Neque porro quisquam est, qui dolorem ipsum 
quia dolor sit amet, consectetur, adipisci velit, sed quia 
non numquam eius modi tempora incidunt ut labore et dolore 
magnam aliquam quaerat voluptatem.\\
\hline
Three  &  Four & Sed ut perspiciatis unde omnis iste natus error
 sit voluptatem accusantium doloremque laudantium, totam rem aperiam,
 eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae  
 vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas
 sit aspernatur aut odit aut fugit, sed quia consequuntur magni 
 dolores eos qui ratione voluptatem sequi nesciunt.  \\
 \hline
 \end{tabular}
 \end{document}

Here is the output

enter image description here

In this example, I would like the argument of p{3in} in the tabular header to be set automatically.

2
  • 2
    Do you assume, that table width is equal to text width and the width of the last column is equal to space left after first two columns? – Zarko Jan 7 '17 at 6:15
  • 1
    No need for array in your example... – Werner Jan 7 '17 at 7:05
9

Use tabularx!

\documentclass{article}
\usepackage{tabularx}
\begin{document}
\begin{tabularx}{0.9\linewidth}{|r|c|X|}
\hline
 One & Two  & Neque porro quisquam est, qui dolorem ipsum 
quia dolor sit amet, consectetur, adipisci velit, sed quia 
non numquam eius modi tempora incidunt ut labore et dolore 
magnam aliquam quaerat voluptatem.\\
\hline
Three  &  Four & Sed ut perspiciatis unde omnis iste natus error
 sit voluptatem accusantium doloremque laudantium, totam rem aperiam,
 eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae  
 vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas
 sit aspernatur aut odit aut fugit, sed quia consequuntur magni 
 dolores eos qui ratione voluptatem sequi nesciunt.  \\
 \hline
 \end{tabularx}
 \end{document}

enter image description here

1
  • Exactly, thats the way to go! – Jan Jan 7 '17 at 8:09

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.