acro icon indicating copy to clipboard operation
acro copied to clipboard

Make public the `glossary` template?

Open dbitouze opened this issue 2 years ago • 7 comments

The (abstract of the) documentation claims that acro can also be used for glossaries or nomenclatures. And indeed, a glossary can be found in it, which it is typeset thanks to the glossary template

\printacronyms[include=glossary,template=glossary]

But this template is private:

\NewAcroTemplate[list]{glossary}{%
...

(defined in acro-manual.cls only). Is there any reason for no making it public?

dbitouze avatar Mar 14 '22 13:03 dbitouze

Well, it's neither really private as the code of the manual class is public nor is it very complex:

\NewAcroTemplate[list]{glossary}{%
  \begin{description}
    \acronymsmapF{%
      \item[\sffamily\acrowrite{short}] \acrowrite{long}%
    }%
    { \item \AcroRerun }%
  \end {description}
}

To be honest it is just a very simple version of the default template:

\NewAcroTemplate[list]{description}{%
  \acroheading
  \acropreamble
  \begin{description}
    \acronymsmapF{%
      \item[\acrowrite{short}\acroifT{alt}{/}\acrowrite{alt}]
        \acrowrite{list}%
        \acroifanyT{foreign,extra}{ (}%
        \acrowrite{foreign}%
        \acroifallT{foreign,extra}{, }%
        \acrowrite{extra}%
        \acroifanyT{foreign,extra}{)}%
        \acropagefill
        \acropages{\acrotranslate{page}~}{\acrotranslate{pages}~}%
    }
    { \item \AcroRerun }%
  \end{description}
}

The only reason for the template definition in the manual is the \sffamily in the items…

(Which reminds that there should maybe be a possibility to set the format of the short forms in the list…?)

cgnieder avatar Mar 14 '22 14:03 cgnieder

Sorry, I wrote "private" whereas I meant "available and documented". In fact, examples of a glossary and of a nomenclature would be welcome :smile:

dbitouze avatar Mar 14 '22 15:03 dbitouze

As an example for a simple glossary the acro manual does

\NewAcroTemplate[list]{glossary}{%
  \begin{description}
    \acronymsmapF{%
      \item[\sffamily\acrowrite{short}] \acrowrite{long}%
    }%
    { \item \AcroRerun }%
  \end {description}
}

and defines the terms using the tag property:

\DeclareAcronym{property}{
  long = A \property*{property} is an option to the second argument of the
    \cs*{DeclareAcroym} command.  They are options of an individual acronym if
    you will. ,
  tag = glossary , no-index
}

The glossary then is printed like this:

\section{Glossary}
\printacronyms[include=glossary,template=glossary]

cgnieder avatar Mar 16 '22 09:03 cgnieder

A more “nomenclature” like example is the following

\documentclass{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{acro}
\acsetup{
  list/display = all ,
  pages/display = first ,
  pages/name = true
}

\usepackage{longtable,siunitx}
\DeclareAcroProperty{unit}
\NewAcroTemplate[list]{physics}{
  \setlength\LTleft{0pt}%
  \setlength\LTright{0pt}%
  \acsetup{ pages/display = all }%
  \acroheading
  \acropreamble
  \acronymsmapF{%
    \AcroAddRow{
      \acrowrite{short} &
      \acrowrite{unit} &
      \acrowrite{list}  &
      \acroifpagesT{(S.~\acropages{}{})} \\
    }%
  }{\AcroRerun}
  \begin{longtable}{@{}lll@{\extracolsep{\fill}}l@{}}
    \bfseries\sffamily Symbol & \bfseries\sffamily Einheit &
    \bfseries\sffamily Name & \\ \endhead
    \AcronymTable
  \end{longtable}
}

\DeclareAcronym{ecm}{
  short = ECM ,
  long  = Electro Chemical Machining ,
  extra = Elektrochemisches Abtragen
}
\DeclareAcronym{adc}{
  short = ADC ,
  long  = Analog-to-Digital-Converter
}
\DeclareAcronym{edm}{
  short = EDM ,
  long  = Electro Discharge Machining
}
\DeclareAcronym{ecdm}{
  short = ECDM ,
  long  = Electro Chemical Discharge Machining ,
  extra = Kombination aus \acs{ecm} und \acs{edm}
}

% "Acronyme" (tatsächlich physikalische Größen) einer speziellen Klasse:
\DeclareAcronym{f}{
  short = \ensuremath{f} ,
  long  = Frequenz ,
  unit  = \unit{\hertz} ,
  tag = physics
}
\DeclareAcronym{A}{
  short = \ensuremath{A} ,
  long  = Fläche ,
  unit  = \unit{\metre^2} ,
  tag = physics
}
\DeclareAcronym{C}{
  short = \ensuremath{C} ,
  long  = Kapazität ,
  unit  = \unit{\farad} ,
  tag = physics
}
\DeclareAcronym{F}{
  short = \ensuremath{F} ,
  long  = Kraft ,
  unit  = \unit{\newton} ,
  tag = physics
}

\begin{document}

erstes Mal: \ac{ecm}

zweites Mal: \ac{ecm}

\ac{F}

% alle außer der Klasse 'physics' auflisten:
\printacronyms[exclude=physics, name=Abkürzungsverzeichnis]

% nur die Klasse 'physics' auflisten:
\printacronyms[include=physics, name=Formelverzeichnis,template=physics]

\end{document}

cgnieder avatar Mar 16 '22 09:03 cgnieder

What both examples are missing are divisions are divisions into groups (let's say alphabetical or as in the nomencl manual Latin and Greek letters…). Such divisions can only be done manually by using tags in the definitions of the “acronyms” and by using several instances of \printacronyms.

cgnieder avatar Mar 16 '22 09:03 cgnieder

What both examples are missing are divisions are divisions into groups (let's say alphabetical or as in the nomencl manual Latin and Greek letters…). Such divisions can only be done manually by using tags in the definitions of the “acronyms” and by using several instances of \printacronyms.

OK so, for this purpose, the packages glossaries and glossaries-extra (maybe among others) are more convenient: too bad for those who would like to stick with acro! :smile:

dbitouze avatar Mar 16 '22 15:03 dbitouze

I take this as a feature request ;)

cgnieder avatar Mar 16 '22 17:03 cgnieder