[texhax] Nested lists and newenvironment

Dan Luecking dluecking at sbcglobal.net
Fri Mar 7 20:14:09 CET 2014


On Mar 7, 2014 at 15:07:02 CET, Hefferon, James S. 
<http://tug.org/pipermail/texhax/2014-March/mailto:texhax%40tug.org?Subject=Re%3A%20%5Btexhax%5D%20Nested%20lists%20and%20newenvironment&In-Reply-To=%3C8E15C2BC0B63AD4AA20BF9F1C3947FC10128CBDC22%40SMCEXMBX01.mikenet.smcvt.edu%3E>jhefferon 
at smcvt.edu wrote:


>I'm scratching my head over some interaction between nested lists 
>and newenvironment.  A small working example is at the end.
>
>If I use the \begin{exercise}..\end{exercise} construct, with 
>nothing after the \item[] of the trivlist, then the numbers of the 
>enumerate environment are not placed next to the text "This is a 
>nother test." and "And another." but instead appear in the margin 
>before the next trivlist.  If I just use \item instead of the 
>environment then it is good; the numbers appear where I think they should.
>
>I am also good if any text at all appears between the \item[] and 
>the \begin{enumerate}  (just \hbox{} or just \relax won't do).
>
>Of course, none of this happens if I strip out the surrounding trivlist.
>
>No doubt I'm missing something obvious but I would greatly 
>appreciate if someone could point out my blind spot.

Wrapping \item in a group (as your exercise environment does)
is problematic. The \item command examines and sets some switches:
   --\if at noparitem is true at the start of a list environment,
     before the first item's paragraph.
   -- \if at inlabel is true when \item occurs after another item but
      before a new paragraph.
The second is globally set false (by \everypar) but the first is
nonglobally set false by the \item command itself.

Wrapping \item in a group causes each item to see itself as
the first in the enumerate environment. I have not been able
yet to trace exactly how this leads to the results you see,
and how the surrounding trivlist environment is involved,
but sure one can expect things to go wrong if mistaken
information is used.

Personally, I would just use \let\exercise\item and not use
an environment.

Dan


Daniel H. Luecking
Department of Mathematical Sciences
Fayetteville, Arkansas
http://www-cs-faculty.stanford.edu/~knuth/iaq.html 




More information about the texhax mailing list