Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concise command to wrap all \ac-like commands to ensure colorless links #274

Open
tplobo opened this issue Nov 11, 2024 · 0 comments
Open

Comments

@tplobo
Copy link

tplobo commented Nov 11, 2024

Hi there @cgnieder, thanks for the package, it is great!
I currently have a difficulty with the combination of acro and hyperref, but maybe I miss some particular instruction in the acro manual.
I am trying to have links colored as usual by hyperref, but avoid the coloring for acronyms, otherwise they become very distracting in the text. The best solution I have come up with is creating a custom wrapper to locally modify hypersetup to force links to be colored in black in a small environment, and apply it using \RenewAcroCommand. However, as you can see below, this forces me to renew each \ac-like command individually:

% Define BlackLink function to color local links black
\newcommand{\BlackLink}[1]{%
    \begingroup\hypersetup{linkcolor=black}#1\endgroup
}

% Renew ac-like commands to use the BlackLink wrapper
\RenewAcroCommand\ac{m}{\BlackLink{\UseAcroTemplate{first}{#1}}}
\RenewAcroCommand\Ac{m}{\BlackLink{\acroupper\UseAcroTemplate{first}{#1}}}
\RenewAcroCommand\acp{m}{\BlackLink{\acroplural\UseAcroTemplate{first}{#1}}}
\RenewAcroCommand\Acp{m}{\BlackLink{\acroupper\acroplural\UseAcroTemplate{first}{#1}}}
\RenewAcroCommand\iac{m}{\BlackLink{\acroindefinite\UseAcroTemplate{first}{#1}}}
\RenewAcroCommand\Iac{m}{\BlackLink{\acroupper\acroindefinite\UseAcroTemplate{first}{#1}}}

% Renew acs-like commands to use the BlackLink wrapper
\RenewAcroCommand\acs{m}{\BlackLink{\UseAcroTemplate{short}{#1}}}
\RenewAcroCommand\Acs{m}{\BlackLink{\acroupper\UseAcroTemplate{short}{#1}}}
\RenewAcroCommand\acsp{m}{\BlackLink{\acroplural\UseAcroTemplate{short}{#1}}}
\RenewAcroCommand\Acsp{m}{\BlackLink{\acroupper\acroplural\UseAcroTemplate{short}{#1}}}
\RenewAcroCommand\iacs{m}{\BlackLink{\acroindefinite\UseAcroTemplate{short}{#1}}}
\RenewAcroCommand\Iacs{m}{\BlackLink{\acroupper\acroindefinite\UseAcroTemplate{short}{#1}}}

% Renew acl-like commands to use the BlackLink wrapper
\RenewAcroCommand\acl{m}{\BlackLink{\UseAcroTemplate{long}{#1}}}
\RenewAcroCommand\Acl{m}{\BlackLink{\acroupper\UseAcroTemplate{long}{#1}}}
\RenewAcroCommand\aclp{m}{\BlackLink{\acroplural\UseAcroTemplate{long}{#1}}}
\RenewAcroCommand\Aclp{m}{\BlackLink{\acroupper\acroplural\UseAcroTemplate{long}{#1}}}
\RenewAcroCommand\iacl{m}{\BlackLink{\acroindefinite\UseAcroTemplate{long}{#1}}}
\RenewAcroCommand\Iacl{m}{\BlackLink{\acroupper\acroindefinite\UseAcroTemplate{long}{#1}}}

% Renew aca-like commands to use the BlackLink wrapper
\RenewAcroCommand\aca{m}{\BlackLink{\UseAcroTemplate{alt}{#1}}}
\RenewAcroCommand\Aca{m}{\BlackLink{\acroupper\UseAcroTemplate{alt}{#1}}}
\RenewAcroCommand\acap{m}{\BlackLink{\acroplural\UseAcroTemplate{alt}{#1}}}
\RenewAcroCommand\Acap{m}{\BlackLink{\acroupper\acroplural\UseAcroTemplate{alt}{#1}}}
\RenewAcroCommand\iaca{m}{\BlackLink{\acroindefinite\UseAcroTemplate{alt}{#1}}}
\RenewAcroCommand\Iaca{m}{\BlackLink{\acroupper\acroindefinite\UseAcroTemplate{alt}{#1}}}

% Renew acf-like commands to use the BlackLink wrapper
\RenewAcroCommand\acf{m}{\BlackLink{\acrofull\UseAcroTemplate{first}{#1}}}
\RenewAcroCommand\Acf{m}{\BlackLink{\acroupper\acrofull\UseAcroTemplate{first}{#1}}}
\RenewAcroCommand\acfp{m}{\BlackLink{\acrofull\acroplural\UseAcroTemplate{first}{#1}}}
\RenewAcroCommand\Acfp{m}{\BlackLink{\acroupper\acrofull\acroplural\UseAcroTemplate{first}{#1}}}
\RenewAcroCommand\iacf{m}{\BlackLink{\acroindefinite\acrofull\UseAcroTemplate{first}{#1}}}
\RenewAcroCommand\Iacf{m}{\BlackLink{\acroupper\acroindefinite\acrofull\UseAcroTemplate{first}{#1}}}

I can make it more concise by renewing the \UseAcroTemplate command directly, but that does not use \RenewAcroCommand:

\newcommand{\BlackLink}[1]{%
    \begingroup\hypersetup{linkcolor=black}#1\endgroup
}
\let\OriginalUseAcroTemplate\UseAcroTemplate
\renewcommand{\UseAcroTemplate}[2]{\BlackLink{\OriginalUseAcroTemplate{#1}{#2}}}`

and unfortunately it does not work if I just want colorless links:

\newcommand{\ColorlessLink}[1]{%
    \begingroup\hypersetup{colorlinks=false}#1\endgroup
}
\let\OriginalUseAcroTemplate\UseAcroTemplate
\renewcommand{\UseAcroTemplate}[2]{\ColorlessLink{\OriginalUseAcroTemplate{#1}{#2}}}`

Is there a correct way of doing this using acro commands? Is defining a new template required?

Thanks,

@tplobo tplobo changed the title Concise command to wrap all \ac-like commands Concise command to wrap all \ac-like commands to ensure colorless links Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant