1

I've got a bunch of paragraphs that I'm manually "tabbing out" using hspace of varying degree. After the varying amount of hspace, I'm trying to make a paragraph that fills the remaining width available on the page. Unfortunately, parbox requires a finite width to be passed to it, which isn't known unless I calculate it manually for each paragraph. Is there an easier way to do this?

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

Result

UPDATE

I'm getting very close, but when I try to add my manually-numbered paragraphs, the right margin gets messed up again.

Here's an example. If I try to use adjustwidth again, it creates a line break after the section number which I don't want.

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

Second result

  • Hard to say given so little information but tabularx or (usually better) a list environment probably does what you need. Please always include a complete small document that shows the problem. – David Carlisle Nov 11 '13 at 21:53
  • I'll create a little sample to show the problem. Thanks for your help. – aardvarkk Nov 11 '13 at 21:57
  • @DavidCarlisle I've added an example with an included image. – aardvarkk Nov 11 '13 at 22:10
  • 2
    \makebox[2em]{1.1}\parbox[t]{\linewidth} is clearly 2em too wide but again you should be using a list environment with \item[1.1] not parboxes. – David Carlisle Nov 11 '13 at 23:10
  • @DavidCarlisle Switching to item from parbox does give me something that's much closer to what I'm looking for. I think it's safe to say that last bit solves the problem. Thanks! – aardvarkk Nov 11 '13 at 23:15
3

Probably you would want to consider using the changepage package. With it you can locally adjust the margins of text in a page with the use of the environment, adjustwidth.

\begin{adjustwidth}{<leftmargin>}{<rightmargin>}
<content>
\end{adjustwidth}

enter image description here

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

For the second question, you can use a list as David Carlisle suggested. This can be achieved as follows:

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

enter image description here

Now playing with lists to make more robust:

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

enter image description here

  • I like this answer because it seems a bit simpler in my mind... I also don't feel like I'm really producing a "list" (unless my entire document is considered a list), so this seems more appropriate. – aardvarkk Nov 11 '13 at 22:27
  • Hmm... this is so close! My problem now is that I have another space in the paragraph allocated to a section number. When I try to add that via a makebox, the text now shoots off the end of the page again. I'll add it as an update. – aardvarkk Nov 11 '13 at 22:54
  • It's not quite solved yet! I've put an update in the question. – aardvarkk Nov 11 '13 at 22:55
3

The way to control margins in LaTeX is to use a list environment (compare the definition of quote in article class).

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

enter image description here

  • Seems like it will likely work once I translate it back to my document. How could I have figured this out on my own? I've been finding myself back at places like en.wikibooks.org/wiki/LaTeX/List_Structures a lot, but they don't even seem to mention begin{list}. I'd like to understand the syntax a bit better so I know what the empty curly braces are for, etc. – aardvarkk Nov 11 '13 at 22:22
  • 1
    The latexbook or latex companion are the official references (not free of course) or this site or there are lots of packages using the same technique eg the adustwidth environment in the other answer is a wrapper making a list environment with perhaps a more natural syntax for this kind of case which isn't obviously a list. Or you could look at article.cls where the quote environment is defined exactly this way, but changes left and right margin, not just left. – David Carlisle Nov 11 '13 at 22:26
  • Is "The latexbook" "Guide to LaTeX" by Kopka? – aardvarkk Nov 11 '13 at 22:29
  • 1
    @aardvarkk no, the official latex manual is amazon.com/LaTeX-Document-Preparation-System-Edition/dp/… – David Carlisle Nov 11 '13 at 22:32
  • 1
    @aardvarkk if you use a list environment the \linewidth is update to the new width taking indentation into account but it doesn't just change itself automatically, but parboxes are not what you want anyway as they prevent breaking – David Carlisle Nov 12 '13 at 16:38

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.