1

In the document I want to apply this to, I have a long glossary, formatted with the longheaderborder style. Rows of all tables in the document have alternating background colors. I style the top row/header of each table with \rowcolor{headercolor}. I just can't seem to get it to work with the glossary.

Below is a MWE (not really working though) of what I attempted. The colors used are not the colors I really want to use, but they are very noticeable for this example

I tried redefining the \glossaryheader with the \rowcolor{blue} I wanted to use. I also tried to color each cell separately with \cellcolor{red}. As you may notice, no blue or red occur in the table, only yellow and green of \rowcolors{0}{yellow}{green}, which I have included to demonstrate that xcolor at least has some effect on the glossary.

So: how can I change the background color of the top row of a glossary, styled with longheaderborder?

The example:

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage[automake,nogroupskip]{glossaries-extra}

\renewcommand*{\glossaryheader}{\rowcolor{blue} \bfseries Notation & \cellcolor{red} \bfseries Description\\\hline}
\makeglossaries

\newglossaryentry{MWE}{
  name={MWE},
  description={Minimal working example}
}
\newglossaryentry{ex}{
  name={ex.},
  description={example}
}
\newglossaryentry{I}{
  name={I},
  description={the author}
}

\begin{document}
This is a \gls{MWE}. It is an \gls{ex} of what \gls{I} want.

{
\rowcolors{0}{yellow}{green}
\printglossary[style=longheaderborder]
}
\end{document}

Generated output: Demonstration of above code. The header row of the glossary is yellow, while I expected it to be multicolored blue and red.

2
  • Replacing \renewcommand*{\glossaryheader}{ \bfseries Notationzzrtt & \cellcolor{red} \bfseries Description\\\hline} with \renewcommand*\entryname{\cellcolor{blue} Name} \renewcommand*\descriptionname{\cellcolor{red} Description} should work.
    – leandriis
    Commented Jul 22, 2020 at 20:22
  • Thanks! This seems to work for the MWE, but didn't in my main document. It turns out that this breaks when using \usepackage[english]{babel}. Replacing \usepackage[automake,nogroupskip]{glossaries-extra} with \usepackage[automake,nogroupskip,translate=false]{glossaries-extra} does work, but if I want any translations of the terms, I have to provide them myself. That's fine for now!
    – pkok
    Commented Jul 22, 2020 at 21:46

1 Answer 1

2

As commented by leandriis, replacing \renewcommand*{\glossaryheader}{ \bfseries Notationzzrtt & \cellcolor{red} \bfseries Description\\\hline} with \renewcommand*\entryname{\cellcolor{blue} Name} \renewcommand*\descriptionname{\cellcolor{red} Description} works in the above MWE.

When using \usepackage[english]{babel} (or any other language), this breaks. Telling glossaries-extra that you want to provide your own translations for everything lets you adjust colors though. That means that in the above MWE, I replaced \usepackage[automake,nogroupskip]{glossaries-extra} with \usepackage[automake,nogroupskip,translate=false]{glossaries-extra}, and it all worked!

You must log in to answer this question.

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