[Tex/LaTex] Create custom [type=\acronymtype] for \printglossary

acronymsglossaries

I am nearly where I want to get with my document set-up but I am missing a custom Acronymtable for it. With the help of the community I got a good style for my Symbol/Unit List:

\documentclass{article} \usepackage{lipsum} \usepackage{siunitx}

\usepackage[acronym,toc]{glossaries}              % use glossaries-package \setlength{\glsdescwidth}{12cm} \usepackage{glossary-longbooktabs}

\newglossary[slg]{unitlist}{syi}{syg}{Verzeichnis der Kurzzeichen} % create add. symbolslist \glsaddkey{unit}{\glsentrytext{\glslabel}}{\glsentryunit}{\GLsentryunit}{\glsunit}{\Glsunit}{\GLSunit} \makeglossaries                                   % activate glossaries-package

%=================================================================== %Einträge Einheitenverzeichnis %===================================================================

   \newglossaryentry{m}{name=\ensuremath{m},
    description={Meter},
    unit={\si{m}},
    type=unitlist}

    \newglossaryentry{symb:Pi}{name=\ensuremath{\pi},
    description={Geometrischer Wert},
    unit={},
    type=unitlist}

    \newglossaryentry{energyconsump}{
    name=\ensuremath{P},
    description={Leistung},
    unit={\si{kW}},
    type=unitlist}

\glsnoexpandfields  \newglossaryentry{sqkm}{
    name=\ensuremath{A},
    description=Quadratkilometer Quadratkilometer Quadratkilometer Quadratkilometer Quadratkilometer,
    unit=\si{\square\kilo\metre},
    type=unitlist}

%=================================================================== %Stilvorlage %===================================================================

\newglossarystyle{3colger}{%
    \setglossarystyle{longragged3col}% base this style on the list style
    \renewenvironment{theglossary}{% Change the table type --> 3 columns
     % compute the description width
        \settowidth{\dimen0}{\bfseries Zeichen}%
        \settowidth{\dimen1}{\bfseries Einheit}%
        \glsdescwidth=\dimexpr\linewidth-\dimen0-\dimen1-6\tabcolsep\relax
        \begin{longtable}{l l p{\glsdescwidth}}}%
        {\end{longtable}}%
    %
    \renewcommand*{\glossaryheader}{%  Change the table header
        \bfseries Zeichen & \bfseries Einheit & \bfseries Beschreibung \\
        %       \hline
        \vspace{0.05cm}
        \endhead}
    \renewcommand*{\glossentry}[2]{%  Change the displayed items
        \glstarget{##1}{\glossentryname{##1}} %
        & \glsunit{##1}
        &  \glossentrydesc{##1}  \tabularnewline
    } }

\begin{document}
    \lipsum[2-4] \glsaddall \printglossary[type=unitlist,style=3colger]  \end{document}

I now need my Acronym table (Verzeichnis der Abkürzungen) match this spacing, but I do not know how to generate a custom style I can use with

\printglossary[type=\acronymtype,title=Verzeichnis der Abkürzungen] 

It should basically be a 2column table with no page references and a header.The \acronymtype has no header and I would need to adjust the width of the first column so the second column is flush with the second column of my symbol/unit list (Verzeichnis der Kurzzeichen)

I also tried using \printglossary[type=unitlist,style=2colacro]with the style colacro:

\renewcommand*{\glossaryheader}{%  Change the table header
\bfseries Zeichen & \bfseries Einheit & \bfseries Beschreibung \\
\vspace{0.05cm}
    \endhead}
    \renewcommand*{\glossentry}[2]{%  Change the displayed items
        \glstarget{##1}{\glossentryname{##1}} %
        & \glsunit{##1}
        &  \glossentrydesc{##1}  \tabularnewline
    }
}

But than all entries from from the Symbol/unit glossary are included as well. using another type does not seem to work either… Any ideas?

Best Answer

Figured it out:

Used this in the preamble:

    \usepackage[acronym,toc]{glossaries}
                 % use glossaries-package
    \setlength{\glsdescwidth}{12cm}
    \usepackage{glossary-longbooktabs}

    \newglossary[slg]{unitlist}{syi}{syg}{Verzeichnis der Kurzzeichen}
    %\newglossary[alg]{acronym}{acr}{acn}{Verzeichnis der Abkürzungen} % create add. symbolslist
    \glsaddkey{unit}{\glsentrytext{\glslabel}}{\glsentryunit}{\GLsentryunit}{\glsunit}{\Glsunit}{\GLSunit}

\makeglossaries                                   % activate glossaries-package

This are my test entries for both Units and Acronyms:

  \newglossaryentry{m}{name=\ensuremath{m},
        description={Meter},
        unit={\si{m}},
        type=unitlist}

        \newglossaryentry{symb:Pi}{name=\ensuremath{\pi},
        description={Geometrischer Wert},
        unit={},
        type=unitlist}

        \newglossaryentry{energyconsump}{
        name=\ensuremath{P},
        description={Leistung},
        unit={\si{kW}},
        type=unitlist}

     \newglossaryentry{cd}{
        name=CD,
        description=Quadratkilometer Quadratkilometer Quadratkilometer Quadratkilometer Quadratkilometer,
        unit=,
        type=acronym}

    \newacronym{bzw}{bzw.}{Beziehungsweise}

Those are my two styles for the symbols/units and the acronyms:

\newglossarystyle{3colger}{%
    \setglossarystyle{longragged3col}% base this style on the list style
    \renewenvironment{theglossary}{% Change the table type --> 3 columns
        \settowidth{\dimen0}{\bfseries Zeichen}%
        \settowidth{\dimen1}{\bfseries Einheit}%
        \glsdescwidth=\dimexpr\linewidth-\dimen0-\dimen1-4\tabcolsep\relax
        \begin{longtable}{@{}l l p{\glsdescwidth}@{}}}%
        {\end{longtable}}%
    %
    \renewcommand*{\glossaryheader}{%  Change the table header
        \bfseries Zeichen & \bfseries Einheit & \bfseries Beschreibung \\
        %       \hline
        \vspace{0.05cm}
        \endhead}
    \renewcommand*{\glossentry}[2]{%  Change the displayed items
        \glstarget{##1}{\glossentryname{##1}} %
        & \glsunit{##1}
        &  \glossentrydesc{##1}  \tabularnewline
    }
}


\newglossarystyle{2colacro}{%
    \setglossarystyle{longragged}% base this style on the list style
    \renewenvironment{theglossary}{% Change the table type --> 3 columns
        \settowidth{\dimen0}{\bfseries Abkürzung}%
%       \settowidth{\dimen1}{\bfseries Beschreibung}%
        \glsdescwidth=\dimexpr\linewidth-\dimen0-\dimen1-4\tabcolsep\relax
        \begin{longtable}{@{}l p{\glsdescwidth}@{}}}%
        {\end{longtable}}%
    %
    \renewcommand*{\glossaryheader}{%  Change the table header
        \bfseries Abkürzung & \bfseries Beschreibung \\
        %       \hline
        \vspace{0.05cm}
        \endhead}
    \renewcommand*{\glossentry}[2]{%  Change the displayed items
        \glstarget{##1}{\glossentryname{##1}} %
        &  \glossentrydesc{##1}  \tabularnewline
    }
}

And finally how to print them:

\printglossary[type=unitlist,style=3colger]
\printglossary[type=acronym,style=2colacro,title=Verzeichnis der Abkürzungen]