4

I would like to have "subsections" in my glossary, or simply two glossaries one after the other. However, I always get an empty page (or, because I am using twoside & openright, even two!) between the glossaries.

I found the following topic

Remove Page Break Before Glossary

where the short version is (I think) that any "chapter" based class will introduce a clearpage, which I should be able to remove using

\renewcommand*{\glsclearpage}{}

That does not work for me though, or I am not calling it correctly.

I created the following mini-example:

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

% Include Glossary Package
\usepackage[style=alttree,nonumberlist,acronym]{glossaries}
\glssetwidest{ABCD}% widest name
\renewcommand*{\glsclearpage}{}

% Create Glossaries
\newglossary{type1}{gls1}{glo1}{Glossary 1}
\newglossary{type2}{gls2}{glo2}{Glossary 2}

% Generate Glossary Entries
\newglossaryentry{Entry1}{type = type1, name = $aaaa$, description = Position}
\newglossaryentry{Entry2}{type = type1, name = $bbbb$, description = Velocity}
\newglossaryentry{Entry3}{type = type2, name = $cccc$, description = Position}
\newglossaryentry{Entry4}{type = type2, name = $dddd$, description = Velocity}

% Generate Glossaries
\makeglossaries


\begin{document}

% Print Glossaries
\glsaddall
\printglossary[type=type1]
\printglossary[type=type2]

\end{document} 

What am I doing wrong?

Thanks a lot! Cheers


EDIT, SOLUTION: Using the suggestions below, this is how I achieved to have a main glossary chapter with some specific glossary "sections".

\documentclass[11pt,a4paper]{scrreprt}

% Include Glossary Package
\usepackage[toc,style=alttree,nonumberlist,acronym,section=section]{glossaries}
\glssetwidest{ABCD}% widest name[![enter image description here][2]][2]

% Create Glossaries
\newglossary{type1}{gls1}{glo1}{Accronyms}
\newglossary{type2}{gls2}{glo2}{Nomenclature}

% Generate Glossary Entries
\newglossaryentry{Entry1}{type = type1, name = $aaaa$, description = Position}
\newglossaryentry{Entry2}{type = type1, name = $bbbb$, description = Velocity}
\newglossaryentry{Entry3}{type = type2, name = $cccc$, description = Position}
\newglossaryentry{Entry4}{type = type2, name = $dddd$, description = Velocity}

% Generate Glossaries
\makeglossaries
\glsaddall

\begin{document}

\tableofcontents

% First, start main glossary chapter
\addchap{My Glossaries}
Some introductory text if desired.
% Now print actual glossaries
\printglossary[type=type1]
\printglossary[type=type2]
\bigskip\noindent
Some concluding text if desired.

\end{document} 

Output

