我想让 pbox 在边距处有换行符

我想让 pbox 在边距处有换行符

我习惯\pbox在表格中使用换行符,但似乎无法弄清楚如何让它在边距开始的“自然”位置处换行。

这是我的代码:

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

有人知道我可以使用什么命令来修复这个问题吗?我尝试过将\columnwidth\paperwidth作为命令的长度参数\pbox,但它们都导致同样的问题。

还请注意,我想要某种宏,而不是手动设置长度5in或边距。

答案1

无需使用\pbox即可拥有多单元格条目。(tabular反正它只是一个嵌套。只需使用p列而不是即可l。要自动确定列的宽度,请X使用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}

相关内容