0

enter image description hereI'm using hyperref for clickable links in my document and acro for acronyms.

I aim to retain colored links in the PDF viewer, either with colored rectangles or colored text. However, I don't want to print them in color on physical paper.

I found a helpful solution here for printing url-links, Table of Contents/List of Figures, citations, and references to figures in black, while keeping the links red in the PDF viewer. I've used \usepackage[ocgcolorlinks]{ocgx2} to achieve this.

Although hidelinks-option would be a quick fix, allowing me to print everything in black, it would make all links invisible in the PDF viewer.

Nevertheless, the acronyms are still printed in red on paper. Is there a way to avoid this? I appreciate any help!

Here my MWE:

\documentclass[%
    paper=a4,
    oneside=true,
    bibliography=totoc,
    listof=notnumbered,
    numbers=noenddot,
    parskip=half,
    headsepline,
    footsepline,
    fontsize=12pt
]{scrreprt}
\KOMAoptions{listof=entryprefix}
\usepackage[ngerman, english]{babel}
\usepackage[T1]{fontenc}
\usepackage{lipsum}
\usepackage{url}

\usepackage{hyperref} %hidelinks \usepackage[ocgcolorlinks]{ocgx2}

\usepackage{acro} \acsetup{make-links = true, list/sort=true}

\DeclareAcronym{fir}{ short = {FIR}, long = {finite impulse response} } \DeclareAcronym{ofdm}{ short = {OFDM}, long = {orthogonal frequency division multiplexing} }

\begin{document}

\tableofcontents

\chapter{One} \section{Section One} In signal processing, a \ac{fir} filter is a filter with finite impulse response. \acp{fir} filters can be discrete-time or continuous-time.

\section{Section Two} In \ac{ofdm}, several bits can be sent in parallel, or at the same time, in separate substream channels. With \ac{ofdm}, the subchannel frequencies are close together and overlapping but are still orthogonal.

\chapter{Two} \lipsum[1] \par\url{www.foo.com}

\end{document}

Ian
  • 49

1 Answers1

1

acro disables the ocgsupport as it prints the links in two parts (with a phantom and a \llap-box). You could try something like this:

\documentclass[%
    paper=a4,
    oneside=true,
    bibliography=totoc,
    listof=notnumbered,
    numbers=noenddot,
    parskip=half,
    headsepline,
    footsepline,
    fontsize=12pt
]{scrreprt}
\KOMAoptions{listof=entryprefix}
\usepackage[ngerman, english]{babel}
\usepackage[T1]{fontenc}
\usepackage{lipsum}
\usepackage{url}

\usepackage{hyperref} %hidelinks \usepackage[ocgcolorlinks]{ocgx2}

\usepackage{acro} \acsetup{make-links = true, list/sort=true}

\DeclareAcronym{fir}{ short = {FIR}, long = {finite impulse response} } \DeclareAcronym{ofdm}{ short = {OFDM}, long = {orthogonal frequency division multiplexing} }

\makeatletter \ExplSyntaxOn \tl_set:Nn\l_ocgxii_lnkcol_tl{{red}} \cs_set:Npn __acro_color_link:n #1 { \bool_lazy_and:nnTF { \cs_if_exist_p:N \hypersetup } { \bool_lazy_or_p:nn { \legacy_if_p:n {Hy@colorlinks} } { \legacy_if_p:n {Hy@ocgcolorlinks} } } { \ocgxii_colourlink_begin: #1 \ocgxii_colourlink_end:} {#1} } \ExplSyntaxOff \begin{document} \section{a}\label{a} \ref{a}

\ac{fir} filter is a filter with finite impulse response. \acp{fir}

\end{document}

Ulrike Fischer
  • 327,261
  • Ty for your solution. It works, BUT one should avoid having acronyms in captions of figures or in sections' titles otherweise there will be missing text in the ToC / LoF / LoA of the printed document. Is there any solution for this? – Ian Nov 22 '23 at 00:42
  • 1
    Try with the hyperref option linktoc=page. – Ulrike Fischer Nov 22 '23 at 07:05
  • It works, but, again, there is an issue with the acronyms. They are automatically printed in full version. – Ian Nov 23 '23 at 09:12
  • sorry but I doubt that this has anything to do with ocgx, so better ask a new question. – Ulrike Fischer Nov 23 '23 at 09:34