1

I have a number of "design principle" statements that I'm introducing throughout the document. I'm currently using a custom theorem environment defined using amsthm for them, but I'm happy to use something else if necessary.

The result is a lot of bits throughout the document that look like:

\begin{principle}
It should do stuff.
\end{principle}

Which would then show up as "Principle 1: It should do stuff"

I would like to create a page at the end of the document which restates all of these principles in order (with links to them in context ideally), so the resulting page would look like:

Principle 1: It should do stuff.

Principle 2: And it should do it well

Principle 3: etc.

I've looked into using thmtools for this, but if it supports this I haven't been able to figure out how: listoftheorems will give me an index page for all theorems, but not show their contents, and restattheorem will allow me to achieve the desired effect for each individual entry but not for every entry in order.

2

What you're describing sounds kind like a glossary to me, so here's an attempt using the glossaries package. (Disclaimer: I really don't know much about glossaries in LaTeX).

Create the file example.tex below, then compile with:

>> pdflatex example.tex
>> makeglossaries example
>> pdflatex example.tex

(My text editor uses latexmk, which did all of that for me. But that's the command line version. I'm guessing that makeglossaries comes with most TeX distributions.)

Contents of example.tex:

\documentclass{article}

\usepackage[
    colorlinks=true,
    linkcolor=blue
]{hyperref}
\usepackage{amsthm} % for styling
\usepackage{environ} % allows access to environment body during definition
\usepackage[
    sanitize={
        description=false,
        sort=false
    },
    numberedsection
]{glossaries}

\theoremstyle{definition}
\newtheorem{principleInternal}{Principle}

\makeglossary

% Usage:
% \begin{principle}{labelName}
% content
% \end{principle}
% NOTE: labelName is required and should be unique---it's used
% to label the internal principleDefinition environment and is
% used as the glossary keys.
\NewEnviron{principle}[1]{
    \newglossaryentry{#1}{%
        sort={\theprincipleInternal},
        name={Principle \ref{#1}},
        description={\BODY}
    }
    \glsadd{#1} % adds glossary entry printed list. 
    \begin{principleInternal}\label{#1}
        \BODY
    \end{principleInternal}
}
\renewcommand*{\glstextformat}[1]{p #1}

\begin{document}

\begin{principle}{cats}
    Cats are good, $\int f(x) dx$
\end{principle}

\newpage

\begin{principle}{dogs}
    Dogs are good, $\sqrt{121}$
\end{principle}

\begin{principle}{demons}
    Demons are bad, OK.
\end{principle}


\printglossary[title=Principles]

\end{document}

If the principle glossary seems not to be updating correctly, try deleting the auxiliary files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.