I want to have a modified page list (back-references) of my glossary, list of acronyms and symbols. With \glsaddallunused
at the end of the document, I add all entries to the lists. Because of that, it appears that some entries have no page references and some do have (which is exactly what I want). The page list should be:
- if there are no page numbers, no additional text and no brackets should appear.
- if there is a reference to one page only: "(page #)"
- if there are references to more than one page: "(pages #,#-#,...,# and #)"
I achieved a similar behavior in my bibliography (which I do not understand at all) by doing:
\renewcommand*{\backref}[1]{}
\renewcommand*{\backrefalt}[4]{%
{\footnotesize\mbox{
\ifcase #1%
(Not directly cited)%
\or
(Cited on page #2)%
\else
(#1 cites on pages #2)%
\fi}
}
}
If this is absolutely not possible with glossaries, I would be happy to have:
- if there are no page numbers, no additional text should appear.
- if there is a reference to one or more pages: "(#)"
MWE that does not have a different page list depending on the references:
\documentclass{scrreprt}
\usepackage[backref=page,plainpages=false,pdfpagelabels,colorlinks]{hyperref}
\usepackage[footnote,acronym,toc,hyperfirst]{glossaries}
% acronym style (Nicola Talbot)
\newacronymstyle{ex-footnote}%
{%
\GlsUseAcrEntryDispStyle{footnote}%
}%
{%
\GlsUseAcrStyleDefs{hyperfirst, footnote}%
\renewcommand*{\genacrfullformat}[2]{%
\firstacronymfont{\glsentryshort{##1}}##2%
\expandafter\footnote\expandafter{\expandafter\glsentrylong\expandafter{##1}}%
}%
\renewcommand*{\Genacrfullformat}[2]{%
\firstacronymfont{\Glsentryshort{##1}}##2%
\expandafter\footnote\expandafter{\expandafter\glsentrylong\expandafter{##1}}%
}%
\renewcommand*{\genplacrfullformat}[2]{%
\firstacronymfont{\glsentryshortpl{##1}}##2%
\expandafter\footnote\expandafter{\expandafter\glsentrylongpl\expandafter{##1}}%
}%
\renewcommand*{\Genplacrfullformat}[2]{%
\firstacronymfont{\Glsentryshortpl{##1}}##2%
\expandafter\footnote\expandafter{\expandafter\glsentrylongpl\expandafter{##1}}%
}%
}
\setacronymstyle{ex-footnote}
% glossary stile
\makeatletter
\newglossarystyle{MyGlossaryStyle}{%
% Use longtable with two columns:
\renewenvironment{theglossary}%
{\begin{longtable}[l]{p{.2\textwidth}p{.755\textwidth}}}%
{\end{longtable}}%
% start of the environment:
\renewcommand*{\glossaryheader}{}%
% Main (level 0) entries displayed in a row:
\renewcommand*{\glossaryentryfield}[5]{\hspace{-6pt}%
\glstarget{##1}{##2}%
& ##3\glspostdescription%
\space\footnotesize\mbox{(##5)}\tabularnewline%
}%
% Blank row between groups:
\renewcommand*{\glsgroupskip}{\\}%
}
\glossarystyle{MyGlossaryStyle}
\makeatother
\makeglossaries
% arconyms
\newacronym{D}{D}{Is not used}
\newacronym{DD}{DD}{\glslink{displacement damage}{Displacement Damage}}
\newacronym{DDD}{DDD}{Displacement Damage Dose}
\newacronym{FPGA}{FPGA}{Field-Programmable Gate Array}
% Gloassaries
\newglossaryentry{displacement damage}{
name = {Displacement Damage},
description = {Displacement damage description}
}
\newglossaryentry{displacement damage dose}{
name = {Displacement Damage Dose},
description = {\Gls{DD} dose description}
}
\newglossaryentry{interconnect}{
name = {Interconnect},
description = {The wiring resources in an \gls{FPGA}}
}
\begin{document}
page 1\\
What does \gls{interconnect} mean?
\clearpage
\newpage
page 2\\
What does \gls{interconnect} mean again?\\
\Gls{DDD}, \gls{displacement damage dose} and again \gls{DDD}.\\
\clearpage
\newpage
page 3\\
What does \gls{interconnect} mean again?\\
\Gls{DDD}
\clearpage
\newpage
page 4
\clearpage
\newpage
page 5\\
What does \gls{interconnect} mean again?\\
\Gls{DDD}
\printglossary[type=\acronymtype, title=Abbreviations]
\printglossary[type=main, title=Glossary]
\glsaddallunused
\end{document}
Note1: Since there are cross-references in the MWE, you have to compile with makeglossaries twice, e.g.:
- pdflatex
- makeglossaries
- pdflatex
- makeglossaries
- pdflatex
Note2: A problem in the page list occours, one comma and space is added falsely, see below:
Note3: The 5th argument in \glossaryentryfield
is the page list. It does neither work to check if the list is empty with
\ifx##5\relax
nor
\if\relax\detokenize{##5}\relax
nor
\ifthenelse{\isempty{##5}}
Note4: I don't mind to clean up the code of my glossary style =)
\glossaryentryfield
and how to check if the 5th parameter is empty?