2

I am trying to create a new "Examples" environment in the memoir class (which has the tocloft package, I believe), but I cannot get the list entries correct. The best I have is the following,

\documentclass{memoir}
\usepackage{amsthm}

\newlength\Labelwidth
\newlength\AfterLabelspace
\setlength\Labelwidth{2em}
\setlength\AfterLabelspace{10pt}

\newtheorem{xexample}{Example}
\newcommand\listexamplesname{List of Examples}
\newlistof{listofexample}{loe}{\listexamplesname}
\newlistentry[chapter]{examplecounter}{loe}{0}
\newcommand{\edescription}[1]{%
\refstepcounter{examplecounter}
\par\noindent\textbf{Example \theexamplecounter~(#1).}
\addcontentsline{loe}{section}{\protect\numberline{\theexamplecounter}#1}}
\newenvironment{example}[1][]{\edescription{#1}}{\qed\par}

\newcounter{propcounter}[chapter]
\newenvironment{proposition}[1][]{\refstepcounter{propcounter} \noindent  {\bfseries Proposition \arabic{propcounter}  (#1).}}{\qed}

\begin{document}

\listofexample
\bigskip

\begin{example}[Big Idea]
Some big idea.
\end{example}

\begin{proposition}[Medium Idea]
Something hard.
\end{proposition}

\begin{example}[Small Idea]
Some small idea.
\end{example}

\end{document}

This gives me the following:

enter image description here which I'm happy with except that I want the list items (e.g., "0.1 ...") to be flush left the same way my figure and table lists are.

I also know that I should not be using

\addcontentsline{loe}{section}{\protect\numberline{\theexamplecounter}#1}}

but rather

\addcontentsline{loe}{listofexample}{\protect\numberline{\theexamplecounter}#1}}

But when I use "listofexample" instead of "section" I get,

enter image description here

which is junk.

Question: How do I use "listofexample" in \addcontentsline to get what I want? I know that \newlistof creates lots of extra macros, but I do not know which to use.

Thanks for anyone's help.

1
  • Welcome to TeX.SX! You can disable the tocloft emulation by memoir.
    – user31729
    Commented Oct 1, 2015 at 19:29

1 Answer 1

1

Instead of

\addcontentsline{loe}{section}{\protect\numberline{\theexamplecounter}#1}

which instruct memoir to format the entries as section entries (thus adding the same indention as for section entries in the ToC), use

\addcontentsline{loe}{figure}{\protect\numberline{\theexamplecounter}#1}

so the entries are formatted as figure entries. A complete example:

\documentclass{memoir}
\usepackage{amsthm}

\newlength\Labelwidth
\newlength\AfterLabelspace
\setlength\Labelwidth{2em}
\setlength\AfterLabelspace{10pt}

\newtheorem{xexample}{Example}
\newcommand\listexamplesname{List of Examples}
\newlistof{listofexample}{loe}{\listexamplesname}
\newlistentry[chapter]{examplecounter}{loe}{0}
\newcommand{\edescription}[1]{%
\refstepcounter{examplecounter}
\par\noindent\textbf{Example \theexamplecounter~(#1).}
\addcontentsline{loe}{figure}{\protect\numberline{\theexamplecounter}#1}
}
\newenvironment{example}[1][]{\edescription{#1}}{\qed\par}

\newcounter{propcounter}[chapter]
\newenvironment{proposition}[1][]{\refstepcounter{propcounter} \noindent  {\bfseries Proposition \arabic{propcounter}  (#1).}}{\qed}

\begin{document}

\listofexample
\bigskip

\begin{example}[Big Idea]
Some big idea.
\end{example}

\begin{proposition}[Medium Idea]
Something hard.
\end{proposition}

\begin{example}[Small Idea]
Some small idea.
\end{example}

\end{document}

The result:

enter image description here

3
  • Thanks! So obvious. With that change, I still find vertical spacing between lines to be too great, but I will sort that out with some vspace commands.
    – xbot
    Commented Oct 1, 2015 at 20:15
  • I would up vote the answer but don't have enough points to do so...
    – xbot
    Commented Oct 1, 2015 at 20:16
  • @xbot You're welcome. Don't worry; you can up-vote it later ;) Commented Oct 1, 2015 at 20:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .