# List of acronyms alignment error using bib2gls

Recently I have learnt how to use bib2gls in order to generate list of abbreviations, acronyms, symbols, etc. There is a power full method described in previous posts.

However, once I tried to finally implement this method in the template I am using, I have one error.

Although I am using set-widest in the \GlsXtrLoadResources with style=alttree for the list of acronyms, I still have the acronyms that are not properly aligned. Why this? I really do not understand.

You can see the result in the attached figure.

In the template given by my university, I am digging in the settings to see if there is an error, but I cannot find it. There is probably something in conflict, but I do not know what. I put here the code of the main.tex file including the settings:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Settings
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\documentclass[a4paper,11pt,fleqn]{book}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french,german,english]{babel}

\usepackage{nameref}% http://ctan.org/pkg/nameref
\usepackage[cbgreek]{textgreek}

% Use of SI units
\usepackage{siunitx}

% For figures
\usepackage{graphicx}
\usepackage{xcolor}
\graphicspath{{images/}}
\usepackage{rotating} % Rotate figures
\usepackage{subfig}
% Caption package to force center of captions
\usepackage[justification=centering]{caption}

% Landscape tables and long tables
\usepackage{booktabs}
\usepackage{lscape}
\usepackage{longtable}

\usepackage{changepage}

% symbols
\usepackage{amssymb}