(I only removed the "twoside,openright" options to have a shorter output for the forum, this has no other influence)

  • What happens if you put the \renewcommand after \begin{document}? – cfr Mar 20 '16 at 23:53
  • Thanks for the suggestion, but same result I'm afraid. I tried many placements, it almost looks as if it is ignored (or if that is not the reason for the clearpage in the first place here) EDIT: I am using TexStudio on Ubuntu 12.04 if that makes any difference. – Ced Mar 21 '16 at 0:28
  • 1
    If they are chapters, then it is appropriate for blank pages to be inserted between the two and prior to the first if there is something else in the document. But blank pages shouldn't be added before the first if there is nothing but the glossaries in the document. Is that what you are asking about? Otherwise, I think the answer below is the correct one, even though the package's behaviour is wrong (because you don't want the correct behaviour either). But if you want chapters and are just asking about the additional pages, that's different. – cfr Mar 21 '16 at 1:41
3

There are several possible things you might want here:

  1. the glossaries to be sections, rather than chapters;
  2. the glossaries to be chapters but with a custom format which does not insert blank pages as other chapters do;
  3. the glossaries to be chapters but not to have additional blank pages before the first glossary when the glossaries are the only thing in the document.

esdd's answer addresses the first two possibilities.

In the third case, the problem is that \glsaddall appears to get counted as content, even though nothing is actually typeset. I'd consider this a bug: it ought not cause this behaviour, as far as I can see.

However, I didn't look into this further as there's an easy solution: use the command in the preamble rather than the document and all is well.

\documentclass[11pt,a4paper,twoside,openright]{scrreprt}
\usepackage[style=alttree,nonumberlist,acronym]{glossaries}
\glssetwidest{ABCD}% widest name
\renewcommand*{\glsclearpage}{}

\newglossary{type1}{gls1}{glo1}{Glossary 1}
\newglossary{type2}{gls2}{glo2}{Glossary 2}

\newglossaryentry{Entry1}{type = type1, name = $aaaa$, description = Position}
\newglossaryentry{Entry2}{type = type1, name = $bbbb$, description = Velocity}
\newglossaryentry{Entry3}{type = type2, name = $cccc$, description = Position}
\newglossaryentry{Entry4}{type = type2, name = $dddd$, description = Velocity}

\makeglossaries
\glsaddall

\begin{document}

\printglossary[type=type1]
\printglossary[type=type2]

\end{document}

regular chapters with no extra blanks

  • Thanks for the quick and thorough answer. I will have material before my glossary, so this is not really an issue here. Just out of curiosity though: So, the general behaviour of a "chapter" is to insert a blank page, and because \glsaddall seems to be treated as context, an empty page appears? Is that what you meant? – Ced Mar 21 '16 at 10:23
  • 3
    \glsaddall is treated as context because it uses \glsadd which needs to switch to horizontal mode (if it's not already in it and it doesn't occur in the preamble) for some technical reason that I can't remember off the top of my head. In general it's best to put \glsaddall in the preamble. – Nicola Talbot Mar 21 '16 at 12:50
  • 1
    @Ced In general, classes which use chapters define them to start on a new, odd page in two-sided mode or a new page in one-sided mode. It does depend on the class, but that's pretty standard. So, if previous material ends on an odd page, you'll get a blank page before the chapter. If previous stuff ends on an even page, no blank is required. This can all be altered, of course - hence openany etc. But the default behaviour tends to be as described, yes. – cfr Mar 21 '16 at 13:37
3

You could use option section or section=section for the glossaries package. Then the glossaries get headings on level section.

    \documentclass[11pt,a4paper,twoside,openright]{scrreprt}
    % Include Glossary Package
    \usepackage[style=alttree,nonumberlist,acronym,
        section=section% <- added
    ]{glossaries}
    \glssetwidest{ABCD}% widest name
    % Create Glossaries
    \newglossary{type1}{gls1}{glo1}{Glossary 1}
    \newglossary{type2}{gls2}{glo2}{Glossary 2}
    % Generate Glossary Entries
    \newglossaryentry{Entry1}{type = type1, name = $aaaa$, description = Position}
    \newglossaryentry{Entry2}{type = type1, name = $bbbb$, description = Velocity}
    \newglossaryentry{Entry3}{type = type2, name = $cccc$, description = Position}
    \newglossaryentry{Entry4}{type = type2, name = $dddd$, description = Velocity}
    % Generate Glossaries
    \makeglossaries
    \begin{document}
    % Print Glossaries
    \glsaddall
    \printglossary[type=type1]
    \printglossary[type=type2]
    \end{document} 

enter image description here

If the glossary heading should be on chapter level you could use the KOMA-Script command \RedeclareSectionCommand to change the style for chapter locally to section. Then there is no page break while the glossary heading is still on level chapter using the font element chapter and having the same spaces before and after the heading. This workaround needs at least KOMA-Script version 3.18 (current is 3.19a).

    \documentclass[11pt,a4paper,twoside,openright]{scrreprt}
    % Include Glossary Package
    \usepackage[style=alttree,nonumberlist]{glossaries}
    \glssetwidest{ABCD}% widest name
    % Create Glossaries
    \newglossary{type1}{gls1}{glo1}{Glossary 1}
    \newglossary{type2}{gls2}{glo2}{Glossary 2}
    % Generate Glossary Entries
    \newglossaryentry{Entry1}{type = type1, name = $aaaa$, description = Position}
    \newglossaryentry{Entry2}{type = type1, name = $bbbb$, description = Velocity}
    \newglossaryentry{Entry3}{type = type2, name = $cccc$, description = Position}
    \newglossaryentry{Entry4}{type = type2, name = $dddd$, description = Velocity}
    % Generate Glossaries
    \makeglossaries
    \begin{document}
    % Print Glossaries
    \glsaddall
    \begingroup
        \RedeclareSectionCommand[style=section,indent=0pt]{chapter}
        \printglossary[type=type1]
        \printglossary[type=type2]
    \endgroup
    \chapter{Chapter}
    \end{document} 

enter image description here

Note that the command \glsaddall inserts in both examples additional horizontal space before the heading of the first glossary. Therefore see also cfr's answer.


If you remove the blank pages before the first glossary using cfr's answer it is also possible to remove the empty page between the glossaries: use \KOMAoptions{open=any} locally.

\documentclass[11pt,a4paper,twoside,openright]{scrreprt}
\usepackage{showframe}

% Include Glossary Package
\usepackage[style=alttree,nonumberlist]{glossaries}
\glssetwidest{ABCD}% widest name
% Create Glossaries
\newglossary{type1}{gls1}{glo1}{Glossary 1}
\newglossary{type2}{gls2}{glo2}{Glossary 2}
% Generate Glossary Entries
\newglossaryentry{Entry1}{type = type1, name = $aaaa$, description = Position}
\newglossaryentry{Entry2}{type = type1, name = $bbbb$, description = Velocity}
\newglossaryentry{Entry3}{type = type2, name = $cccc$, description = Position}
\newglossaryentry{Entry4}{type = type2, name = $dddd$, description = Velocity}
% Generate Glossaries
\makeglossaries\glsaddall% < see https://tex.stackexchange.com/a/300060/43317
\begin{document}
% Print Glossaries
\begingroup
    \KOMAoptions{open=any}
    \printglossary[type=type1]
    \printglossary[type=type2]
\endgroup
\chapter{First Chapter}
\chapter{Second Chapter}
\end{document} 

enter image description here

  • 1
    (+1) But the behaviour of the package is surely wrong. If there is nothing before the glossary, it should not insert blank pages. If there is stuff first, then if it is a chapter, it will clear the page or pages with the default definition. But it ought not add blank page over and above those appropriate for a chapter. – cfr Mar 21 '16 at 1:39
  • @cfr Thank you for the hint. You are right, that there should be no empty page before the first glossary if there is nothing else before it. – esdd Mar 21 '16 at 9:07
  • Thank you so much, both methods worked out great! The main goal was that I wanted a main "Glossaries" chapter with several types of glossaries in individual sections. See final result as edit in my question. Using \KOMAoptions{open=any} also performed as expected, but not really what I needed. Nice addition though. – Ced Mar 21 '16 at 10:35

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.