我有许多段落,我使用hspace
不同程度的 手动“制表”。在不同的 数量之后hspace
,我试图制作一个段落来填充页面上剩余的可用宽度。不幸的是,parbox
需要传递给它一个有限的宽度,除非我为每个段落手动计算,否则无法知道这个宽度。有没有更简单的方法来做到这一点?
\documentclass{article}
\begin{document}
\hspace{2in}
\parbox{\linewidth}{I have a whole bunch of text here and it will extend past the edge of the page even though I'd like it to break before the page ends and act like a normal paragraph.}
\end{document}
更新
我已经很接近了,但是当我尝试添加手动编号的段落时,右边距又变得乱了。
这是一个例子。如果我尝试adjustwidth
再次使用,它会在节号后创建一个我不想要的换行符。
\documentclass{article}
\usepackage{changepage}
\begin{document}
\begin{adjustwidth}{2.5cm}{}
\parbox{\linewidth}{This paragraph runs to the proper end of the page. It will have a fair bit of space at the end, unlike the next paragraph which will overshoot it because of the makebox that's put in front of it.}
\makebox[2em]{1.1}\parbox[t]{\linewidth}{I have a whole bunch of text here and it will extend past the edge of the page even though I'd like it to break before the page ends and act like a normal paragraph.}
\end{adjustwidth}
\end{document}
答案1
您可能想要考虑使用该changepage
包。有了它,您可以使用环境局部调整页面中文本的边距adjustwidth
。
\begin{adjustwidth}{<leftmargin>}{<rightmargin>}
<content>
\end{adjustwidth}
\documentclass{article}
\usepackage{changepage}
\usepackage{lipsum}
\begin{document}
\lipsum[1-2]
\begin{adjustwidth}{2.5cm}{} % Here 2.5cm defines the extra tabbing you need. The right margin is left untouched to keep the default right margin.
\lipsum[1-2]
\end{adjustwidth}
\lipsum[1-2]
\end{document}
对于第二个问题,你可以像 David Carlisle 建议的那样使用列表。具体方法如下:
\documentclass{article}
\usepackage{changepage}
\usepackage{enumitem}
\begin{document}
\begin{adjustwidth}{2.5cm}{}
This paragraph runs to the proper end of the page. It will have a fair bit of space at the end, unlike the next paragraph which will overshoot it because of the makebox that's put in front of it.
\begin{enumerate}[label=1.\arabic*,leftmargin=*]
\item I have a whole bunch of text here and it will extend past the edge of the page even though I'd like it to break before the page ends and act like a normal paragraph.
\end{enumerate}
\end{adjustwidth}
\end{document}
现在使用列表使其更加健壮:
\documentclass{article}
\usepackage{changepage}
\usepackage{enumitem}
\newlist{parin}{enumerate}{2} % depth of 2 can be changed depending on the necessity
\setlist[parin,1]{label*=1.\arabic*.,leftmargin=*}
\setlist[parin,2]{label*=\arabic*.,leftmargin=*}
\begin{document}
\begin{adjustwidth}{2.5cm}{}
This paragraph runs to the proper end of the page. It will have a fair bit of space at the end, unlike the next paragraph which will overshoot it because of the makebox that's put in front of it.
\begin{parin}
\item I have a whole bunch of text here and it will extend past the edge of the page even though I'd like it to break before the page ends and act like a normal paragraph.
\begin{parin}
\item I have a whole bunch of text here and it will extend past the edge of the page even though I'd like it to break before the page ends and act like a normal paragraph.
\item I have a whole bunch of text here and it will extend past the edge of the page even though I'd like it to break before the page ends and act like a normal paragraph.
\end{parin}
\item I have a whole bunch of text here and it will extend past the edge of the page even though I'd like it to break before the page ends and act like a normal paragraph.
\begin{parin}
\item I have a whole bunch of text here and it will extend past the edge of the page even though I'd like it to break before the page ends and act like a normal paragraph.
\item I have a whole bunch of text here and it will extend past the edge of the page even though I'd like it to break before the page ends and act like a normal paragraph.
\end{parin}
\end{parin}
\end{adjustwidth}
\end{document}
答案2
在 LaTeX 中控制边距的方法是使用列表环境(比较课堂quote
中的定义article
)。
\documentclass{article}
\begin{document}
\begin{list}{}{\setlength\leftmargin{2in}}\item\relax
I have a whole bunch of text here and it will extend past the edge of the page even though I'd like it to break before the page ends and act like a normal paragraph.
\end{list}
\end{document}