4

I'm trying to break the following command

    %\hsize=380 true pt
    \line{%
    1
    \hfil\vtop{\hsize 365 truept{%
    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
    Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
    Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
    Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.}
    }}

through its current page. I wrote the command above in order to get an exercises environment, in which I put the exercise number on the left (in this case is number 1), then its text on the right. However, when I'm on the bottom of the page, TeX does not break the environment and inserts all the text into the next page. Is there a way to get the results I'm looking for, rather than use \item or similar command?

2 Answers 2

3

Don't use a box.

\long\def\exercise#1 #2\endexercise{%
  \begingroup\par\bigskip
  \leftskip=15pt
  \noindent\llap{\hbox to15pt{#1\hfil}}#2\par\bigskip
  \endgroup}

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor  incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat.

\exercise 1
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor  incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum
dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui
officia deserunt mollit anim id est laborum.
\endexercise

\bye

enter image description here

2

this method is tried and true. just make sure to use the same width for the \hbox and the \hangindent.

(a "helper" macro is used to provide dummy text.)

\def\fillertext{here is the text of the exercise. }

\long\def\myexercise#1#2{%
    \noindent\hangindent3em
    \hbox to3em{\hfil #1\quad}\unskip#2\ignorespaces
    \par
    }

\noindent
start with some unindented text.

\myexercise 1 {\fillertext\fillertext\fillertext
  \fillertext\fillertext\fillertext\fillertext}

\vskip 8in

\myexercise 2 {\fillertext\fillertext\fillertext
  \fillertext\fillertext\fillertext\fillertext}

\myexercise 3 {\fillertext\fillertext\fillertext
  \fillertext\fillertext\fillertext\fillertext}

\noindent
and here is some more ordinary unindented text.
\bye

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.