cgnieder / acro

acronyms for LaTeX
LaTeX Project Public License v1.3c
41 stars 9 forks source link

Make public the `glossary` template? #238

Open dbitouze opened 2 years ago

dbitouze commented 2 years ago

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?

cgnieder commented 2 years ago

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…?)

dbitouze commented 2 years ago

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

cgnieder commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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.

dbitouze commented 2 years ago

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:

cgnieder commented 2 years ago

I take this as a feature request ;)