0

In the paper I am writing, I need:

  1. part of the captions 'Example 1' instead of 'Fig.1' as the caption of some pictures (Not all the figures, so \usepackage[figurename=Example.]{caption} is not suitbale). This requirement is similar to Change the caption name of a specific figure.

  2. At the same time, I need both the List of Figures and List of Examples. I found the way to insert 'List of Anything' such as List of Anything.

But how could I be able to combine the two requirements: 1. Change few particular caption to Example; 2. Insert a List of Example after contents.

Thank you very much for any suggestions.

--- For the comments from Peter ---

I cannot include the code in the comment as it is too long. Simply replace the "memoir" with "book" then you will see the problem. I have no idea why it is so difficult to understand what I mean (below code). BTW, thank you for your previous answer. Goodbye from a KYM (Kind Young Man).

\documentclass{book}
\usepackage{lipsum}
\usepackage{graphicx}
\newlistof{listofexamples}{loe}{List of Examples}
\newfloat{example}{loe}{Example}

\begin{doument}
\frontmatter
\tableofcontents
\listoffigures
\listofexamples

\mainmatter
\chapter{First}
\lipsum[1]

\begin{figure}
\centering
 %\includegraphics... for a picture
\caption{A picture}
\end{figure}

\begin{example}
\centering
%\includegraphics... for an illustration
\caption{An illustration}
\end{example}

\end{document}

For others meet the same problem, I find float environment and list of anything might be helpful.

1 Answers1

0

The memoir class (covers the book, report and article classes) lets you do this (set up a new List of... and new float environment).

First for the List of Examples:

\newlistof{listofexamples}{loe}{List of Examples}

which will create a command\listofexamples which when called in the document will produce a heading List of Examples followed by data from an .loe file (just like \listoffigures produces List of Figures followed by data from a .lof file).

Then for your examples create a new Example float (like the Figure float):

\newfloat{example}{loe}{Example}

after which

\begin{example}
% contents of the example
\caption{A caption for the example}
\end{example}

will act like a Figure but with its own caption style and numbering.

Here is a fuller example (but remove any typos):

\documentclass{memoir}
\usepackage{lipsum}
\usepackage{graphicx}
\newlistof{listofexamples}{loe}{List of Examples}
\newfloat{example}{loe}{Example}

\begin{doument}
\frontmatter
\tableofcontents
\listoffigures
\listofexamples

\mainmatter
\chapter{First}
\lipsum[1]

\begin{figure}
\centering
 %\includegraphics... for a picture
\caption{A picture}
\end{figure}

\begin{example}
\centering
%\includegraphics... for an illustration
\caption{An illustration}
\end{example}

\end{document}

For more detailed information see the documentation (> texdoc memoir sections 9.3 and 10.1)

On the other hand there might be a package that lets you do something similar.

Peter Wilson
  • 28,066
  • thank you for your answer. I am not sure if \includegraphics can be used in the defined 'example' environment since I want to insert 'figure format' example only with different caption 'Example.' instead of 'Fig.'. It would be better if you could an example code. Thank you in advance. – Raymond Jun 24 '19 at 06:41
  • @Raymond Did you try an \includegraphics in the example environment? \includegraphics can be used anywhere, not just in a figure environment. – Peter Wilson Jun 25 '19 at 15:51
  • Thank you for your reply. Your example works, however, it seems these are based on the document class "memoir". Since the document I wrote is based on the book class, and it cause errors when I change the class from "book" to "memoir". – Raymond Jun 29 '19 at 07:22
  • @Raymond I said that it worked in the memoir class. You did not say what class you were using. I have no idea why you are getting errors moving from the book to memoir class as you have not bothered to show any code. Goodbye from a GOM (Grumpy Old Man). – Peter Wilson Jun 30 '19 at 18:19