% Label in the figure
\newcommand{\subfigimg}[3][,]{%
\setbox1=\hbox{\includegraphics[#1]{#3}}% Store image in box
\leavevmode\rlap{\usebox1}% Print image
\rlap{\hspace*{11pt}\raisebox{\dimexpr\ht1-1\baselineskip}{#2}}% Print label
\phantom{\usebox1}% Insert appropriate spcing
}

\usepackage{fourier}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\setlength{\textwidth}{146.8mm} % = 210mm - 37mm - 26.2mm
\setlength{\oddsidemargin}{11.6mm} % 37mm - 1in (from hoffset)
\setlength{\evensidemargin}{0.8mm} % = 26.2mm - 1in (from hoffset)
\setlength{\topmargin}{-2.2mm} % = 0mm -1in + 23.2mm
\setlength{\textheight}{221.9mm} % = 297mm -29.5mm -31.6mm - 14mm (12 to accomodate footline with pagenumber)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{scrextend}

\setlength{\parindent}{0pt}

\usepackage{setspace} % increase interline spacing slightly
\setstretch{1.1}

\usepackage{lipsum}
\usepackage{microtype}
\usepackage{url}
\usepackage[final]{pdfpages}

\usepackage{fancyhdr}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\footrulewidth}{0pt}
\fancyfoot[EL,OR]{\thepage}
\fancypagestyle{plain}{
\fancyhf{}
\renewcommand{\footrulewidth}{0pt}
\fancyfoot[EL,OR]{\thepage}}
\fancyfoot{}
\fancyfoot[RO,LE]{\thepage}
}

\usepackage{listings}
\lstset{language=[LaTeX]Tex,tabsize=4, basicstyle=\scriptsize\ttfamily, showstringspaces=false, numbers=left, numberstyle=\tiny, numbersep=10pt, breaklines=true, breakautoindent=true, breakindent=10pt}

\makeatletter
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
\hbox{}
\thispagestyle{empty}
\newpage
\if@twocolumn\hbox{}\newpage\fi\fi\fi}
\makeatother \clearpage{\pagestyle{plain}\cleardoublepage}

\usepackage{color}
\usepackage{tikz}
\usepackage[explicit]{titlesec}
\newcommand*\chapterlabel{}
%\renewcommand{\thechapter}{\Roman{chapter}}
\titleformat{\chapter}[display]  % type (section,chapter,etc...) to vary,  shape (eg display-type)
{\normalfont\bfseries\Huge} % format of the chapter
{\gdef\chapterlabel{\thechapter\ }}     % the label
{0pt} % separation between label and chapter-title
{\begin{tikzpicture}[remember picture,overlay]
\node[yshift=-8cm] at (current page.north west)
{\begin{tikzpicture}[remember picture, overlay]
\draw[fill=black] (0,0) rectangle(35.5mm,15mm);
\node[anchor=north east,yshift=-7.2cm,xshift=34mm,minimum height=30mm,inner sep=0mm] at (current page.north west)
{\parbox[top][30mm][t]{15mm}{\raggedleft $\phantom{\textrm{l}}$\color{white}\chapterlabel}};  %the black l is just to get better base-line alingement
\node[anchor=north west,yshift=-7.2cm,xshift=37mm,text width=\textwidth,minimum height=30mm,inner sep=0mm] at (current page.north west)
{\parbox[top][30mm][t]{\textwidth}{\color{black}#1}};
\end{tikzpicture}
};
\end{tikzpicture}
\gdef\chapterlabel{}
} % code before the title body

\titlespacing*{\chapter}{0pt}{50pt}{30pt}
\titlespacing*{\section}{0pt}{13.2pt}{*0}  % 13.2pt is line spacing for a text with 11pt font size
\titlespacing*{\subsection}{0pt}{13.2pt}{*0}
\titlespacing*{\subsubsection}{0pt}{13.2pt}{*0}

\newcounter{myparts}
\newcommand*\partlabel{}
\titleformat{\part}[display]  % type (section,chapter,etc...) to vary,  shape (eg display-type)
{\normalfont\bfseries\Huge} % format of the part
{\gdef\partlabel{\thepart\ }}     % the label
{0pt} % separation between label and part-title
{\setlength{\unitlength}{20mm}
\begin{tikzpicture}[remember picture,overlay]
\node[anchor=north west,xshift=-65mm,yshift=-6.9cm-\value{myparts}*20mm] at (current page.north east) % for unknown reasons: 3mm missing -> 65 instead of 62
{\begin{tikzpicture}[remember picture, overlay]
\draw[fill=black] (0,0) rectangle(62mm,20mm);   % -\value{myparts}\unitlength
\node[anchor=north west,yshift=-6.1cm-\value{myparts}*20mm,xshift=-60.5mm,minimum height=30mm,inner sep=0mm] at (current page.north east)
{\parbox[top][30mm][t]{55mm}{\raggedright \color{white}Part \partlabel $\phantom{\textrm{l}}$}};  %the phantom l is just to get better base-line alingement
\node[anchor=north east,yshift=-6.1cm-\value{myparts}*20mm,xshift=-63.5mm,text width=\textwidth,minimum height=30mm,inner sep=0mm] at (current page.north east)
{\parbox[top][30mm][t]{\textwidth}{\raggedleft \color{black}#1}};
\end{tikzpicture}
};
\end{tikzpicture}
\gdef\partlabel{}
} % code before the title body

\usepackage{hyperref} % les entrées de la table des matières deviennent des liens internes au sein du pdf.
\hypersetup{pdfborder={0 0 0},
citecolor=black,
urlcolor=black}
\urlstyle{same}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Glossary
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[record,abbreviations,acronyms,symbols,%
stylemods={tree},style=treegroup]{glossaries-extra}

% always set the abbreviation style before \GlsXtrLoadResources
\setabbreviationstyle{short-long-desc}
\setabbreviationstyle[acronym]{short-long}

% Assign group titles:
\glsxtrsetgrouptitle{latin}{Latin Symbols}
\glsxtrsetgrouptitle{greek}{Greek Symbols}

src={no-interpret-preamble,acronym},% bib files
sort={en-US},% sort according to this locale
set-widest,% needed for 'alttree' styles
%  save-locations=false % use this command to pring only the acronyms you are using
selection=all,% select all entries in the .bib files
save-locations=false % do not save locations
]

src={symbols-greek},
sort={letter-case},% sort according Unicode value
symbol-sort-fallback=name,
type=symbols,
group=greek,
set-widest,% needed for 'alttree' styles
save-locations=false % do not save locations
]

src={symbols-latin},
sort={letter-case},% sort according Unicode value
symbol-sort-fallback=name,
type=symbols,
group=latin,
set-widest,% needed for 'alttree' styles
save-locations=false % do not save locations
]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Document
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}
\frontmatter % Partie préface du document

% List of acronyms
\printunsrtglossary[type=acronym,style=alttree,title={List of Acronyms}]
%List of symbols
\printunsrtglossary[type=symbols,style=alttreegroup,title={List of Symbols}]

% space before each new paragraph according to the template guidelines.
\setlength{\parskip}{1em}

\mainmatter % Corps du document

Some useful example of acronyms used for the fist time: \gls{bse}, \gls{dbtt}, \gls{hd} or \gls{wd}.

And some useful example of acronyms used for the second time: \gls{bse}, \gls{dbtt}, \gls{hd} or \gls{wd}.

Some example of greek symbols: \gls{delta}, \gls{alpha} and \gls{alphalin}.

Some example of latin symbols: \gls{a}, \gls{v} and \gls{F}.

\end{document}


There are additional files. The first one defining the acronyms. It is the acronym.bib file that shall be put also in the same folder as the main:

% acronym.bib

% This file is public domain. See the "Examples" chapter
% in the bib2gls user manual for a more detailed description
% of this file.

% Encoding: UTF-8

@acronym{bse,
short={BSE},
long={Backscattered Electrons},
identifier={acronym}
}

@acronym{dbtt,
short={DBTT},
long={Ductile-Brittle Transition Temperature},
identifier={acronym}
}

@acronym{hd,
short={HD},
long={High Definition},
identifier={acronym}
}

@acronym{wd,
short={WD},
long={Working Distance},
identifier={acronym}
}


Then, the two lists of symbols. The first one for the greek symbols, according to the symbols-greek.bib file:

% symbols-greek.bib

% Put here all greek symbols
% Encoding: UTF-8

@symbol{alpha,
name={\ensuremath{\alpha}},
description={angular acceleration},
indentifier={mathgreek}
}
@symbol{alphalin,
name={\ensuremath{\alpha_{L}}},
description={linear coefficient of thermal expansion},
indentifier={mathgreek}
}
@symbol{delta,
name={\ensuremath{\delta}},
description={Kronecker delta},
indentifier={mathgreek}
}
@symbol{lambda,
name={\ensuremath{\lambda}},
description={Lagrange multiplier},
indentifier={mathgreek}
}
@symbol{chi,
name={\ensuremath{\chi}},
description={chromatic number},
indentifier={mathgreek}
}
@symbol{rho,
name={\ensuremath{\rho}},
description={density},
indentifier={mathgreek}
}
@symbol{zeta,
name={\ensuremath{\zeta}},
description={Riemann zeta function},
indentifier={mathgreek}
}


The latin list of symbols as well (symbols-latin.bib):

% symbols-latin.bib

% Put here all latin symbols
% Encoding: UTF-8

@symbol{x,
name={\ensuremath{x}},
description={position},
indentifier={mathlatin}
}
@symbol{v,
name={\ensuremath{v}},
description={velocity},
indentifier={mathlatin}
}
@symbol{a,
name={\ensuremath{a}},
description={acceleration},
indentifier={mathlatin}
}
@symbol{t,
name={\ensuremath{t}},
description={time},
indentifier={mathlatin}
}
@symbol{E,
name={\ensuremath{E}},
description={Young's modulus},
indentifier={mathlatin}
}
@symbol{F,
name={\ensuremath{F}},
description={force},
indentifier={mathlatin}
}
@symbol{Tm,
name={\ensuremath{T_{m}}},
description={melting point temperature},
indentifier={mathlatin}
}
@symbol{KIC,
name={\ensuremath{K_{IC}}},
description={stress intensity factor},
indentifier={mathlatin}
}
@symbol{Z,
name={\ensuremath{Z}},
description={atomic number},
indentifier={mathlatin}
}


And finally, the no-interpret-preamble.bib file:

% This file is public domain. See the "Examples" chapter
% in the bib2gls user manual for a more detailed description
% of this file.

% Encoding: UTF-8

@preamble{"\providecommand{\sortname}[2]{#1 #2}
\providecommand{\sortvonname}[3]{#1 #2 #3}
\providecommand{\sortart}[2]{#1 #2}
\providecommand{\sortmediacreator}[2]{#1 #2}"}


Can someone help me with that please? I would be very thankful to you.

set-widest looks for the widest name (bib2gls documentation, page 86). However, acronyms have no name field. One solution is to copy the short field to the name field by adding replicate-fields={short=name} to the \GlsXtrLoadResources[…] that adds your acronyms. So, it would read:

\GlsXtrLoadResources[
src={no-interpret-preamble,acronym},% bib files
sort={en-US},% sort according to this locale
set-widest,% needed for 'alttree' styles
%  save-locations=false % use this command to pring only the acronyms you are using
selection=all,% select all entries in the .bib files
save-locations=false, % do not save locations
replicate-fields={short=name}
]


set-widest looking for the longest name field is the reason why adding an @entry produces the results you showed in your own answer, @entry has a name field. set-widest takes the width of the name of the @entry. This also explains why adding the @entry markdown produces a different alignment than adding LaTeX: markdown is longer than LaTeX. In other words, the alignment does not depend on the number of @entry in your bib file, but on the length of their name.

• Perfect thanks. Understood and implemented. Now it works well. – Elfo2285 Apr 10 at 9:40

By comparing codes that work, I just discovered that if I add the following code

@preamble{"\providecommand{\abbrvtag}[1]{#1}"}
@string{markuplang="\abbrvtag{m}arkup \abbrvtag{l}anguage"}

@entry{TeX,
name={{}\TeX},
description={a format for describing complex type and page layout
often used for mathematics, technical, and academic publications},
identifier={markuplanguage}
}

@entry{LaTeX,
name={{}\LaTeX},
description={a format of \glstext{TeX} designed to separate
content from style},
identifier={markuplanguage}
}

@entry{markdown,
name={markdown},
description={a lightweight markup language with plain text
formatting syntax},
identifier={markuplanguage}
}


at the beginning of the file acronym.bib, then I have the right alignment. Check the result on the following figure.

The file acronym.bib becomes:

% acronym.bib

% This file is public domain. See the "Examples" chapter
% in the bib2gls user manual for a more detailed description
% of this file.

% Encoding: UTF-8

@preamble{"\providecommand{\abbrvtag}[1]{#1}"}
@string{markuplang="\abbrvtag{m}arkup \abbrvtag{l}anguage"}

@entry{TeX,
name={{}\TeX},
description={a format for describing complex type and page layout
often used for mathematics, technical, and academic publications},
identifier={markuplanguage}
}

@entry{LaTeX,
name={{}\LaTeX},
description={a format of \glstext{TeX} designed to separate
content from style},
identifier={markuplanguage}
}

@entry{markdown,
name={markdown},
description={a lightweight markup language with plain text
formatting syntax},
identifier={markuplanguage}
}

@acronym{bse,
short={BSE},
long={Backscattered Electrons},
identifier={acronym}
}

@acronym{dbtt,
short={DBTT},
long={Ductile-Brittle Transition Temperature},
identifier={acronym}
}

@acronym{hd,
short={HD},
long={High Definition},
identifier={acronym}
}

@acronym{wd,
short={WD},
long={Working Distance},
identifier={acronym}
}


It is like the alignment depends on the number of @entry you put at the beginning of the document. In this case I have three @entry. For example, if you remove the markdown entry, you remain with two @entry, and the results becomes

I do not know why we have this behavior. It does not follow any logic. Maybe it indicates that we are with the presence of a beautiful bug??? :-)