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}
The standard column specifiers are l
, r
, c
and p{
length}
. You can define new column types using the array
package, but I don't think that's needed in this case as you can adjust the paragraph alignment using \raggedleft
. When defining a new glossary style, it helps to consider a simplified version of what that style does. At it's basic level, the style needs to be in the form:
\documentclass{article}
\begin{document}
\begin{tabular}{p{2cm}p{4cm}}
\raggedleft A. & some text\\
\raggedleft AA. & some more text\\
\raggedleft AAA. & some more text
\end{tabular}
\end{document}
which has a right-aligned paragraph-style first column.
Now test what happens if ParameterA,ParameterB
is added:
\documentclass{article}
\begin{document}
\begin{tabular}{p{2cm}p{4cm}}
\raggedleft A. & some text\\
\raggedleft AA. & some more text\\
\raggedleft AAA. & some more text\\
\raggedleft ParameterA,ParameterB & some text
\end{tabular}
\end{document}
This doesn't have a line wrap because TeX can't insert a line break, so the result is rather ugly.
Instead you need to provide TeX with some scope to break the line at the comma:
\documentclass{article}
\newcommand{\comma}{,\penalty \exhyphenpenalty}
\begin{document}
\begin{tabular}{p{2cm}p{4cm}}
\raggedleft A. & some text\\
\raggedleft AA. & some more text\\
\raggedleft ParameterA\comma ParameterB & some text
\end{tabular}
\end{document}
TeX can now break the line:
Here I've hardcoded the column widths using 2cm
and 4cm
, but the glossaries
package defines a length for the second column called \glsdescwidth
. You can define another length to use for the first column:
\newlength\glsnamewidth
You'll need to set this value as appropriate for your document. For example:
\setlength{\glsnamewidth}{3cm}
or
\setlength{\glsnamewidth}{0.3\hsize}
The new glossary style can then be defined as:
\newglossarystyle{superglossarystyle}
{%
\setglossarystyle{super}%
\renewenvironment{theglossary}%
{%
\tablehead{}%
\tabletail{}%
\begin{supertabular}{p{\glsnamewidth}p{\glsdescwidth}}%
}%
{%
\end{supertabular}%
}%
\renewcommand{\glossentry}[2]{%
\raggedleft
\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
\glossentrydesc{##1}\glspostdescription\space ##2\tabularnewline
}%
}
The complete example is:
\documentclass[pdftex,a4paper,oneside,12pt,halfparskip]{scrbook}
\usepackage[]{amsmath,amssymb}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[a4paper,top=3.6cm,bottom=3.6cm,left=3.6cm,right=3.6cm]{geometry}
\usepackage[]{glossaries}
\newcommand{\comma}{,\penalty \exhyphenpenalty}
\newlength\glsnamewidth
\setlength{\glsnamewidth}{0.3\hsize}
\newglossarystyle{superglossarystyle}
{%
\setglossarystyle{super}%
\renewenvironment{theglossary}%
{%
\tablehead{}%
\tabletail{}%
\begin{supertabular}{p{\glsnamewidth}p{\glsdescwidth}}%
}%
{%
\end{supertabular}%
}%
\renewcommand{\glossentry}[2]{%
\raggedleft
\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
\glossentrydesc{##1}\glspostdescription\space ##2\tabularnewline
}%
}
\setglossarystyle{superglossarystyle}
\makeglossaries
\newglossaryentry{pab}
{
name =
{$\boldsymbol{ParameterA}\comma\boldsymbol{ParameterB}$} ,
description = {This is the description of ParameterA and
ParameterB, that is long and automatically wraps} ,
}
\newglossaryentry{pc}
{
name = {$\boldsymbol{ParameterC}$} ,
description = {This is the description of ParameterC, that is
long and automatically wraps.} ,
}
\begin{document}
\glsaddallunused\printglossaries
\end{document}
which produces:
Best Answer
The
alttree
style uses\makebox
which won't allow line breaks. You could make a new style based on thealttree
style that uses a\parbox
instead. For example:This produces:
Edit:
The
\parbox
's height affects the first line of the description, which I'd forgotten about. This can be eliminated by using\smash
like this:This modification to the above MWE now produces:
However, since this removes the
\parbox
's height, if the description has fewer lines than the name this may cause the excess lines to clash with the next entry. If this is likely to happen, it may be better to use a tabular-like style. Another possibility you might want to consider is to allow the long name to overflow and start the description on the next line, like this:This produces: