1

Currently I try to typeset a larger document containing a glossary and a list of acronyms. I handle those using the glossaries package. But I have problems styling it. I want it to show the description at first \gls{key} macro.

For acronyms I started to use the code from here. I just adapted it to print the text (description at first use) into the margin instead of setting up a footnote.

Now my question is how to transfer that behavior to the main glossary, which should be treated as acronym list by acronymlists={main}. Is it possible to code such a footnote style for the main glossary?

glossaries behavior

\documentclass[twoside=semi,DIV=calc,BCOR=1mm]{scrreprt}
\usepackage{scrlayer-notecolumn,xparse,tcolorbox} % for implementation
\tcbuselibrary{most}

% scrlayer-notecolumn for twoside=semi
\RedeclareNoteColumn[position=\oddsidemargin+1in+\textwidth+\marginparsep,width=\marginparwidth,font=\footnotesize]{marginpar}
\DeclareDocumentCommand{\xmarginnote}{O{0pt} +m}{%
    \makenote[marginpar]{\hbox{}\vskip#1\setlength{\parindent}{0.5pc}\setlength{\parskip}{0pt}\noindent #2}%
}

\usepackage[makeindex,acronym,acronymlists={main},nopostdot]{glossaries}
\ProvideDocumentCommand{\printglossdef}{o m}{\xmarginnote{#1: #2}}
\newacronymstyle{ex-footnote}%
    {\GlsUseAcrEntryDispStyle{footnote}}%
    {%
        \GlsUseAcrStyleDefs{footnote}%
        \renewcommand*{\genacrfullformat}[2]{%
            \firstacronymfont{\glsentryshort{##1}}##2%
            \expandafter\printglossdef\expandafter[\expandafter\glsentryshort\expandafter{##1}]{\expandafter\glsentrylong\expandafter{##1}}
        }%
        \renewcommand*{\Genacrfullformat}[2]{%
            \firstacronymfont{\Glsentryshort{##1}}##2%
            \expandafter\printglossdef\expandafter[\expandafter\Glsentryshort\expandafter{##1}]{\expandafter\glsentrylong\expandafter{##1}}
        }%
        \renewcommand*{\genplacrfullformat}[2]{%
            \firstacronymfont{\glsentryshortpl{##1}}##2%
            \expandafter\printglossdef\expandafter[\expandafter\glsentryshortpl\expandafter{##1}]{\expandafter\glsentrylongpl\expandafter{##1}}
        }%
        \renewcommand*{\Genplacrfullformat}[2]{%
            \firstacronymfont{\Glsentryshortpl{##1}}##2%
            \expandafter\printglossdef\expandafter[\expandafter\Glsentryshortpl\expandafter{##1}]{\expandafter\glsentrylongpl\expandafter{##1}}
        }%
    }
\setacronymstyle{ex-footnote}
\GlsSetQuote{*}
\newglossaryentry{hurenkind}{name={Hurenkind},plural={Hurenkinder},description={der Absatz befindet sich auf einer Seite, bis auf die als \emph{Hurenkind} bezeichnete letzte Zeile auf der nächsten}}
\newacronym{test}{TEST}{TEst is a test}
\makeglossaries

\begin{document}
    This is a test. \gls{hurenkind} does not work.\\\par
    \gls{test} is just fine.\\\par
    \printglossaries
\end{document}

1 Answer 1

1

I think you might find it easier to use the extension package glossaries-extra:

\documentclass[twoside=semi,DIV=calc,BCOR=1mm]{scrreprt}
\usepackage{scrlayer-notecolumn,xparse,tcolorbox} % for implementation
\tcbuselibrary{most}

% scrlayer-notecolumn for twoside=semi
\RedeclareNoteColumn[position=\oddsidemargin+1in+\textwidth+\marginparsep,width=\marginparwidth,font=\footnotesize]{marginpar}
\DeclareDocumentCommand{\xmarginnote}{O{0pt} +m}{%
    \makenote[marginpar]{\hbox{}\vskip#1\setlength{\parindent}{0.5pc}\setlength{\parskip}{0pt}\noindent #2}%
}

\usepackage[acronym]{glossaries-extra}

\ProvideDocumentCommand{\printglossdef}{o m}{\xmarginnote{#1: #2}}

\GlsSetQuote{*}
\makeglossaries

\newcommand{\glsxtrpostlinkmarginnote}{%<-- hook for 'marginnote' category
  \glsxtrifwasfirstuse
   {\printglossdef[\glsentryname{\glslabel}]{\glsentrydesc{\glslabel}}}{}%
}

\newglossaryentry{hurenkind}{category={marginnote},% <-- set category to 'marginnote'
 name={Hurenkind},
 plural={Hurenkinder},
 description={der Absatz befindet sich auf einer Seite, 
 bis auf die als \emph{Hurenkind} bezeichnete letzte 
 Zeile auf der nächsten}
}

\newacronym[category=marginnote]{test}{TEST}{TEst is a test}

\begin{document}
This is a test. \gls{hurenkind}.

\gls{test} is just fine.

\printglossaries

\end{document}

First page:

image of first page with marginal notes

Second page:

image of glossary

Third page:

image of acronym list

You must log in to answer this question.

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