4

I want to do a nomenclature list using the glossaries package. I like the print style "long", however, I would prefer if it didn't have the large indentation to the left and it also would be great if it had three columns so I could have the first column for the notation, second column for units and third for description. Minimal example of my 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

\glsaddall

\printglossary[nonumberlist, style = long, title=Nomenclature]

\end{document}

Is there a way of adjusting the glossary style "long" the way I want to?

EDIT: In case you want to see what it looks like right now using the "long" style:

1
  • Does no one here know how to change the indentation?
    – ekmanch
    Feb 21, 2014 at 7:24

1 Answer 1

7

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

enter image description here

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:

enter image description here

2
  • 1
    Thank you so much! This is great. However, would it be possible to make the notations start in line with the title (Nomenclature)? I tried to change \glsdescwidth like you did in your first example but it didn't really work the way I thought it would.
    – ekmanch
    Feb 21, 2014 at 13:39
  • @ekmanch Of course. It suffices to add the l specifier to the longtable. See the edited answer. Feb 21, 2014 at 15:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .