2

I am using \pbox to have line breaks in a table, but cannot seem to figure out how to have it break at the "natural" location where the margin begins.

Here is my code:

\documentclass{article}
%
\usepackage[top=1in,bottom=1in,left=1in,right=1in]{geometry}
\usepackage{amsmath}
\usepackage{pbox}
%
\begin{document}
%
\begin{tabular}{ll}
First cell & \pbox[t]{\columnwidth}{This is a long block of text that is not breaking where I would like it to break and as you can see it does not break eventually, but not until it hits the edge of the page.}
\end{tabular}
And this is another long block of text outside the tabular environment which has a line break where I would like it to be, that is, where the margin begins.
%
\end{document}

Does anyone know a command I can use to fix this? I have tried \columnwidth and \paperwidth as the length parameters of the \pbox command, but they both result in the same problem.

Also please note that I would like some sort of macro, rather than manually setting the length to 5in or whatever it is to the margin.

  • Welcome to tex.sx, note you can use the {} button (or simply indent by 4 spaces to format code sections (see my edit) – David Carlisle Oct 1 '13 at 19:41
  • Unrelated note: As option to geometry you can use margin=1in instead of defining the margins for all four sides of the page (since they are all the same). – Svend Tveskæg Oct 1 '13 at 19:50
  • Figured out how to format code, is there an easy way to show what the code outputs, so people don't need to copy-paste and compile to see what the MWE is doing? – Abe Schulte Oct 6 '13 at 18:24
4

There is no no need to use \pbox to have multi-cell entries. (It is just a nested tabular anyway. Simply use p columns instead of l. To have the width of the column determined automatically, use X from tabularx.

\documentclass{article}

\usepackage[top=1in,bottom=1in,left=1in,right=1in]{geometry}

\usepackage{amsmath}

\usepackage{tabularx}

\begin{document}

\noindent
\begin{tabularx}{\textwidth}{lX}

First cell & This is a long block of text that is not breaking where I would like it to break and as you can see it does break eventually, but not until it hits the edge of the page.

\end{tabularx}

And this is another long block of text outside the tabular environment which has a line break where I would like it to be, that is, where the margin begins.
\end{document}

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.