From b75d3d1aa2c240b7e7a184b92f83ba52409a1ab0 Mon Sep 17 00:00:00 2001 From: Alex Povel Date: Mon, 7 Dec 2020 15:46:22 +0100 Subject: [PATCH] Provide option to suppress glossaries page list printing A long overdue feature anyway --- chapters/frontmatter.tex | 39 ++++++++ cookbook.cls | 204 +++++++++++++++++++++++++++------------ 2 files changed, 179 insertions(+), 64 deletions(-) diff --git a/chapters/frontmatter.tex b/chapters/frontmatter.tex index e63110e..ef6375f 100644 --- a/chapters/frontmatter.tex +++ b/chapters/frontmatter.tex @@ -77,6 +77,45 @@ style=long3colheader, ] +\addchap{\glossaryname{} without page lists}% + +\emph{ + The following styles do not contain page lists of the entries' occurrences, + leading to a cleaner, more concise look. + Refer to the source code on how to achieve this (which options and styles to use). +} + +% For all sorts of styles, see also +% https://www.dickimaw-books.com/gallery/glossaries-styles/ + +% Simply pass the `nonumberlist` parameter where desired/required: +\printunsrtglossary[ + type=symbols, + style=symbunitlong, + nonumberlist, +] +\printunsrtglossary[ + type=numbers, + style=numberlong, + nonumberlist, +] +\printunsrtglossary[ + type=subscripts, + style=mcolalttree, + nonumberlist, +] +\printunsrtglossary[ + type=abbreviations, + % If `nonumberlist` is passed, the `long3colheader` style simply leaves the + % corresponding table cells *empty* (leading to an entirely empty column), but does + % not actually remove the column. So use a different, but equivalent style + % altogether: + style=longheader, + % The `longheader` style prints the page list behind the description, just not in a + % separate column. So also explicitly suppress the generation of that: + nonumberlist, +] + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \listoffigures% diff --git a/cookbook.cls b/cookbook.cls index 4f31df5..773b532 100644 --- a/cookbook.cls +++ b/cookbook.cls @@ -1961,91 +1961,167 @@ \newcommand*{\glshdrfont}[1]{\textbf{#1}} % Font for gls table heads - % To print symbols: + \newglossarystyle{custom-base}{ + % A simple style subsequent, custom-defined styles will have in common. + \setglossarystyle{long-name-desc-loc} + \renewcommand*{\glossaryheader}{}% Remove it + } + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Symbols +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + % Standard base style, without page list \newglossarystyle{symbunitlong}{% https://tex.stackexchange.com/a/269571/120853 % Base new style on existing one. This is quite important, since it implements % all otherwise missing but maybe required commands, % like \glsgroupskip if --group option is used for bib2gls - \setglossarystyle{long-name-desc-loc} + \setglossarystyle{custom-base} - \renewcommand*{\glossaryheader}{}% Remove it + \renewcommand*{\glsgroupskip}{\addlinespace\addlinespace}% - \renewenvironment{theglossary}{% - % Use Longtabu over longtable, the latter caused inexplicable issues with - % 'Column widths have changed, rerun Latex' - \begin{longtabu}{% - r% - p{0.5\linewidth}% - p{\glspagelistwidth}% - l% + % This command is taken from the source code, I hope I am not abusing it: + \ifglsnonumberlist + % User requested NO location list/number list/page list to be printed, so + % remove those columns. + \renewenvironment{theglossary}{% + % Use Longtabu over longtable, the latter caused inexplicable issues with + % 'Column widths have changed, rerun Latex' + \begin{longtabu}{% + r% + p{0.5\linewidth}% + l% + }% + }{% + \end{longtabu}% }% - }{% - \end{longtabu}% - }% - \renewcommand*{\glsgroupskip}{\addlinespace\addlinespace}% + \renewcommand*{\glsgroupheading}[1]{% + \glshdrfont{\glsgetgrouptitle{##1}} & + \glshdrfont{\descriptionname} & + \glshdrfont{\TransUnit{}} + \tabularnewline + }% - \renewcommand*{\glsgroupheading}[1]{% - \glshdrfont{\glsgetgrouptitle{##1}} & - \glshdrfont{\descriptionname} & - \glshdrfont{\pagelistname} & - \glshdrfont{\TransUnit{}} - \tabularnewline - }% + \renewcommand*{\glossentry}[2]{% + \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} & + \glossentrydesc{##1}\glspostdescription & + % Use glsentryunit to access entry, NOT glsunit, + % https://tex.stackexchange.com/a/281772/120853: + \glsentryunit{##1} + \tabularnewline + } + \else + \renewenvironment{theglossary}{% Redefine this, overwriting the base style + \begin{longtabu}{% + r% + p{0.5\linewidth}% + p{\glspagelistwidth}% + l% + }% + }{% + \end{longtabu}% + }% - \renewcommand*{\glossentry}[2]{% - \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} & - \glossentrydesc{##1}\glspostdescription & - ##2 & - % Use glsentryunit to access entry, NOT glsunit, - % https://tex.stackexchange.com/a/281772/120853: - \glsentryunit{##1} - \tabularnewline - } + \renewcommand*{\glsgroupheading}[1]{% + \glshdrfont{\glsgetgrouptitle{##1}} & + \glshdrfont{\descriptionname} & + \glshdrfont{\pagelistname} & + \glshdrfont{\TransUnit{}} + \tabularnewline + }% + + \renewcommand*{\glossentry}[2]{% + \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} & + \glossentrydesc{##1}\glspostdescription & + ##2 & + % Use glsentryunit to access entry, NOT glsunit, + % https://tex.stackexchange.com/a/281772/120853: + \glsentryunit{##1} + \tabularnewline + } + \fi } - % To print constants, as in physical constants with values and unit: +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Numbers. +% To print constants, as in physical constants with values and unit. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \newglossarystyle{numberlong}{% https://tex.stackexchange.com/a/269571/120853 % Base new style on existing one. This is quite important, since it implements % all otherwise missing but maybe required commands, like % \glsgroupskip if --group option is used for bib2gls - \setglossarystyle{long-name-desc-loc} + \setglossarystyle{custom-base} + + % This command is taken from the source code, I hope I am not abusing it: + \ifglsnonumberlist + % User requested NO location list/number list/page list to be printed, so + % remove those columns. + \renewenvironment{theglossary}{ + % Use Longtabu over longtable, the latter caused inexplicable issues with + % 'Column widths have changed, rerun Latex' + \begin{longtabu}{% + r% + p{0.3\linewidth}% + r% + @{\;}% + l% + }% + }{% + \end{longtabu}% + }% - \renewcommand*{\glossaryheader}{}% Remove it + \renewcommand*{\glossaryheader}[1]{% + \glshdrfont{\symbolname} & + \glshdrfont{\descriptionname} & + \multicolumn{2}{l}{{\glshdrfont{\TransPhysicalQuantity{}}}} + \tabularnewline + }% - \renewenvironment{theglossary}{ - % Use Longtabu over longtable, the latter caused inexplicable issues with - % 'Column widths have changed, rerun Latex' - \begin{longtabu}{% - r% - p{0.3\linewidth}% - r% - @{\;}% - l% - p{\glspagelistwidth}% + \renewcommand*{\glossentry}[2]{% + \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} & + \glossentrydesc{##1}\glspostdescription & + \glsentryvalue{##1} & + % Use glsentryunit to access entry, NOT glsunit, + % https://tex.stackexchange.com/a/281772/120853: + \glsentryunit{##1} + \tabularnewline + }% + \else + \renewenvironment{theglossary}{ + % Use Longtabu over longtable, the latter caused inexplicable issues with + % 'Column widths have changed, rerun Latex' + \begin{longtabu}{% + r% + p{0.3\linewidth}% + r% + @{\;}% + l% + p{\glspagelistwidth}% + }% + }{% + \end{longtabu}% }% - }{% - \end{longtabu}% - }% - \renewcommand*{\glossaryheader}[1]{% - \glshdrfont{\symbolname} & - \glshdrfont{\descriptionname} & - \multicolumn{2}{l}{{\glshdrfont{\TransPhysicalQuantity{}}}} & - \glshdrfont{\pagelistname} - \tabularnewline - }% + \renewcommand*{\glossaryheader}[1]{% + \glshdrfont{\symbolname} & + \glshdrfont{\descriptionname} & + \multicolumn{2}{l}{{\glshdrfont{\TransPhysicalQuantity{}}}} & + \glshdrfont{\pagelistname} + \tabularnewline + }% - \renewcommand*{\glossentry}[2]{% - \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} & - \glossentrydesc{##1}\glspostdescription & - \glsentryvalue{##1} & - % Use glsentryunit to access entry, NOT glsunit, - % https://tex.stackexchange.com/a/281772/120853: - \glsentryunit{##1} & - ##2 - \tabularnewline - }% + \renewcommand*{\glossentry}[2]{% + \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} & + \glossentrydesc{##1}\glspostdescription & + \glsentryvalue{##1} & + % Use glsentryunit to access entry, NOT glsunit, + % https://tex.stackexchange.com/a/281772/120853: + \glsentryunit{##1} & + ##2 + \tabularnewline + }% + \fi } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%