Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm using the 'glossaries' package to build a list of abbreviations. I have my own style defined based on a standard longtable style (to easily see what's the matter I pick the 'longheaderborder' style). The problem occurs when the list of abbreviations spreads over a single page and you have a style where the value 'glsgoupskip' is greater than zero. In the used style this means, that the entries within the list are grouped based on the first letter and between each group there is a blank line in the longtable.

If this groupskip coincide with a pagebreak (longtable pagebreak), naturally you get a blank line at the end of the first page or at the beginning at the second page. To clarify what is going on here's my Minimal Example:

\documentclass[]{scrbook} 

\usepackage[english]{babel} 
\usepackage[T1]{fontenc} 
\usepackage[latin1]{inputenc} 
% glossaries 
\usepackage[% 
acronym % use acronym functionality 
,section = section % use sections for all glossary lists 
]{glossaries} 
% some acronyms 
\newacronym{mimo}{MIMO}{Multiple Input Multiple Output} 
\newacronym{miso}{MISO}{Multiple Input Single Output} 
\newacronym{simo}{SIMO}{Single Input Multiple Output} 
\newacronym{siso}{SISO}{Single Input Single Output} 
\newacronym{cdma}{CDMA}{Code Division Multiple Access} 
\newacronym{ofdm}{OFDM}{Orthogonal Frequency Division Multiplex} 

% switch on glossaries 
\makeglossaries 

\begin{document} 
\chapter{Notation} 
\vspace{28\baselineskip} 
% print list of acronyms 
\glsaddall 
\printglossary[type=\acronymtype,style=longheaderborder] 
\end{document} 

I've added the vspace to prevent me from typing too much abbreviations. :)

To cut a long story short: How can one suppress the glsgroupskip if a pagebreak has occurred?


edit:

To compile this document I do the following calls:

  1. pdflatex %
  2. makeindex -s %.ist -t %.alg -o %.acr %.acn
  3. pdflatex %

where % indicates the document file name.
When I run my example from above there is a groupskip (ie blank line) directly after the MISO entry. Right beneath this groupskip the pagebreak occurs so there is a blank line left at the bottom of the table on the first page.

a groupskip (blank line) at the bottom of the table

If you set the vertical skip to 29\baselineskip this blank line will occur at the top of the table on the second page right beneath the table head.

For the sake of completeness here's a MWE with my own defined style using 'tabu' and 'booktabs' package. To build this document I call the same commands as mentioned above. The aim is to set groupskip to \addlinespace (booktabs command) but the problem is more clearly with a full blank line ( &\\ ).

\documentclass[]{scrbook} 

\usepackage[english]{babel} 
\usepackage[T1]{fontenc} 
\usepackage[latin1]{inputenc} 

% table packages 
\usepackage{booktabs,longtable,tabu} 
% glossaries 
\usepackage[% 
acronym % use acronym functionality 
,section = section % use sections for all glossary lists 
,nonumberlist % no page references in lists 
,nostyles % do not load  any style 
]{glossaries} 

% define new style for acronyms 
\newglossarystyle{my_acronymlist}{% 
\renewenvironment{theglossary}% 
{\begin{longtabu} to\linewidth {lX}}% 
{\end{longtabu}}% 
\renewcommand*{\glossaryheader}{\toprule Acronym & Description\\\midrule\endhead% 
\toprule Acronym & Description\\\midrule\endfirsthead% 
\bottomrule\endfoot}% 
\renewcommand*{\glsgroupheading}[1]{}% 
\renewcommand*{\glossaryentryfield}[5]{% 
\glstarget{##1}{##2} & \glsentrydesc{##1}\\}% 
% 
\renewcommand*{\glossarysubentryfield}[6]{% 
&% 
\glssubentryitem{##2}% 
\glstarget{##2}{\strut}##4 & ##6\\}% 
% 
%*** GROUP SKIP *** 
\renewcommand*{\glsgroupskip}{&\\}% 
%\renewcommand*{\glsgroupskip}{\addlinespace}% 
%****************** 
} 

% some acronyms 
\newacronym{mimo}{MIMO}{Multiple Input Multiple Output} 
\newacronym{miso}{MISO}{Multiple Input Single Output} 
\newacronym{simo}{SIMO}{Single Input Multiple Output} 
\newacronym{siso}{SISO}{Single Input Single Output} 
\newacronym{cdma}{CDMA}{Code Division Multiple Access} 
\newacronym{ofdm}{OFDM}{Orthogonal Frequency Division Multiplex} 

% switch on glossaries 
\makeglossaries 

\begin{document} 

\chapter{Notation} 

\vspace{28\baselineskip} 
% print list of acronyms 
\glsaddall 
\printglossary[type=\acronymtype,style=my_acronymlist] 

\end{document}

With this style I get this blank groupskip-line at the top of the second page.

blank line with own defined style

When I add

\expandafter\let\csname @glsstyle@my_acronymlist\endcsname\relax

right before the style definition, and set

\renewcommand*{\glsgroupskip}{\noalign{\penalty-50\vskip\normalbaselineskip}}%

sadly I can't see any change.
Nevertheless, thanks so far for your help. Hopefully there will be a solution...

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

Probably you should use a real space rather than a blank table row so it is automatically discarded. This would look better if there were no vertical rules but I've left those in for now.

adding this to the preamble after the glossaries package is loaded probably does something.

\expandafter\let\csname @glsstyle@long\endcsname\relax
\newglossarystyle{long}{%
  \renewenvironment{theglossary}%
     {\begin{longtable}{lp{\glsdescwidth}}}%
     {\end{longtable}}%
  \renewcommand*{\glossaryheader}{}%
  \renewcommand*{\glsgroupheading}[1]{}%
  \renewcommand*{\glossaryentryfield}[5]{%
    \glsentryitem{##1}\glstarget{##1}{##2} & ##3\glspostdescription\space ##5\\}%
  \renewcommand*{\glossarysubentryfield}[6]{%
     &
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}##4\glspostdescription\space ##6\\}%
  \renewcommand*{\glsgroupskip}{\noalign{\penalty-50\vskip\normalbaselineskip}}%
}

The above probably ought to have worked in an ideal world, but longtable has a few "features" that defeat this. Notably that the table head is not inserted by the output routine for the current page but rather it is injected by the output routine for the previous page. This means that the glue is not discarded at the top of the page. (Normally this is not an issue as tables do not have discardable glue....

So, the following appears to work. The penalty -50 and the skip added between groups (15pt here) are fairly arbitrary but the penalty probably should be negative and the values must be the same where they are set in the \noalign in your acronym style and (twice) where a correction is inserted into longtable internals

The redefinition of \LT@output gets LT to check if the page break happened at -50 and if so backs up by 15pt to allow for the 15pt skip added at these special breaks.

\documentclass[]{scrbook} 

\usepackage[english]{babel} 
\usepackage[T1]{fontenc} 
\usepackage[latin1]{inputenc} 

% table packages 
\usepackage{booktabs,longtable,tabu} 
% glossaries 
\usepackage[% 
acronym % use acronym functionality 
,section = section % use sections for all glossary lists 
,nonumberlist % no page references in lists 
,nostyles % do not load  any style 
]{glossaries} 

% define new style for acronyms 
\newglossarystyle{my_acronymlist}{% 
\renewenvironment{theglossary}% 
{\begin{longtabu} to\linewidth {lX}}% 
{\end{longtabu}}% 
\renewcommand*{\glossaryheader}{\toprule Acronym & Description\\\midrule\endhead% 
\toprule Acronym & Description\\\midrule\endfirsthead% 
\bottomrule\endfoot}% 
\renewcommand*{\glsgroupheading}[1]{}% 
\renewcommand*{\glossaryentryfield}[5]{% 
\glstarget{##1}{##2} & \glsentrydesc{##1}\\}% 
% 
\renewcommand*{\glossarysubentryfield}[6]{% 
&% 
\glssubentryitem{##2}% 
\glstarget{##2}{\strut}##4 & ##6\\}% 
% 
%*** GROUP SKIP *** 
\renewcommand*{\glsgroupskip}{&\\}% 
%\renewcommand*{\glsgroupskip}{\addlinespace}% 
\renewcommand*{\glsgroupskip}{\noalign{\penalty-50\vskip15pt\relax}}%

%****************** 
} 

% some acronyms 
\newacronym{mimo}{MIMO}{Multiple Input Multiple Output} 
\newacronym{miso}{MISO}{Multiple Input Single Output} 
\newacronym{simo}{SIMO}{Single Input Multiple Output} 
\newacronym{siso}{SISO}{Single Input Single Output} 
\newacronym{cdma}{CDMA}{Code Division Multiple Access} 
\newacronym{ofdm}{OFDM}{Orthogonal Frequency Division Multiplex} 

% switch on glossaries 
\makeglossaries 

\makeatletter
\def\LT@output{%
  \ifnum\outputpenalty <-\@Mi
    \ifnum\outputpenalty > -\LT@end@pen
      \LT@err{floats and marginpars not allowed in a longtable}\@ehc
    \else
      \setbox\z@\vbox{\unvbox\@cclv}%
      \ifdim \ht\LT@lastfoot>\ht\LT@foot
        \dimen@\pagegoal
        \advance\dimen@-\ht\LT@lastfoot
        \ifdim\dimen@<\ht\z@
          \setbox\@cclv\vbox{\unvbox\z@\copy\LT@foot\vss}%
          \@makecol
          \@outputpage
          \setbox\z@\vbox{\box\LT@head
\ifnum\outputpenalty=-50\vskip-15pt\relax\fi
}%
        \fi
      \fi
      \global\@colroom\@colht
      \global\vsize\@colht
%      \vbox
        {\unvbox\z@\box\ifvoid\LT@lastfoot\LT@foot\else\LT@lastfoot\fi}%
    \fi
  \else
    \setbox\@cclv\vbox{\unvbox\@cclv\copy\LT@foot\vss}%
    \@makecol
    \@outputpage
      \global\vsize\@colroom
    \copy\LT@head
\ifnum\outputpenalty=-50\vskip-15pt\relax\fi
\nobreak
  \fi}
\makeatother
\begin{document} 

\chapter{Notation} 

\vspace{28\baselineskip} 
% print list of acronyms 
\glsaddall 
\printglossary[type=\acronymtype,style=my_acronymlist] 

\end{document}
share|improve this answer
    
Thanks for this first response... –  christian May 22 '12 at 11:12
    
I apologise for this mindless comment (that's the first time at stackexchange) I have to admit that I didn't tell the truth :) My own defined style that I'm working with uses the 'tabu' package to get a longtable (longtabu) that is spread to linewidth. There are only horizontal lines with the 'booktabs' package commands. I've set glsgroupskip to '\addlinespace' (booktabs command too). In order to ease the example, I showed the problem with this standard style at which the problem should remain the same. I'll give your solution a try and let you know whether its working or not... –  christian May 22 '12 at 11:28
    
I've copy and paste your code snippet directly after loading the package. You are right, the vertical lines are now disrupted on each groupskip, but as I mentioned this is no problem since my own style doesn't use vertical lines. Anyway, there is still a groupskip (blank line) at the beginning of the second page directly beneath the table heading. Correct me if I'm wrong: Your approach adds a penalty value for a pagebreak if a groupskip occurs? Would it be helpful if I post my own defined style? Can I do this as an answer to my own question (Answer Your Question)? –  christian May 23 '12 at 14:17
    
"Your approach adds a penalty value for a pagebreak if a groupskip occurs?" It was a negative penalty, ie saying it was a good break. When I ran your original example the page breaks did not come quite where you described, so if you do adjust your example could you also be explicit about the latex and makeindex calls you used. If you have something working it is fine to answer your own question, if you are posting a more complete MWE for clarification it is better to edit your question. –  David Carlisle May 23 '12 at 15:30
    
I have appended some additional information to my original question. Maybe you can give me some advice on how to resolve this problem for my particular table-style? –  christian May 27 '12 at 9:59
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.