[Tex/LaTex] custom glossaries

glossaries

I would like to change the glossaries settings in order to have " see p. x" rather than just the number of the page where this entry is.

For example if the acronym PC in the page 3 of my document, it will appear in the glossary as
" PC Personal Computer. 3", and I would like " PC Personal Computer. see p. 3"

How can I do that ? I read the user-guide of the glossaries package but I did not find (or understant) something about it.

Here is an example:

\documentclass[onecolumn,twoside,openright,a4paper,11pt]{report}    

\usepackage[utf8]{inputenc}     
\usepackage[T1]{fontenc}        

\usepackage{hyperref}       
\usepackage{makeidx}                % package permettant de créer des index
\usepackage[toc,acronym,xindy,section=section]{glossaries} 
\newglossary[ntg]{notation}{not}{ntn}{Glossaire}
\newglossary[slg]{symbols}{sym}{sbl}{Nomenclature}

 \makeindex             % 
 \makeglossaries        %


 \begin{document}       % 

\newglossaryentry{glscard}{%type=main,
      name=cardinality,
        description={The number of elements in the specified set}}

\printglossary[toctitle=Lexique,type=main]

\newacronym{pc}{PC}{personal computer}


\printglossary[toctitle=Acronyms,type=acronym]


\newglossaryentry{mesh}{type=notation,
    name={Mesh},
    description={maillage},
    sort={m}}

\printglossary[type=notation]

\newglossaryentry{mbb}{type=symbols,    
    name={\ensuremath{ {M} }},
    first={dzq},                        
    firstplural={esfe}
    text={ \uuline{M} },                
    plural={fesfse},                    
    description={matrix},               
    descriptionplural={desfsf},
    sort=m,                             
    see=[see also]{glscard}}                        

\printglossary[type=symbols]

\chapter{Introduction}
\section{ab}

 \gls{pc}; \gls{glscard}; \gls{mbb}; \gls{mesh};

 \end{document}     

Note the cross-reference does not work, I don't understand why.

Best Answer

The displaying of glossaries is controlled by the styles. Then you need declare a new style or edit the macros that used into the styles. The defualt style is list and the part that print the entries in the glossaries is the \glossentry macro.

The list style definition declares the \glossentry macro as (p. 251, glossaries-code.pdf):

\renewcommand*{\glossentry}[2]{%
\item[\glsentryitem{##1}%
\glstarget{##1}{\glossentryname{##1}}]
\glossentrydesc{##1}\glspostdescription\space ##2}%

Then is possible to define a new style based in the list style (p. 179, glossaries-user.pdf), and modify only the \glossentry macro adding the 'see p.' before of page list part (##2). It means:

\newglossarystyle{mylist}{%
\setglossarystyle{list}% base this style on the list style
\renewcommand*{\glossentry}[2]{%
\item[\glsentryitem{##1}%
\glstarget{##1}{\glossentryname{##1}}]
\glossentrydesc{##1}\glspostdescription\space see p.\space ##2}%
}

Finally, it is necessary set the style before of the print glossary

\setglossarystyle{mylist}

The last question about the cross-reference: this works if the newglossaryentry are used in the preamble. I don't know the reason, I think is related to that:

Originally, \newglossaryentry ... could only be used in the preamble.(p. 83, glossaries-user.pdf)

MWE:

\documentclass[onecolumn,twoside,openright,a4paper,11pt]{report}    

\usepackage[utf8]{inputenc}     
\usepackage[T1]{fontenc}        

\usepackage{hyperref}       
\usepackage{makeidx}                % package permettant de créer des index
\usepackage[toc,acronym,xindy,section=section]{glossaries} 

\newglossarystyle{mylist}{%
    \setglossarystyle{list}% base this style on the list style
    \renewcommand*{\glossentry}[2]{%
    \item[\glsentryitem{##1}%
    \glstarget{##1}{\glossentryname{##1}}]
    \glossentrydesc{##1}\glspostdescription\space see p.\space ##2}%
}



\newglossary[ntg]{notation}{not}{ntn}{Glossaire}
\newglossary[slg]{symbols}{sym}{sbl}{Nomenclature}

 \makeindex             % 
 \makeglossaries        %

\newglossaryentry{glscard}{%type=main,
      name=cardinality,
        description={The number of elements in the specified set}}

\newglossaryentry{mesh}{type=notation,
    name={Mesh},
    description={maillage},
    sort={m}}

\newglossaryentry{mbb}{type=symbols,    
    name={\ensuremath{ {M} }},
    first={dzq},                        
    firstplural={esfe}
    text={ \uuline{M} },                
    plural={fesfse},                    
    description={matrix},               
    descriptionplural={desfsf},
    sort=m,                             
    see=[see also]{glscard}} 

 \begin{document}       % 

\setglossarystyle{mylist}    
\printglossary[toctitle=Lexique,type=main]
\newacronym{pc}{PC}{personal computer}   
\printglossary[toctitle=Acronyms,type=acronym]
\printglossary[type=notation]



\printglossary[type=symbols]

\chapter{Introduction}
\section{ab}

 \gls{pc}; \gls{glscard}; \gls{mbb}; \gls{mesh};

 \end{document} 
Related Question