0

I've copied & pasted the glossary of a friend of mine for my thesis. I have to admit that I don't understand a thing of what's happening in that section. All I know is that the right margin of the glossary is way too wide. I am not certain what is doing that as the example worked in the file of my friend. So maybe you can help by finding the obvious error here.

Here's my Example:

\documentclass[a4paper,12pt,twoside]{report}
\raggedbottom

%Einstellungen.....................
% Formatierungseinstellungen

\usepackage[colorinlistoftodos]{todonotes} %Erzeugt Kommentare mittels \todo{} in der .pdf
\usepackage{setspace}
\usepackage{notoccite} %Damit Zitate im Abbildungskapitel nicht die Reihenfolge versauen
\usepackage{MnSymbol}
\usepackage[T1]{fontenc}
\usepackage{titlesec}
\usepackage{siunitx}
\usepackage{blindtext}
\usepackage{fancyhdr} % Package für Kopf- und Fußzeilen
    \pagestyle{fancyplain} % Kopfzeilen definieren
        \renewcommand{\chaptermark}[1]{\markboth{\thechapter \hspace{3mm}#1}{}}
        \renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
        \cfoot[\fancyplain{}{}]{\fancyplain{}{}}
        \lhead[\fancyplain{}{\small\sl\thepage}]
        {\fancyplain{}{\small\sl\leftmark}}
        \rhead[\fancyplain{}{\small\sl\rightmark}]
        {\fancyplain{}{\small\sl\thepage}}
        \renewcommand{\footrulewidth}{0pt}
        \setlength{\headheight}{15pt}
\usepackage[nottoc]{tocbibind}
\usepackage[nohyperlinks, printonlyused, withpage]{acronym}
\usepackage{suffix} %Gehört irgendwie mit zu {acronym}
\usepackage{xstring} %Gehört irgendwie mit zu {acronym}
\usepackage{relsize} %Gehört irgendwie mit zu {acronym}
\usepackage{graphicx} %Ich glaube, damit man Grafiken adden kann
    \graphicspath{{./Images/}} %Unterordner Images
\usepackage{tikz}
\usepackage{xcolor,colortbl} %Für farbige Tabellen
    \definecolor{myOrange}{HTML}{ed7d31}
    \definecolor{myRed}{HTML}{d60000}
    \definecolor{myYellow}{HTML}{ffc000}
\usepackage{array} %Für Tabellen
\usepackage{multirow} %Für komplexe Tabellen
\usepackage{subcaption} %Mehre Bilder nebeneinander
\usepackage{epstopdf} %package to overcome problem with eps in pdf files
%\usepackage{cite} %Damit man mit Citavi zitieren kann. Wird mit Biblatex nicht benötigt
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
    \DeclareUnicodeCharacter{2215}{/} %Behebung eines random Fehlers wo "/" nicht erkannt wurde
\usepackage[labelfont=bf]{caption}% u. a. für \captionof
    \captionsetup[figure]{font=small}
\usepackage{mwe}    
\usepackage{float} %Wichtig um die floats von Bildern und Tabellen zu ändern
\usepackage[section]{placeins}
\usepackage{amsfonts} %Für Formeln
\usepackage{amsmath} %Für Formeln
\usepackage{mathtools} %Für Formeln
    \DeclarePairedDelimiter\abs{\lvert}{\rvert}%
    \DeclarePairedDelimiter\norm{\lVert}{\rVert}%
    % Swap the definition of \abs* and \norm*, so that \abs
    % and \norm resizes the size of the brackets, and the 
    % starred version does not.
    \makeatletter
    \let\oldabs\abs
    \def\abs{\@ifstar{\oldabs}{\oldabs*}}
    \let\oldnorm\norm
    \def\norm{\@ifstar{\oldnorm}{\oldnorm*}}
    \makeatother
\usepackage{color,soul}

%Glossaries----------------------------------
\usepackage[
nopostdot,      %kein Punkt hinten
nonumberlist, %keine Seitenzahlen anzeigen
acronym,      %ein Abkürzungsverzeichnis erstellen
%toc,          %Einträge im Inhaltsverzeichnis
nogroupskip,    %kein Abstand zwischen 
section]      %im Inhaltsverzeichnis auf section-Ebene erscheinen
{glossaries}
\AtBeginDocument{\setlength{\glsdescwidth}{.85\columnwidth}} %für Zeilenumbrüche im Abkürzungsverzeichnis
\usepackage{xassoccnt} %Damit man Seiten zählen kann
    \newcounter{realpage}
    \DeclareAssociatedCounters{page}{realpage}
    \AtBeginDocument{%
        \stepcounter{realpage}
    }
    
\newglossary[mlg]{mater}{myi}{myg}{Elemente und Materialien}
\newglossary[slg]{symbolslist}{syi}{syg}{Symbole}

\setlength{\glsdescwidth}{15cm}
\glsaddkey{unit}{\glsentrytext{\glslabel}}{\glsentryunit}{\GLsentryunit}{\glsunit}{\Glsunit}{\GLSunit}

\makeglossaries
%\loadglsentries {Kapitel/ASE.tex}

\newglossarystyle{symbunitlong}{%
\setglossarystyle{long3col}% base this style on the list style
\renewenvironment{theglossary}{% Change the table type --> 3 columns
  \begin{longtable}{lp{0.15\glsdescwidth}>{\arraybackslash}p{11cm}}}%
  {\end{longtable}}%
%
\renewcommand*{\glossaryheader}{%  Change the table header
   \textbf{Symbol} & \textbf{Einheit} & \textbf{Beschreibung} \\
  \endhead}
\renewcommand*{\glossentry}[2]{%  Change the displayed items
\glstarget{##1}{\glossentryname{##1}} %
& \glsunit{##1}% Description
& \glossentrydesc{##1}  
\tabularnewline
}
}


%Alle globalen document settings hier rein-----------------------------------------------
\setlength\parindent{0pt} %Wenn man keine Indentation haben möchte einfahc auf 0 setzen
\onehalfspacing %Zeilenabstand des Dokuments
\pagestyle{fancy} %Seitenzahlen abwechselnd rechts/links im header

%Literaturverzeichnis mit Biblatex/biber-----------------------------------------------
\usepackage[autostyle]{csquotes}  %für biblatex
\usepackage{xpatch}
\usepackage[backend=biber, maxnames=20, style=nature, autocite=superscript, isbn=false, intitle=true, url=false, doi=false, natbib=true, eprint=false]{biblatex}
\setlength{\bibitemsep}{0.5\baselineskip} 
\addbibresource{Literaturverzeichnis.bib}
%\bibliographystyle{unsrt} %Literaturverzeichnis mit Citavi; (plain, unsrt, abbrv, alpha)
%\bibliography{Literaturverzeichnis}

\makeatother %???
\numberwithin{equation}{section} % Integriert Kapitelnummer in Formeln

%Commands hier rein
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
    \node[shape=circle,draw,inner sep=2pt] (char) {#1};}}
\newcommand{\angstrom}{\textup{\AA}}

\usepackage{hyperref} %Alles was mit Hyperlinks zu tun hat
    \hypersetup{
        colorlinks = true,
        linkcolor = black,
        anchorcolor = blue,
        citecolor = blue,
        filecolor = blue,
        urlcolor = blue
        }
        \addto\extrasngerman{\def\subsectionautorefname{Kapitel}} %Definition "Kapitel" bei autoref von subsection  
        \addto\extrasngerman{\def\sectionautorefname{Kapitel}} %Definition "Kapitel" bei autoref von section
\usepackage{cleveref}   


\begin{document}
\pagestyle{fancyplain} 
\pagenumbering{Roman} 
    
%%%%%%%%%%%%%%%%%%% Abkürzungen %%%%%%%%%%%%%
\newglossaryentry{MIGS}{type=acronym, name={MIGS},
description={Metall induzierte Bandlückenzustände (\textit{engl.} Metal Induced Gap States (MIGS)},
first={MIGS}}
\newglossaryentry{UVO}{type=acronym, name={UVO},
description={Ultraviolett-Ozon},
first={UVO}}
\newglossaryentry{MQW}{type=acronym, name={MQW},
description={multiple Quantentöpfe (engl. \textit{multiple quantum well})},
first={multiple Quantentöpfe (MQW)}}
\newglossaryentry{TCF}{type=acronym, name={TCF},
description={transparente, leitfähige Schicht/Elektrode (engl. \textit{transparent conducting film}},
first={transparente, leitfähige Schicht/Elektrode (TCF)}}           
\newglossaryentry{TL}{type=acronym, name={T$_L$},
description={Transferlänge},
first={Transferlänge (T$_L$)}}
\newglossaryentry{IIINitride}{type=acronym, name={III-Nitride},
description={Halbleiterverbindung aus Elementen der III. Hauptgruppe des Periodensystems und Stickstoff},
first={III-Nitride}}
\newglossaryentry{MOVPE}{type=acronym, name={MOVPE},
description={Metallorganische Gasphasenepitaxie (engl. \textit{metal organic chemical vapor phase epitaxy})},
first={metallorganische Gasphasenepitaxie (MOVPE)}}
\newglossaryentry{PID}{type=acronym,name={PID-Regelkreis},
description={PID-Regelkreis (engl. \textit{proportional-integral-derivative controller})},
first={PID-Regelkreis (engl. \textit{proportional-integral-derivative controller}, PID-controller})}
%%%%%%%%%% Symbole %%%%%%%%%%%%%%%
\newglossaryentry{symb:a0}{type=acronym, name={$a_0$},
description={Gitterkonstante von GaN in \textit{a}-Richtung},
first={$a_0$}, unit={$nm$}, type=symbolslist}
\newglossaryentry{symb:c0}{type=acronym, name={$c_0$},
description={Gitterkonstante von GaN in \textit{c}-Richtung},
first={$c_0$}, unit={$nm$}, type=symbolslist}
\newglossaryentry{symb:RhoMGrpGaN}{type=acronym, name={$\rho_{M/Gr/p-GaN}$},
description={Summe der spez. Kontaktwiderstände zwischen Metallkontakt, Graphen und \textit{p}-GaN},
first={$\rho_{M/Gr/p-GaN}$}, unit={$\Omega cm^2$}, type=symbolslist}
\newglossaryentry{symb:RhoGrpGaN}{type=acronym, name={$\rho_{Gr/p-GaN}$},
description={spez. Kontaktwiderstand zwischen Graphen und \textit{p}-GaN},
first={$\rho_{M/p-GaN}$}, unit={$\Omega cm^2$}, type=symbolslist}
%%%%%%%%%% Elemente und Materialien %%%%%%%%%%%%%%%
\newglossaryentry{H2O}{name={H$_2$O},
description={Wasser-Molekül}, first={H$_2$O}, type=mater}
\newglossaryentry{Si}{name={Si},
description={Silizium}, first={Silizium (Si)}, type=mater}
\newglossaryentry{C-OH}{name={C-OH},
description={Bindung zwischen einem Kohlenstoffatom und einer OH-Gruppe}, first={C-OH}, type=mater} 
\newglossaryentry{AlGaN}{name={Al$_{x}$Ga$_{1-x}$N},
description={Aluminiumgalliumnitrid}, first={Aluminiumgalliumnitrid (Al$_{x}$Ga$_{1-x}$N)}, type=mater}
    
\cleardoublepage\phantomsection\addcontentsline{toc}{section}{Abkürzungen und Symbole}
\printglossary[type=\acronymtype, style=long, title=Abk{\"u}rzungen]
\printglossary[type=symbolslist, style=symbunitlong]
\cleardoublepage\phantomsection\addcontentsline{toc}{section}{Elemente und Materialien}
\printglossary[type=mater,style=long]

\chapter{Test}
\gls{MIGS}, \gls{UVO}, \gls{MQW}, \gls{TCF}, \gls{TL}, \gls{symb:a0}, \gls{symb:RhoMGrpGaN}, \gls{H2O}, \gls{Si}, \gls{MOVPE}, \gls{IIINitride}, \gls{C-OH}, \gls{AlGaN}, \gls{PID}
\end{document}

enter image description here

enter image description here

5
  • Welcome. // If you can, please expand your code, starting with \documentclass until \end{document} . You can fill in just brief enough statements so we can copy, run and reproduce your problem. // Reason: Latex is so powerful, hence complex, that the beginning of your code is very important and may or may not contribute to your observation.
    – MS-SPO
    Jun 28, 2022 at 9:43
  • Sure. I thought it might be too messy and long. But I've edited the whole file with all m packages and stuff and then the main part where I call for the glossaries. The "ASE.tex" just holds all the \newglossaryentry
    – Jan
    Jun 28, 2022 at 9:54
  • Please make that a single file example. It is not clear what is needed to show your example.
    – daleif
    Jun 28, 2022 at 10:11
  • Unrelated: have a look at siunitx for the proper formatting of units. and you should probably use _{\mathrm{Kanal}} to get that named index upright.
    – daleif
    Jun 28, 2022 at 10:12
  • I eddited the code into one single file.
    – Jan
    Jun 28, 2022 at 11:27

1 Answer 1

0

There are two settings to control the width:

This one for Abkürzungen and Elemente und Materialien:

\AtBeginDocument{\setlength{\glsdescwidth}{.75\columnwidth}}

Another one for Symbole, p{8.5cm} control the third column width:

\renewenvironment{theglossary}{% Change the table type --> 3 columns
  \begin{longtable}{lp{0.15\glsdescwidth}>{\arraybackslash}p{8.5cm}}}%
  {\end{longtable}}%
%

according to your comment, the automatically adjustment is nothing related to the glossaries package. To automatic adjust the the second or third column width, you need relay on xltabular and environ package to define your customized glossary style (e.g. \begin{xltabular}{\linewidth}{lX} for two column list and \begin{xltabular}{\linewidth}{lcX} for three column list). I will show you an example as follow:

\documentclass[a4paper,twoside,12pt]{report}
\usepackage{showframe}

\usepackage[
nopostdot,      
nonumberlist, 
nogroupskip, 
acronym,
section,
automake,
]      
{glossaries}

\usepackage{xltabular}
\usepackage{environ} 

\NewEnviron{symboltable}{%
    \begin{xltabular}{\linewidth}{lcX}%
        \BODY
    \end{xltabular}
}

\NewEnviron{twocoltable}{%
    \begin{xltabular}{\linewidth}{lX}%
        \BODY
    \end{xltabular}
}

\newglossary[mlg]{mater}{myi}{myg}{Elemente und Materialien}
\newglossary[slg]{symbolslist}{syi}{syg}{Symbole}

\glsaddkey{unit}{\glsentrytext{\glslabel}}{\glsentryunit}{\GLsentryunit}{\glsunit}{\Glsunit}{\GLSunit}

\makeglossaries

\newglossarystyle{symbunitlong}{%
\setglossarystyle{long3col}
\renewenvironment{theglossary}{%
\symboltable
}
{\endsymboltable}

\renewcommand*{\glossaryheader}{\textbf{Symbol} & \textbf{Einheit} & \textbf{Beschreibung}\endhead}
\renewcommand*{\glossentry}[2]{\glstarget{##1}{\glossentryname{##1}} & \glsunit{##1} & \glossentrydesc{##1}\\
}
}

\newglossarystyle{twocollong}{%
\setglossarystyle{long}
\renewenvironment{theglossary}{%
\twocoltable
}
{\endtwocoltable}

\renewcommand*{\glossaryheader}{\endhead}
}

%%%%%%%%%%%%%%%%%%% Abkürzungen %%%%%%%%%%%%%
\newglossaryentry{MIGS}{type=acronym, name={MIGS},
description={Metall induzierte Bandlückenzustände (\textit{engl.} Metal Induced Gap States (MIGS)},
first={MIGS}}
\newglossaryentry{UVO}{type=acronym, name={UVO},
description={Ultraviolett-Ozon},
first={UVO}}
\newglossaryentry{MQW}{type=acronym, name={MQW},
description={multiple Quantentöpfe (engl. \textit{multiple quantum well})},
first={multiple Quantentöpfe (MQW)}}
\newglossaryentry{TCF}{type=acronym, name={TCF},
description={transparente, leitfähige Schicht/Elektrode (engl. \textit{transparent conducting film}},
first={transparente, leitfähige Schicht/Elektrode (TCF)}}           
\newglossaryentry{TL}{type=acronym, name={T$_L$},
description={Transferlänge},
first={Transferlänge (T$_L$)}}
\newglossaryentry{IIINitride}{type=acronym, name={III-Nitride},
description={Halbleiterverbindung aus Elementen der III. Hauptgruppe des Periodensystems und Stickstoff},
first={III-Nitride}}
\newglossaryentry{MOVPE}{type=acronym, name={MOVPE},
description={Metallorganische Gasphasenepitaxie (engl. \textit{metal organic chemical vapor phase epitaxy})},
first={metallorganische Gasphasenepitaxie (MOVPE)}}
\newglossaryentry{PID}{type=acronym,name={PID-Regelkreis-longer name},
description={PID-Regelkreis (engl. \textit{proportional-integral-derivative controller})},
first={PID-Regelkreis (engl. \textit{proportional-integral-derivative controller}, PID-controller})}
%%%%%%%%%% Symbole %%%%%%%%%%%%%%%
\newglossaryentry{symb:a0}{name={$a_0$},
description={Gitterkonstante von GaN in \textit{a}-Richtung},
first={$a_0$}, unit={$nm$}, type=symbolslist}
\newglossaryentry{symb:c0}{name={$c_0$},
description={Gitterkonstante von GaN in \textit{c}-Richtung},
first={$c_0$}, unit={$nm$}, type=symbolslist}
\newglossaryentry{symb:RhoMGrpGaN}{name={$\rho_{M/Gr/p-GaN}longer symbol$},description={Summe der spez. Kontaktwiderstände zwischen Metallkontakt, Graphen und \textit{p}-GaN},
first={$\rho_{M/Gr/p-GaN}$}, unit={$\Omega cm^2$}, type=symbolslist}
\newglossaryentry{symb:RhoGrpGaN}{name={$\rho_{Gr/p-GaN}$},
description={spez. Kontaktwiderstand zwischen Graphen und \textit{p}-GaN},
first={$\rho_{M/p-GaN}$}, unit={$\Omega cm^2longer unit$}, type=symbolslist}
\newglossaryentry{symb:test1}{name={$\rho_1$},
description={spez. Kontaktwiderstand zwischen Graphen und \textit{p}-GaN},
first={$\rho_1$}, unit={$\Omega cm^2longer unit$}, type=symbolslist}
%%%%%%%%%% Elemente und Materialien %%%%%%%%%%%%%%%
\newglossaryentry{H2O}{name={H$_2$O},
description={Wasser-Molekül}, first={H$_2$O}, type=mater}
\newglossaryentry{Si}{name={Si},
description={Silizium}, first={Silizium (Si)}, type=mater}
\newglossaryentry{C-OH}{name={C-OH},
description={Bindung zwischen einem Kohlenstoffatom und einer OH-Gruppe}, first={C-OH}, type=mater} 
\newglossaryentry{AlGaN}{name={Al$_{x}$Ga$_{1-x}$N longer name test},
description={Aluminiumgalliumnitrid}, first={Aluminiumgalliumnitrid (Al$_{x}$Ga$_{1-x}$N)}, type=mater}
\glsaddall

\begin{document}
\printglossary[type=\acronymtype, style=twocollong, title=Abk{\"u}rzungen]\clearpage

\printglossary[type=symbolslist, style=symbunitlong]\clearpage

\printglossary[type=mater,style=twocollong]\clearpage
\end{document}

enter image description here enter image description here enter image description here

2
  • Thank you for your answer. Manually changing this helped and solved this issue! Just for the future. Would there be a way to automatically adjust the widht? It all depends on the longest word I use in the first row, right? So if I happen to define a longer word I'd have to manually re-adjust the widht againt. For me now this is totally fine. But maybe there is a more fancy method to do so with glossaries :)
    – Jan
    Jun 28, 2022 at 13:48
  • @Jan If you wanna automatic adjust the width, I include a example in the answer to show how to do that.
    – Tom
    Jun 29, 2022 at 0:25

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.