I am new here and I have a question about defining a glossary style.
I would like to have:
- A glossary style with 3 columns
- In the first should be the symbols, in the second the descriptions and in the third the pagenumbers
My problem is: I would like to define the width of each column manually (the width of the hole table should be as wide as \textwidth). Some symbols are abbreviations for longer terms and therefore I would like to link the page from the first use in the third column but other symbols are more or less familiar and so there shouldn't be a pagelink in the third column. More precisly, if I call a glossaryentry with \gls{..} in the text then there should be a pagelink in the third column of the glossary. The other glossaryentries should only appear with symbol and discription without a pagenumber. I don't call them seperately.
After a long research, I found similar problems but the solution doesn't work fine for me. Here is what I have now :
\documentclass{article}
\usepackage{amsfonts}
\newcommand*{\Z}{\mathbb{Z}}
\newcommand*{\Q}{\mathbb{Q}}
\usepackage{lipsum} % to have some dummy text, and therefore larger page numbers
\usepackage[colorlinks]{hyperref}
\usepackage{glossaries}
\usepackage{glossary-longragged}
\glsdisablehyper %Entfernt links von den Symbolen
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newglossarystyle{tabx3col}{%
% put the glossary in a longtable environment:
\renewenvironment{theglossary}%
{\renewcommand{\arraystretch}{1.5}
\begin{longtable}{@{}p{0.2\textwidth}@{}p{0.7\textwidth}@{}>{\raggedleft}p{0.1\textwidth}@{}}}%
{\end{longtable}}%
% Set the table's header:
\renewcommand*{\glossaryheader}{}%
% No heading between groups:
\renewcommand*{\glsgroupheading}[1]{}%
% Main (level 0) entries displayed in a row:
\renewcommand*{\glossaryentryfield}[5]{%
\glstarget{##1}{##2}% Name
& ##3% Description
& ##5% Page list
\\% end of row
}%
}
\newcommand*{\glsgobblenumber}[1]{}
% \renewcommand*{\glsgobblenumber}[1]{#1}% uncomment for testing
\makeatletter
%% lockstep's code
\newcommand*{\glsaddnp}[2][]{%
\glsdoifexists{#2}%
{
% \def\@glsnumberformat{glsnumberformat}% DELETED
\def\@glsnumberformat{glsgobblenumber}% NEW
\edef\@gls@counter{\csname glo@#2@counter\endcsname}%
\setkeys{glossadd}{#1}%
\@gls@saveentrycounter
\@do@wrglossary{#2}%
}%
}
%% new code; modified \glsaddall
\renewcommand{\glsaddallunused}[1][]{%
\edef\@glo@type{\@glo@types}%
\setkeys{glossadd}{#1}%
\forallglsentries[\@glo@type]{\@glo@entry}{%
\ifglsused{\@glo@entry}{}{%
\glsaddnp[#1]{\@glo@entry}}}%
}
\makeatother
\newglossaryentry{integers}{name=\ensuremath{\Z},
description={the ring of integers}, sort=Z}
\newglossaryentry{rationals}{name=\ensuremath{\Q},
description={the field of rational numbers}, sort=Q, nonumberlist}
\newglossaryentry{vector-space}{name=\ensuremath{V},
description={a vector space}, sort=V}
\makeglossaries
\begin{document}
A vector space \gls{vector-space} \ldots
\lipsum[1-10]
\glsaddallunused
\printglossary[style=tabx3col]
\end{document}
There seams to be problem when there is no symbol call with \gls{..} in the text. The error message is:
! Extra alignment tab has been changed to \cr.
\glossaryentryfield
is obsolete. What version ofglossaries
do you have installed? (It will be in the.log
file.)\glossentryfield
was made obsolete in v4.0). There are some bug fixes in the newer versions but v4.29 should be okay for this (at least in terms of answering it).