Hyperref, tikz node and underline misalignement

With a Tikz node, there is a shift of the underline line. I use lualatex. See my related question : pdflatex vs lualatex underline mystery

\documentclass[french]{article}
\usepackage{xcolor,hyperref,tikz}

\hypersetup{%
urlcolor=blue,
urlbordercolor=blue}

\AtBeginDocument{\hypersetup{pdfborderstyle={/S/U/W .6pt}}}

\tikzset{RndBox/.style args={#1 and #2}{%
thick,
fill=#1,
inner sep=0pt,
%   outer sep=0pt,
draw=#2,
text=#2,
rounded corners=2pt,
minimum width=.6cm,
minimum height=1.25em,
text depth = 0ex,
font = \bfseries\sffamily
},
RndBox/.default={gray!25 and black}
}

\begin{document}

\href{%
https://studio.code.org/s/course3/stage/2/puzzle/1}{%
\smash{Labyrinthe}} un lien

\medskip

\tikz[anchor=base, baseline]
\node[RndBox,minimum width=20pt] {C} ;
\href{%
https://studio.code.org/s/course3/stage/2/puzzle/1}{%
\smash{Labyrinthe}} un lien

\end{document}

• It's perhaps just me, but when I compile your snippet, there are no underlines at all. Do you do something special when compiling?
– user121799
Feb 7 '18 at 15:29
• Interesting, I use lualatex and I have the underline. I just tried pdflatex and there is no underline as you mentioned it. I'll post a new question. Feb 7 '18 at 15:35
• Tikz picture needs to be overlayed or raised otherwise it defines the baseline for the underlining Feb 7 '18 at 15:44
• With overlay option there is an horizontal clash. Feb 7 '18 at 15:50

In this case, you know precisely how wide the node is. This suggests

\documentclass[french]{article}
\usepackage{xcolor,hyperref,tikz}
\usetikzlibrary{positioning}
\hypersetup{%
urlcolor=blue,
urlbordercolor=blue}

\AtBeginDocument{\hypersetup{pdfborderstyle={/S/U/W .6}}}

\tikzset{RndBox/.style args={#1 and #2}{%
thick,
fill=#1,
inner sep=0pt,
%   outer sep=0pt,
draw=#2,
text=#2,
rounded corners=2pt,
minimum width=.6cm,
minimum height=1.25em,
text depth = 0ex,
font = \bfseries\sffamily
},
RndBox/.default={gray!25 and black}
}

\begin{document}

\href{%
https://studio.code.org/s/course3/stage/2/puzzle/1}{%
\smash{Labyrinthe}} un lien

\medskip

\makebox[20pt]{\tikz[anchor=base, baseline,overlay]{
\node[RndBox,minimum width=20pt] (C) {C} ;}}
\href{%
https://studio.code.org/s/course3/stage/2/puzzle/1}{%
\smash{Labyrinthe}}
un lien

\end{document}


Here I have implements Ulrike's comment on your other question and percusse's proposal.