I want a document where I have different sections, and each section has many references to other sections, like

See \nameref{b}

See \nameref{a}

See \nameref{a}

Is it possible to createa a function, or maybe there's already a module for it which I didn't find, to make something like

See \nameref{a}

Resulting in something like:


See b

A has been referenced on in a (page n) and c (page m)


b has been referenced on in a (page suchandsuch)

See a


See a

... or some thing similiar.

  • see enumitem package. – Zarko Apr 13 at 16:57

You can use the mmxref package for this (yes, it was written for this answer). Thanks to egreg who kindly provided a good starting point for the code.

Download mmxref.sty from here1 and put it in the same directory as your document, or somewhere in your TEXINPUTS (in the latter case, you may have to refresh a database of available files for TeX: this is the usual routine for manually-installed packages). The mmxref page contains further usage instructions.

Your document can then look like this (let's call it doc.tex). Note that in general, two compilations are necessary to have everything in order (as usual with references that go through the .aux file; the mmxref package warns you if more compilations are needed).


% The default prefix for labels created by mmxref is “mmxref-”. You can easily
% change this prefix:
%\mmxSetLabelPrefix{prefix of your choice (possibly empty)}

\setlength{\parskip}{2pt plus 0.5pt minus 0.2pt}

\part{A Great Part}
\mmxlabel{a great part}

Foo bar in the part. All that.

\mmxInsertBackReferences[\emph{This fascinating part was referenced}]{a great

\chapter{The First Chapter}
\mmxlabel{first chapter}

See~\mmxautoref{another section}, \mmxautoref{section in 2nd chapter},
and~\mmxautoref{a subsection}.

\mmxInsertBackReferences{first chapter}

\section{A Section}
\mmxlabel{a section}

% If the preceding \mmxlabel were to be omitted, the backreference generated
% by the following \mmxautoref command would point to the last \mmxlabel
% issued, which corresponds to the first chapter.
Some text. See~\mmxautoref{a great part}.

\section{Another Section}
\mmxlabel{another section}

See~\mmxautoref{first chapter}.

\mmxInsertBackReferences{another section}

\subsection{A Subsection}
\mmxlabel{a subsection}
See~\mmxautoref{another section}, \mmxautoref{a subsection},
and~\mmxautoref{first chapter}.

%\mmxInsertBackReferences[This marvelous place]{a subsection}
\mmxInsertBackReferences{a subsection}

\chapter{The Second Chapter}
\mmxlabel{second chapter}

\mmxInsertBackReferences{second chapter}

\section{A Section In The Second Chapter}
\mmxlabel{section in 2nd chapter} See~\mmxautoref{a subsection},
\mmxautoref{another section} and also \mmxautoref{third chapter}, which starts
on page~\mmxpageref{third chapter}.

\mmxInsertBackReferences{section in 2nd chapter}

\chapter{The Third Chapter}
\mmxlabel{third chapter}

Text in the third chapter.

\section{And Now For Something Completely Different}
\mmxlabel{Something Completely Different}

Let's point to \mmxautoref[third chapter]{second chapter}, but in way that
makes the back-reference be \mmxautoref{third chapter} instead of
\mmxautoref{Something Completely Different}. That's what the optional argument
of \verb|\mmxref| and \verb|\mmxautoref| is for.

On page 1:

Page 1 in English

On page 2:

Page 2 in English

On page 3:

Page 3 in English

On page 4:

Page 4 in English

On page 5:

Page 5 in English

You can redefine the following commands to change the wording (possibly the language) of inserted phrases. For instance, you can get \mmxref to speak French by adding this between \usepackage{mmxref} and \begin{document}:

\usepackage{xparse}           % only necessary if you use it for customization
\RenewDocumentCommand \mmxSeparatorBetweenTwo { }
  { ~et~ }

\RenewDocumentCommand \mmxSeparatorBetweenMoreThanTwo { }
  { ,~ }

\RenewDocumentCommand \mmxSeparatorBetweenFinalTwo { }
  { ~et~ }

\RenewDocumentCommand \mmxFormatSimpleRef { m }
    \str_case:nnF {#1}
        { part } { partie }
        { chapter } { chapitre }
        { section } { section }
        { subsection } { section } % intentional: “subsection” is too ugly here
        { subsubsection } { section } % ditto
        { paragraph } { paragraphe }
        { subparagraph } { paragraphe } % ditto
        \msg_error:nnn { mmxref } { main/undefined-ref-format-for-counter } {#1}

\RenewDocumentCommand \mmxFormatStartOfInsertionPhrase { m }
    \str_case:nnF {#1}
        { part } { Cette~partie~a~été~référencée }
        { chapter } { Ce~chapitre~a~été~référencé }
        { section } { Cette~section~a~été~référencée }
        % Intentional: “subsection” is too ugly here
        { subsection } { Cette~section~a~été~référencée }
        { subsubsection } { Cette~section~a~été~référencée } % ditto
        { paragraph } { Ce~paragraphe~a~été~référencé }
        { subparagraph } { Ce~paragraphe~a~été~référencé } % ditto
        \msg_error:nnn { mmxref } { main/undefined-ref-format-for-counter } {#1}

\RenewDocumentCommand \mmxFormatBackRef { m m m }
    \str_case:nnF {#1}
        { part } { à~la~partie \nobreakspace #2~page \nobreakspace #3 }
        { chapter } { au~chapitre \nobreakspace #2~page \nobreakspace #3 }
        { section } { à~la~section \nobreakspace #2~page \nobreakspace #3 }
        % Intentional: « sous-section » is too ugly here
        { subsection } { à~la~section \nobreakspace #2~page \nobreakspace #3 }
        % Ditto
        { subsubsection } { à~la~section \nobreakspace #2~page \nobreakspace
        #3 }
        { paragraph } { au~paragraphe \nobreakspace #2~page \nobreakspace #3 }
        % Ditto
        { subparagraph } { au~paragraphe \nobreakspace #2~
                           page \nobreakspace #3 }
        \msg_error:nnn { mmxref } { main/undefined-ref-format-for-counter } {#1}

Here is what this would do to page 3 of the previous doc.tex file (the bits that remain in English were entered as is in doc.tex, this is just an example!):

Page 3 in French


  1. If you don't know how to download mmxref.sty, click on the mmxref.sty file name on the mmxref page, then on the Raw button and use some menu item like File → Save in your web browser. (Another way is to clone the Git repository, but you need Git for that.)

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.