I've created my own environment example, similar to theorem. Now I want to generate a list of examples, similar to list of tables or list of figures. How can I achieve this?
4 Answers
The package thmtools by U. Schwarz is what you need:
\usepackage{thmtools} \renewcommand{\listoftheoremname}{List of examples} ... \begin{document} ... \listoftheorems[ignoreall,show={example}] For a footnote in a theorem label, you can do with the usual trick of \footnotemark and \footnotetext, but another trick is needed in order to avoid the footnote mark in the list of theorems:
\usepackage{thmtools} \declaretheorem[name=Example]{example} \renewcommand{\listoftheoremname}{List of examples} ... \begin{document} ... \begingroup \let\footnotemark\relax \listoftheorems[ignoreall,show={example}] \endgroup ... \begin{example}[name=Nice example\protect\footnotemark] \footnotetext{Due to E. X. Ample}% This is a very nice example \end{example} You don't want the footnote mark in the list, do you? :)
--- Additional formatting ---
The macro responsible for writing the entry in the loe file that is read for typesetting the list of examples is \ll@example. You can obtain a list showing only the names of the example by saying, just after the relevant \declaretheorem
\makeatletter \def\ll@example{% \protect\numberline{\csname the\thmt@envname\endcsname}% \ifx\@empty\thmt@shortoptarg \thmt@thmname \else \thmt@shortoptarg \fi} \makeatother - Why I can't put
footnotein theorem note when I usethmtools?jesper– jesper2011-04-24 13:38:28 +00:00Commented Apr 24, 2011 at 13:38 - In a minimal example I built, footnotes are OK.egreg– egreg2011-04-24 13:55:52 +00:00Commented Apr 24, 2011 at 13:55
- An how can I change default style of list of theorems? I want to change entries format... If I can't do that I will be very angry that I spend all my day..jesper– jesper2011-04-24 17:14:48 +00:00Commented Apr 24, 2011 at 17:14
- To be more specific:
Example (Example of somthing)have to beExample of seomthingjesper– jesper2011-04-24 17:20:54 +00:00Commented Apr 24, 2011 at 17:20 - This doesn't really answer the original question. It is asked for a list of a custom
environment, nottheorem.andz– andz2018-03-02 02:12:02 +00:00Commented Mar 2, 2018 at 2:12
There are several package you can use for this purpose:
caption using
\DeclareCaptionTypefloat and its commands
\newfloatand\listoffloatrow and
\DeclareNewFloatTypetocloft, a comprehensive package for customizing such lists, providing
\newlistofand related commands
If you follow these links, you can find the documentation. Just look for the mentioned commands. Check out further features which may help deciding which package you might use.
- They are too complicated. I just want to get list of examples created by
\newtheorem{example}. I've triedtocloftand I can't get such list.jesper– jesper2011-04-24 13:56:35 +00:00Commented Apr 24, 2011 at 13:56 - 1There is also the
tocbasicpackage: tex.stackexchange.com/a/191358/9424user9424– user94242019-08-15 00:25:08 +00:00Commented Aug 15, 2019 at 0:25
Why don't you use float as already suggested? It's similar to figures and tables and well documented:
Add this before \begin{document}:
\usepackage{float} \floatstyle{plain} \newfloat{example}{thp}{loc}[chapter] \floatname{example}{Example} Add this to where you want the list:
\listof{example}{List of examples} Add this if you also want this in your tableofcontents:
\addcontentsline{toc}{chapter}{List of examples} And of course define a small example:
\begin{example} This is a small example. \caption[Small example]{Small example - you can add links and other stuff here} \label{example:foo} \end{example} And reference it:
As you can see in Example \ref{example:foo}, ... My solution to this below. By adding a [] after \begin{example}, you can add a label in order to reference to the example later on.
\documentclass{scrartcl} \usepackage{tocloft, lipsum} \usepackage[framemethod=tikz]{mdframed} %%%%%%%%%%%%%%%%%%%%%%%%%%% % Define the List %%%%%%%%%%%%%%%%%%%%%%%%%%% \newcommand{\listexamplename}{List of Examples} % Set the name of the list \newlistof{examples}{exp}{\listexamplename} % First bracket is \listof{what's in here}, second is the document that will be created, NameOfYourDoc.exp in this case. Third is title of the list, what you define in above \newcommand. \newcommand{\examples}[1]{% How to set a counter for. \refstepcounter{examples} %increase the counter \par\noindent\textbf{Example \theexamples: #1} %The text that will be used when \examples is used. \addcontentsline{exp}{examples} % Add the line to the .exp file {\protect\numberline{\theexamples}#1}\par} %I do not understand this, maybe somebody can explain. \setlength{\cftexamplesindent}{1.5em} %Indent of the example #. Same as \listoffigures \setlength{\cftexamplesnumwidth}{2.3em} %Indent of the examples title. Same as \listoffigures %%%%%%%%%%%%%%%%%%%%%%%%%%% % Define the Frame %%%%%%%%%%%%%%%%%%%%%%%%%%% \mdfsetup{frametitlealignment=\center} \newmdenv[linecolor=white, roundcorner=10pt, backgroundcolor=gray!50, frametitleaboveskip=10pt, skipbelow=5pt, innerbottommargin=12pt ]{example} \makeatletter \let\orig@example=\example %This part is used to define the env with and without label \DeclareRobustCommand\example{\@ifnextchar[{\@@example}{\@example}} %It scans for [ and then decides what to use. \def\@@example[#1]#2{ %Case with label \orig@example[frametitle=\examples{{#2}}\label{#1}] } \def\@example#1{ %Case without label \orig@example[frametitle=\examples{{#1}}] } \makeatother \begin{document} You can reference to an example, see example \ref{exp:label}, or not. You can also use the list outside by using \examples{Title}. \begin{example}[exp:label]{Title of Example with label} \lipsum[1] \end{example} \begin{example}{Title of Example without label} \lipsum[1] \end{example} \listofexamples \end{document} Which leads to
