5

Given the following MWE:

\documentclass[english]{scrartcl}

\usepackage{syntax}

\begin{document}

\begin{figure}
  \begin{grammar}
    <example> ::= \[[ \lit{def} <identifier> \lit{=} <expr> \]]
  \end{grammar}
  \caption{an example grammar}
  \label{grm:example}
\end{figure}

\listoffigures

\end{document}

This draws me a nice (partial) definition of the non-terminal “example” in a fictive language and I can see it in the list of figures at the end. But in the real document there are also other figures, which should be in another listofwhatever.

So how can I define such environments by myself with the corresponding counters and lists?

edit

If it matters: I am using xelatex 3.1415926-2.5-0.9999.3-2013060708 (TeX Live 2013).

6

This functionality is offered by a number of packages: float, newfloat, and trivfloat for new floating objects.

Here's an example using newfloat (refer to the package documentation for the customization options it offers):

\documentclass[english]{scrartcl}
\usepackage{syntax}
\usepackage{newfloat}

\DeclareFloatingEnvironment{example}

\begin{document}

\begin{example}
  \begin{grammar}
    <example> ::= \[[ \lit{def} <identifier> \lit{=} <expr> \]]
  \end{grammar}
  \caption{an example grammar}
  \label{grm:example}
\end{example}

\listofexamples

\end{document}

enter image description here

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.