11

I use the Acronym package. In the printed list of acronym (usually put at the beginning of the document) there is the short version of the acronym (in bold font) and after the full name of the acronym (in normal font).

I want to change the color of the short version of each acronym to blue (for example) and keep the color of the full name of the acronym in black.

How to do it ?

\documentclass[12pt,a4paper,english,french]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8x]{inputenc}
\usepackage[frenchb]{babel}
\usepackage{lmodern}
\usepackage{xcolor}
\usepackage[withpage]{acronym}
\usepackage[colorlinks=true, linkcolor=blue]{hyperref}
\hypersetup{colorlinks=true,citecolor=blue} 

\title{My Thesis Document}
\begin{document}
\maketitle
\newpage
{\setlength{\baselineskip}{1.2\baselineskip} 
\tableofcontents\par}
\hrule
\vspace{1cm}
\section*{List of Acronyms}  
\begin{acronym} \renewcommand{\\}{}  
\acro{TTC}{Tunisian Tourism Company} % <---- Make TTC in blue for example
\acro{CBT}{Central Bank of Tunisia}
% etc
\end{acronym}
\newpage
\begin{spacing}{1.5}
\section{First Section}
Text about the \ac{TTC}, etc
\section{Second Section}
Text about the \ac{CBT}, etc
\end{spacing}
\end{document}

2 Answers 2

2

The accepted answer would not work for me. Instead, the following would do the desired job of coloring the acronym's shorthands in their listing:

\AtBeginEnvironment{acronym}{%
  \renewcommand*{\aclabelfont}[1]{\textbf{\acsfont{\color{blue}#1}}}}

This command modifies the command \aclabelfont which is used to display the shorthands.

This example shows how to use the code above:

\documentclass{article}
\usepackage{xcolor}
\usepackage{etoolbox}
\usepackage[printonlyused]{acronym}

\AtBeginEnvironment{acronym}{%
  \renewcommand*{\aclabelfont}[1]{\textbf{\acsfont{\color{blue}#1}}}}

\begin{document}

\section{List of Acronyms}
\begin{acronym}
  \acro{ML}{Machine Learning}
  \acro{NN}{Neural Networks}
  \acro{SE}{Something Else}
\end{acronym}

\section{A Section with Acronyms}
This section uses the acronyms \ac{ML} and \ac{NN}. Notice how only the colors of the acronym shorthands in the list of acronyms changes. The acronyms' color in the text does not change.

\end{document}

enter image description here

2
  • Nice solution, but I need to change the output of \acs. I tried with \renewcommand*{\acsfont}[1]{\color{blue}#1\color{black}} (and some derivatives). This doesn't work as intended, but it gets blue s in \acsp. How can it be done properly?
    – Maverick
    Commented Jan 12, 2023 at 13:50
  • Ok, so \hypersetup{linkcolor=blue} works, but it changes the color of all links (equations, etc.), so what if one wants to change only the color of \acs{} ?
    – Maverick
    Commented Jan 12, 2023 at 18:31
5

With your current settings, the List of Acronyms is typeset using a description environment, so you can change \descriptionlabel for the acronym environment using, for example:

\usepackage{etoolbox}
\AtBeginEnvironment{acronym}{%
  \renewcommand*\descriptionlabel[1]{\hspace\labelsep
                                \normalfont\bfseries\color{blue} #1}}

A complete example:

\documentclass[12pt,a4paper,english,french]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8x]{inputenc}
\usepackage[frenchb]{babel}
\usepackage{lmodern}
\usepackage{xcolor}
\usepackage{setspace}
\usepackage{etoolbox}
\usepackage[withpage]{acronym}
\usepackage[colorlinks=true, linkcolor=blue]{hyperref}
\hypersetup{colorlinks=true,citecolor=blue} 

\AtBeginEnvironment{acronym}{%
  \renewcommand*\descriptionlabel[1]{\hspace\labelsep
                                \normalfont\bfseries\color{blue} #1}}

\title{My Thesis Document}
\begin{document}
\maketitle
\newpage
{\setlength{\baselineskip}{1.2\baselineskip} 
\tableofcontents\par}
\hrule
\vspace{1cm}
\section*{List of Acronyms}  
\begin{acronym} \renewcommand{\\}{}  
\acro{TTC}{Tunisiano Tourism Company} % <---- Make TTC in blue for example
\acro{CBT}{Central Bank of Tunisia}
% etc
\end{acronym}
\newpage
\begin{spacing}{1.5}
\section{First Section}
Text about the \ac{TTC}, etc
\section{Second Section}
Text about the \ac{CBT}, etc
\end{spacing}
\end{document}

enter image description here

If you were using the optional argument for acronym with a value different than 1, then one simply would have to change \bflabel

\def\bflabel#1{{\textbf{\textsf{\color{blue}#1}}\hfill}}

You must log in to answer this question.

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