[texhax] Nested lists and newenvironment

Hefferon, James S. jhefferon at smcvt.edu
Fri Mar 7 15:07:02 CET 2014


Hello,

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).  

The behavior is unchanged if I alter the trivlist to itemize (and in my document, I want it to be enumerate).

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.

Thank you,
Jim Hefferon

================================================= 

\documentclass{article}

\newenvironment{exercise}{%
     \item 
}{%
}

\begin{document}
\par\noindent Stuff before

\begin{trivlist}
  \item[] \begin{enumerate}
    \begin{exercise}
      This is a test.
    \end{exercise}
    \begin{exercise} 
      This is a nother test.
    \end{exercise}
    \begin{exercise} 
      And another.
    \end{exercise}
  \end{enumerate}
\end{trivlist}

\begin{trivlist}
  \item[] \begin{enumerate}
    \item
      This is a new test.
    \item
      This is a nother new test.
    \item
      And another new test.
  \end{enumerate}
\end{trivlist}

\par\noindent Stuff after.
\begin{trivlist}
  \item[] Any text at all.
  \begin{enumerate}
    \begin{exercise}
      This is a test.
    \end{exercise}
    \begin{exercise} 
      This is a nother test.
    \end{exercise}
    \begin{exercise} 
      And another.
    \end{exercise}
  \end{enumerate}
\end{trivlist}


\begin{trivlist}
  \item[] \begin{enumerate}
    \item
      This is a new test.
    \item
      This is a nother new test.
    \item
      And another new test.
  \end{enumerate}
\end{trivlist}

\par\noindent The end.
\end{document} 

------------------------------------------
"Does not the Captain seek your advice, sir?"
"Not always," said Stephen.



More information about the texhax mailing list