You can simply increase the value of the length \glsdescwidth
whose default value is 0.6\hsize
. For example, add the line
\setlength{\glsdescwidth}{0.8\hsize}
in your preamble and you'll have
Complete code:
\documentclass[12pt,a4paper]{report}
\usepackage{amsmath}
\usepackage{hyperref}
\usepackage{longtable}
\usepackage[acronym,toc,nopostdot]{glossaries}
\hypersetup{
colorlinks = true, %Colours links instead of ugly boxes
urlcolor = black, %Colour for external hyperlinks
linkcolor = black, %Colour of internal links
citecolor = black %Colour of citations
}
\newglossaryentry{resonance_angular_frequency}{
name = $\omega_0$ ,
description = [rad/s] - The angular frequency at which the imaginary part of an impedance is zero
}
\newglossaryentry{coil}{
name = $W_i$ ,
description = The coils in the magnetic circuit where 1 denotes the primary side and 2 denotes the secondary side.
}
\newglossaryentry{electric_field}{
name = $\vec{E}$ ,
description = [V/m] - Electric field
}
\newglossaryentry{magnetic_flux_density}{
name = $\vec{B}$ ,
description = [T] - Magnetic flux density
}
\makeglossaries
\setlength{\glsdescwidth}{0.8\hsize}
\begin{document}
\glsaddall
\printglossary[nonumberlist, style = long, title=Nomenclature]
\end{document}
Instead, if you want a column for units you can define a new glossary style mystyle
\newglossarystyle{mylong}{%
\renewenvironment{theglossary}%
{\begin{longtable}[l]{llp{\glsdescwidth}p{\glspagelistwidth}}}%
{\end{longtable}}%
\renewcommand*{\glossaryheader}{}%
\renewcommand*{\glsgroupheading}[1]{}%
\renewcommand{\glossentry}[2]{%
\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
\glossentrysymbol{##1} &
\glossentrydesc{##1} &
##2\tabularnewline
}%
\renewcommand{\subglossentry}[3]{%
&
\glssubentryitem{##2}%
\glossentrysymbol{##2} &
\glstarget{##2}{\strut}\glossentrydesc{##2} & ##3\tabularnewline
}%
\renewcommand*{\glsgroupskip}{%
\ifglsnogroupskip\else & & &\tabularnewline\fi}%
}
and define the units as symbols as in
\newglossaryentry{magnetic_flux_density}{
name = $\vec{B}$ ,
description = Magnetic flux density,
symbol = [T]
}
The following MWE
\documentclass[12pt,a4paper]{report}
\usepackage{amsmath}
\usepackage{hyperref}
\usepackage{longtable}
\usepackage[acronym,toc,nopostdot]{glossaries}
\hypersetup{
colorlinks = true, %Colours links instead of ugly boxes
urlcolor = black, %Colour for external hyperlinks
linkcolor = black, %Colour of internal links
citecolor = black %Colour of citations
}
\newglossaryentry{resonance_angular_frequency}{
name = $\omega_0$ ,
description = The angular frequency at which the imaginary part of an impedance is zero,
symbol = [rad/s]
}
\newglossaryentry{coil}{
name = $W_i$ ,
description = The coils in the magnetic circuit where 1 denotes the primary side and 2 denotes the secondary side.
}
\newglossaryentry{electric_field}{
name = $\vec{E}$ ,
description = Electric field,
symbol = [V/m]
}
\newglossaryentry{magnetic_flux_density}{
name = $\vec{B}$ ,
description = Magnetic flux density,
symbol = [T]
}
\makeglossaries
\newglossarystyle{mylong}{%
\renewenvironment{theglossary}%
{\begin{longtable}[l]{llp{\glsdescwidth}p{\glspagelistwidth}}}%
{\end{longtable}}%
\renewcommand*{\glossaryheader}{}%
\renewcommand*{\glsgroupheading}[1]{}%
\renewcommand{\glossentry}[2]{%
\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
\glossentrysymbol{##1} &
\glossentrydesc{##1} &
##2\tabularnewline
}%
\renewcommand{\subglossentry}[3]{%
&
\glssubentryitem{##2}%
\glossentrysymbol{##2} &
\glstarget{##2}{\strut}\glossentrydesc{##2} & ##3\tabularnewline
}%
\renewcommand*{\glsgroupskip}{%
\ifglsnogroupskip\else & & &\tabularnewline\fi}%
}
\begin{document}
\glsaddall
\printglossary[nonumberlist, style = mylong, title=Nomenclature]
\end{document}
produces the following result:
Is this a bug?
No, it's a documented feature. From Defining Glossary Entries:
Avoid using any of the \gls
-like or \glstext
-like commands within the
text
, first
, short
or long
keys (or their plural equivalent) or any
other key that you plan to access through those commands. (For
example, the symbol
key if you intend to use \glssymbol
.) Otherwise
you end up with nested links, which can cause complications and they
won’t work with the case-changing commands. You can use them within
the value of keys that won’t be accessed through those commands. For
example, the description
key if you don’t use \glsdesc
. Additionally,
they’ll confuse the entry formatting commands, such as \glslabel
.
From Acronyms and Other Abbreviations:
Recall from the warning in §4 Defining Glossary Entries that you
should avoid using the \gls
-like and \glstext
-like commands within the
value of keys like text
and first
due to complications arising from
nested links. The same applies to abbreviations defined using
\newacronym
.
For example, suppose you have defined:
\newacronym{ssi}{SSI}{server side includes}
\newacronym{html}{HTML}{hypertext markup language}
you may be tempted to do:
\newacronym{shtml}{S\gls{html}}{\gls{ssi} enabled \gls{html}}
Don’t! This will break the case-changing commands, such as \Gls
, it
will cause inconsistencies on first use, and, if hyperlinks are
enabled, will cause nested hyperlinks. It will also confuse the
commands used by the entry formatting (such as \glslabel
).
Instead, consider doing:
\newacronym
[description={\gls{ssi} enabled \gls{html}}]
{shtml}{SHTML}{SSI enabled HTML}
or
\newacronym
[description={\gls{ssi} enabled \gls{html}}]
{shtml}{SHTML}
{server side includes enabled hypertext markup language}
The reason why the problem isn't noticeable if you remove \setacronymstyle
is related to this bit:
Additionally, they’ll confuse the entry formatting commands, such as \glslabel
.
The newer method of using \setacronymstyle
uses the new style of entry formatting that relies on \glslabel
, which can't be scoped as the post-link hook needs to be able to both look forwards (for example, the discardperiod
attribute requires this) and effectively look backwards, to know the information about the entry that has just been referenced. You can explicitly add the scoping yourself. For example:
\newacronym{OBS}{OBS}{{\gls{glsOBS}}}
However, this essentially just papers over the most noticeable symptom, whilst ignoring all the other associated problems that are listed in Nested Links.
The best solution is:
\newacronym
[description={\gls{glsOBS}}]
{OBS}{OBS}{Organizational Breakdown Structure}
The next best solution is:
\newacronym
[description={\gls{glsOBS}}]
{OBS}{OBS}{\glsentrytext{glsOBS}}
but don't use \Gls{OBS}
with this method.
Alternatively, with glossaries-extra
:
\newacronym{OBS}{OBS}{\glsxtrtext{glsOBS}}
but, again, don't use \Gls{OBS}
.
Best Answer
The main problem here is that the top level entries (denoting the Greek and Latin entries) are in the first column of the table, so that column must be at least as wide as those headings. There are a number of ways to resolve this.
The first method adjusts the style to make the top-level entries span both columns. It's more efficient to move the font changing commands out of the
name
field and put them in the style. This assumes that all your top-level entries are actually headers.Note that as from version 4.0, the style commands
\glossarystyle
,\glossaryentryfield
and\glossarysubentryfield
are all deprecated. You can still use them but you'll get a warning. To update to the newer commands, you need to make the following substitutions:\glossarystyle{
style-name}
->\setglossarystyle{
style-name}
\glossaryentryfield{
label}{
name}{
description}{
symbol}{
location}
replace with:\glossentry{
label}{
location}
\glossentryname{
label}
.\glossentrydesc{
label}
.\glossentrysymbol{
label}
.\glsentryuseri{
label}
described in section 9: Using Glossary Terms Without Links of the user manual.\glossarysubentryfield{
level}{
label}{
name}{
description}{
symbol}{
location}
replace with:\subglossentry{
level}{
label}{
location}
The fields can be accessed as above.
Here's a modified version that uses the newer commands and makes the top-level entries span both columns:
The result is:
The first column is now just wide enough to fit the widest sub-entry. A dotted leader can be added to the style with
\dotfill
but it will be barely noticeable with just a single dot for the narrower symbol (omega).Here's a variation that makes the left column 2cm wide and adds a leader:
This produces:
The gap between the columns can be shrunk by reducing the value of
\tabcolsep
. For example:This produces:
Alternatively, you can remove it completely with
@{}
in the column specifier:Or to use up the entire line width:
The second method is to remove the hierarchy and have separate glossaries for each type of symbol and use the
alttree
style. For example:This produces:
This method means that you manually order the two symbol lists, which makes it easier to have the Latin list before the Greek list if you prefer.
The third method is only available with the
glossaries-extra
extension package using thegroup
field and\printunsrtglossary
. You can manually arrange the symbols so that they are listed in order of definition (no external tool required):This produces:
If you want the sorting performed by an external tool, you can combine this method with
bib2gls
but this is currently not available with Overleaf. (For a similar example, see thesample-textsymbols.tex
document described in the "Examples" chapter of thebib2gls
documentation.)