5

I’m writing a document in the latex and it contains some BNF grammar noations in several places of the documents. (I used verbatim package in order to write these BNF grammar notations)

Now I want to add a new section to the document that shows name of all grammar notation and their page numbers. This should be similar to “List of Figures” page.

I’m new to Latex and your help will be very helpful for me.

Thanks

4

Use the tocloft package. For a short introduction see for example: http://texblog.org/2008/07/13/define-your-own-list-of/

| improve this answer | |
  • If you need more specific advice, you should give a MWE. Otherwise "accepting" an answer is the proper way to show your content. – bodo Jun 25 '12 at 4:26
5

Example for the tocloft package:

\documentclass{report}

\usepackage{tocloft}
\usepackage{hyperref}

\usepackage[english]{babel}
\hypersetup{colorlinks=true}

\newcommand{\listexamplename}{List of mycustomfiction}
\newlistof{mycustomfiction}{mcf}{\listexamplename}

% Reset section numbering between unnumbered chapters
% https://tex.stackexchange.com/questions/71162/reset-section-numbering-between
\newcommand{\mycustomfiction}[1]
{%
    \refstepcounter{mycustomfiction}
    \addcontentsline{mcf}{mycustomfiction}
    {\protect\numberline{\themycustomfiction}#1}\par
}

\begin{document}

    % How to remove double “Contents” heading generated by memoir?
    % https://tex.stackexchange.com/questions/47225/how-to-remove-double-contents-heading-generated-by-memoir
    \tableofcontents
    \newpage
    \listofmycustomfiction

    \chapter{Two mycustomfiction}
    \mycustomfiction{Your first example}
    \label{1st_ex}
    Your first example

    \mycustomfiction{Your second example}
    \label{2nd_ex}
    Your second example

    \chapter{One example}
    \mycustomfiction{Your third example. (See example \ref{1st_ex} and \ref{2nd_ex})}
    Your third example. (See example \ref{1st_ex} and \ref{2nd_ex})

\end{document}

enter image description here

For the memoir package you need to build more things using the memoir's class emulation of tocloft. See the question for memoir's example: Custom list throw LaTeX Error: Command \mycustomfiction already defined?

| improve this answer | |
  • I would like to format each entry in the "List of mycustomfiction" so that it follows this pattern "Figure 1.1 - Caption.......pagenumber" any thoughts on how to attack the issue? – Fredrik Feb 4 at 14:57

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.