[texhax] Nested lists and newenvironment

Hefferon, James S. jhefferon at smcvt.edu
Fri Mar 7 19:27:27 CET 2014


Bill,

Thanks for the suggestion.  I changed the first trivlist to be a menulist but the problem is unchanged: the 2. and 3. for the menulist appear not in front of their associated text ("This is a nother test" and "And another.") but instead in the margin to the left of the 1. for the second environment.  Source below.  (Of course, perhaps I misunderstood you.)  Is there a way to get them to appear where \item puts them?

(Obviously, I have stripped out hte reason I have for using an environment here; briefly, I have an optional argument of 0 or 1 or 2 or3 that will include the exercise if the number is lower than a document class option sets.  This lets me make different-sized books.)

Jim

============================
\documentclass{article}

\newenvironment{exercise}{%
     \item 
}{%
}
\newenvironment{menulist}{
\begin{list}{}{
\setlength{\topsep}{0ex}
\setlength{\labelwidth}{0.03\linewidth}
\setlength{\leftmargin}{0.06\linewidth}
\setlength{\itemindent}{0em}
\setlength{\itemsep}{-\parskip}
\setlength{\parsep}{\parskip}}
}{\end{list}}

\begin{document}
\par\noindent Stuff before

\begin{menulist}
  \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{menulist}

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



More information about the texhax mailing list