[Tex/LaTex] Undesired coloring of \graffito{…} in classicthesis and arsclassica

classicthesiscolor

Is any of you familiar with the classicthesis and arsclassica packages?

I am using them for my PhD thesis, they are great, but I encountered a minor problem.

classicthesis defines the \graffito{...} command which is used to add a small note on the external margin of the page. These notes are usually formatted in a smaller black italic Times font. Unfortunately, as you can see in the top part of the attached picture, if you use hyperref (or other packages) to color links (or other things like acronyms) and you have one of them spanning across two lines in where a \graffito(...) is defined, the whole note gets the color of the link.

enter image description here

I often use LaTeX to compose scientific papers, so I do not know very well how things work under the hood. I managed to isolate the following code in classicthesis sources that is responsible for \graffito{...}. I thought it was enough to add \color{black} somewhere in the forth line of the following code: the note actually becomes black, but an empty line is added (see the bottom part of the attached picture). Could you please tell me how to modify it to avoid it being colored by links? Could you please also explain me why?

% Graffiti as in GKP's book "Concrete Mathematics"
% thanks to Lorenzo Pantieri and Enrico Gregorio
\def\graffito@setup{%
   \slshape\footnotesize%  <=== I'm going to add \color{black} right here!
   \parindent=0pt \lineskip=0pt \lineskiplimit=0pt %
   \tolerance=2000 \hyphenpenalty=300 \exhyphenpenalty=300%
   \doublehyphendemerits=100000%
   \finalhyphendemerits=\doublehyphendemerits}
%\DeclareRobustCommand{\graffito}[1]{\marginpar%
% [\graffito@setup\raggedleft\hspace{0pt}{#1}]%
% {\graffito@setup\raggedright\hspace{0pt}{#1}}}
\let\oldmarginpar\marginpar
\renewcommand{\marginpar}[1]{\oldmarginpar%
 [\graffito@setup\raggedleft\hspace{0pt}{#1}]%
 {\graffito@setup\raggedright\hspace{0pt}{#1}}}

I hope the following minimal working example will help you.
Thanks in advance!

\documentclass[paper=a4,fontsize=11pt,BCOR=5mm,twoside,open=right,titlepage,
    headinclude,footinclude,captions=tableheading,numbers=noenddot,fleqn,
    cleardoublepage=empty]{scrreprt}

\usepackage[pdftex]{hyperref}
\usepackage[smaller,printonlyused,withpage]{acronym}
\usepackage[dvipsnames,svgnames,x11names,table,fixpdftex,hyperref]{xcolor}
\usepackage[eulerchapternumbers,eulermath,beramono,pdfspacing,linedheaders]{classicthesis}
\usepackage{arsclassica}

\renewcommand{\bflabel}[1]{{#1}\hfill}
\renewcommand*{\acsfont}[1]{\textsmaller{\textsf{\textsc{\textbf{\color{webgreen}{#1}}}}}}
\renewcommand*{\acffont}[1]{\textsf{\textsc{\color{webgreen}{#1}}}}

\areaset[current]{336pt}{750pt}
\setlength{\marginparwidth}{7em}
\setlength{\marginparsep}{2em}

\pdfcompresslevel=9
\pdfadjustspacing=1
\hypersetup{
    colorlinks=true, linktocpage=true, pdfstartpage=3, pdfstartview=FitV,%
    breaklinks=true, pdfpagemode=UseNone, pageanchor=true, pdfpagemode=UseOutlines,%
    plainpages=false, bookmarksnumbered, bookmarksopen=true, bookmarksopenlevel=1,%
    hypertexnames=true, pdfhighlight=/O,%nesting=true,%frenchlinks,%
    urlcolor=webbrown, linkcolor=RoyalBlue, citecolor=webgreen, %pagecolor=RoyalBlue,%
    pdftitle={The Title},%
    pdfauthor={\textcopyright\ Stefano},%
    pdfsubject={},%
    pdfkeywords={},%
    pdfcreator={pdfLaTeX},%
    pdfproducer={LaTeX with hyperref and classicthesis}%
}

\begin{document}
\cleardoublepage
\acresetall
\chapter{A Chapter} % (fold)
\label{cha:a_chapter}
An application field\graffito{Technical domains} that is often cited 
in this regard is that of \acp{WS} and \ac{SOA} in general.

\begin{acronym}[SOA]
\acro{SOA}{Service\--Oriented Architecture}
\acro{WS}{Web Service}
\end{acronym}
% chapter a_chapter (end)
\end{document}

Best Answer

Add \leavevmode before the \color command.

(See a footnote about this in the grfguide documentation of colour support in LaTeX. (Sorry, its not my fault:-)

There is a different type of problem that will occur for all drivers. Due to certain technical difficulties\footnote{At least two causes: 1) The presence of a \texttt{\char`\\special} \m{whatsit} prevents \texttt{\char`\\addvspace} ‘seeing’ space on the current vertical list, so causing it to incorrectly add extra vertical space. 2) A \m{whatsit} as the first item in a \texttt{\char`\\vtop} moves the reference point of the box.}%


\documentclass[paper=a4,fontsize=11pt,BCOR=5mm,twoside,open=right,titlepage,
    headinclude,footinclude,captions=tableheading,numbers=noenddot,fleqn,
    cleardoublepage=empty]{scrreprt}

\usepackage[pdftex]{hyperref}
\usepackage[smaller,printonlyused,withpage]{acronym}
\usepackage[dvipsnames,svgnames,x11names,table,fixpdftex,hyperref]{xcolor}
\usepackage[eulerchapternumbers,eulermath,beramono,pdfspacing,linedheaders]{classicthesis}
\usepackage{arsclassica}

\renewcommand{\bflabel}[1]{{#1}\hfill}
\renewcommand*{\acsfont}[1]{\textsmaller{\textsf{\textsc{\textbf{\color{webgreen}{#1}}}}}}
\renewcommand*{\acffont}[1]{\textsf{\textsc{\color{webgreen}{#1}}}}

\areaset[current]{336pt}{750pt}
\setlength{\marginparwidth}{7em}
\setlength{\marginparsep}{2em}

\pdfcompresslevel=9
\pdfadjustspacing=1
\hypersetup{
    colorlinks=true, linktocpage=true, pdfstartpage=3, pdfstartview=FitV,%
    breaklinks=true, pdfpagemode=UseNone, pageanchor=true, pdfpagemode=UseOutlines,%
    plainpages=false, bookmarksnumbered, bookmarksopen=true, bookmarksopenlevel=1,%
    hypertexnames=true, pdfhighlight=/O,%nesting=true,%frenchlinks,%
    urlcolor=webbrown, linkcolor=RoyalBlue, citecolor=webgreen, %pagecolor=RoyalBlue,%
    pdftitle={The Title},%
    pdfauthor={\textcopyright\ Stefano},%
    pdfsubject={},%
    pdfkeywords={},%
    pdfcreator={pdfLaTeX},%
    pdfproducer={LaTeX with hyperref and classicthesis}%
}

\makeatletter


\def\graffito@setup{%
   \slshape\footnotesize%  <=== I'm going to add \color{black} right here!
\leavevmode\color{black}%
   \parindent=0pt \lineskip=0pt \lineskiplimit=0pt %
   \tolerance=2000 \hyphenpenalty=300 \exhyphenpenalty=300%
   \doublehyphendemerits=100000%
   \finalhyphendemerits=\doublehyphendemerits}

\makeatother

\begin{document}
Related Question