1

I am using the package acro and I store all the definition in a file:

\usepackage{acro}
\input{./acronyms.tex}

It works perfectly using \ac{bla}.

Now, I would like to have always colorful acronyms along with the whole document, with no need to go thought all the definitions I have inserted. Is there a simple way of doing it?

(for example I know I can always do \textcolor{blue}{\ac{bla}}. However, the solution is unfeasible with the huge document I have. Another solution is to use a python script to surround every \ac{..} with textcolor. I would avoid the last solution if there exist another way)

1

You have two ways:

  1. If you want to have acronyms of different colors (and to color only the long or the short) you can color it in the definition
  2. If you want to color all the acronyms in the same way you can define a new command which calls \ac inside a \textcolor
\documentclass{standalone}

\usepackage{acro}
\usepackage{xcolor}

\DeclareAcronym{cd1}{
    short = CD ,
    long  = \textcolor{blue}{compact disc}
}

\DeclareAcronym{cd2}{
    short = CD ,
    long  = compact disc
}

\newcommand*\myac[1]{\textcolor{blue}{\ac{#1}}}

\begin{document} 
   Test1: \ac{cd1}.\\
   Test2: \myac{cd2}.
\end{document}

You can also redefine the \ac command:

\let\oldac\ac
\renewcommand*\ac[1]{\textcolor{blue}{\oldac{#1}}}
1
  • 1
    the last option is the one I was looking for! – Leos313 Jun 3 '20 at 13:41
3

You can add any color you want either individually for a certain acronym or for all acronyms using the options short-format, long-format or format (there are more options, please see the manual for all details).

\documentclass{article}

\usepackage{acro}
\usepackage{xcolor}

\DeclareAcronym{cd1}{
  short = CD1 ,
  long  = compact disc one ,
  format = \textcolor{blue}
}

\DeclareAcronym{cd2}{
  short = CD2 ,
  long  = compact disc two
}

\DeclareAcronym{cd3}{
  short = CD3 ,
  long  = compact disc three
}

\acsetup{
  format = \textcolor{green}
}

\begin{document} 

\ac{cd1} \ac{cd2} \ac{cd3} \par
\ac{cd1} \ac{cd2} \ac{cd3}

\end{document}

enter image description here

2
  • is there a way of having the acronyms "cliccable"? – Leos313 Jun 3 '20 at 13:54
  • 3
    @Leos313 yes, check the acro manual for hyperref support – cgnieder Jun 3 '20 at 13:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.