The simplest solution is to change the value of \glsdescwidth
using \setlength
. For example \setlength{\glsdescwidth}{3in}
as in the following example:
\documentclass{article}
\usepackage{lipsum}
\usepackage{glossaries}
\makeglossaries
\newglossarystyle{formel_altlong4colheader}{%
\setglossarystyle{altlong4colheader}%
%
\renewcommand*{\glossaryheader}{%
\bfseries sign
& \bfseries description
& \bfseries unit
& \\
\hline
\\\endhead}%
\renewcommand{\glossentry}[2]{%
\glstarget{##1}{\glossentryname{##1}}%
& \glossentrydesc{##1}%
& \glossentrysymbol{##1}%
\tabularnewline % end of row
}%
}
\setlength{\glsdescwidth}{3in}
\setglossarystyle{formel_altlong4colheader}
\newglossaryentry{L}{name={L},description={Buchstabe},symbol={---}}
\newglossaryentry{P}{name={P},description={Leistung},symbol={kW}}
\begin{document}
\lipsum[1]
\glsaddall
\printglossaries
\end{document}
This produces:

However this approach is a matter of trial and error to work out the value of \glsdescwidth
. You also still have the fourth column, even though you're not using it, which is taking up unnecessary space. Instead I recommend a different approach that works out the width:
\documentclass{article}
\usepackage{lipsum}
\usepackage{booktabs}
\usepackage{calc}
\usepackage{glossaries}
\makeglossaries
\newlength\glsnamewidth
\newlength\glsunitwidth
\settowidth{\glsnamewidth}{\textbf{sign}}
\settowidth{\glsunitwidth}{\textbf{unit}}
\newglossarystyle{namedescunit}{%
\setlength{\glsdescwidth}{\linewidth-\glsnamewidth-\glsunitwidth-6\tabcolsep}%
\renewenvironment{theglossary}%
{\begin{longtable}{p{\glsnamewidth}p{\glsdescwidth}p{\glsunitwidth}}}%
{\end{longtable}}%
\renewcommand*{\glossaryheader}{%
\bfseries sign
& \bfseries description
& \bfseries unit
\tabularnewline
\midrule
\tabularnewline\endhead}%
\renewcommand*{\glsgroupheading}[1]{}%
\renewcommand{\glossentry}[2]{%
\glstarget{##1}{\glossentryname{##1}} &
\glossentrydesc{##1} &
\glossentrysymbol{##1}\tabularnewline
}%
\renewcommand{\subglossentry}[3]{\glossentry{##2}{##3}}%
\renewcommand*{\glsgroupskip}{}%
}
\setglossarystyle{namedescunit}
\newglossaryentry{L}{name={L},description={Buchstabe},symbol={---}}
\newglossaryentry{P}{name={P},description={Leistung},symbol={kW}}
\begin{document}
\lipsum[1]
\glsaddall
\printglossaries
\end{document}
This produces:

This assumes that the maximum widths of the first and third columns are given by their header text. This may not be the case, so the following example computes them as the entries are defined:
\documentclass{article}
\usepackage{lipsum}
\usepackage{booktabs}
\usepackage{calc}
\usepackage{glossaries}
\makeglossaries
\newlength\glsnamewidth
\newlength\glsunitwidth
\settowidth{\glsnamewidth}{\textbf{sign}}
\settowidth{\glsunitwidth}{\textbf{unit}}
\newglossarystyle{namedescunit}{%
\setlength{\glsdescwidth}{\linewidth-\glsnamewidth-\glsunitwidth-6\tabcolsep}%
\renewenvironment{theglossary}%
{\begin{longtable}{p{\glsnamewidth}p{\glsdescwidth}p{\glsunitwidth}}}%
{\end{longtable}}%
\renewcommand*{\glossaryheader}{%
\bfseries sign
& \bfseries description
& \bfseries unit
\tabularnewline
\midrule
\tabularnewline\endhead}%
\renewcommand*{\glsgroupheading}[1]{}%
\renewcommand{\glossentry}[2]{%
\glstarget{##1}{\glossentryname{##1}} &
\glossentrydesc{##1} &
\glossentrysymbol{##1}\tabularnewline
}%
\renewcommand{\subglossentry}[3]{\glossentry{##2}{##3}}%
\renewcommand*{\glsgroupskip}{}%
}
\setglossarystyle{namedescunit}
\makeatletter
\appto\@newglossaryentryposthook{%
\settowidth{\dimen@}{\glsentryname{\@glo@label}}%
\ifdim\dimen@>\glsnamewidth
\setlength{\glsnamewidth}{\dimen@}%
\fi
\settowidth{\dimen@}{\glsentrysymbol{\@glo@label}}%
\ifdim\dimen@>\glsunitwidth
\setlength{\glsunitwidth}{\dimen@}%
\fi
}%
\makeatother
\newglossaryentry{L}{name={L},description={Buchstabe},symbol={---}}
\newglossaryentry{P}{name={P},description={Leistung},symbol={kW}}
\begin{document}
\lipsum[1]
\glsaddall
\printglossaries
\end{document}
In this case, the result is the same as the previous example. If you want the name and unit columns centred you can add \centering
to the style:
\documentclass{article}
\usepackage{lipsum}
\usepackage{booktabs}
\usepackage{calc}
\usepackage{glossaries}
\makeglossaries
\newlength\glsnamewidth
\newlength\glsunitwidth
\settowidth{\glsnamewidth}{\textbf{sign}}
\settowidth{\glsunitwidth}{\textbf{unit}}
\newglossarystyle{namedescunit}{%
\setlength{\glsdescwidth}{\linewidth-\glsnamewidth-\glsunitwidth-6\tabcolsep}%
\renewenvironment{theglossary}%
{\begin{longtable}{p{\glsnamewidth}p{\glsdescwidth}p{\glsunitwidth}}}%
{\end{longtable}}%
\renewcommand*{\glossaryheader}{%
\centering\bfseries sign
& \bfseries description
& \centering\bfseries unit
\tabularnewline
\midrule
\tabularnewline\endhead}%
\renewcommand*{\glsgroupheading}[1]{}%
\renewcommand{\glossentry}[2]{%
\centering\glstarget{##1}{\glossentryname{##1}} &
\glossentrydesc{##1} &
\centering\glossentrysymbol{##1}\tabularnewline
}%
\renewcommand{\subglossentry}[3]{\glossentry{##2}{##3}}%
\renewcommand*{\glsgroupskip}{}%
}
\setglossarystyle{namedescunit}
\makeatletter
\appto\@newglossaryentryposthook{%
\settowidth{\dimen@}{\glsentryname{\@glo@label}}%
\ifdim\dimen@>\glsnamewidth
\setlength{\glsnamewidth}{\dimen@}%
\fi
\settowidth{\dimen@}{\glsentrysymbol{\@glo@label}}%
\ifdim\dimen@>\glsunitwidth
\setlength{\glsunitwidth}{\dimen@}%
\fi
}%
\makeatother
\newglossaryentry{L}{name={L},description={Buchstabe},symbol={---}}
\newglossaryentry{P}{name={P},description={Leistung},symbol={kW}}
\begin{document}
\lipsum[1]
\glsaddall
\printglossaries
\end{document}
This now produces:

altlong4colheader
style useslongtable
which computes the cell widths according to the widest value for that column, except in the case of thep
specifier (which is used for the description column). You can change the value of\glsdescwidth
(using\setlength
) to make the description column wider.