3

I am using the scale option of a node inside of a tikzpicture in which a text with \href{}{} is hyperlinked. The hyperlinks are shown for the unscaled version of the text. This means they are at the wrong positions. How can I circumvent this problem (or what did I do wrong)? Thanks!

\documentclass{standalone}
\usepackage{tikz}
\usepackage{hyperref}

\begin{document}

\begin{tikzpicture}
    \node[scale=.2,text width=1cm] {\href{https://www.google.de}{test test test est set}};
\end{tikzpicture}

\end{document}
10
  • 3
    Is it an option to use font=\tiny or similar rather than scale? Generally, it is considered bad to scale text rather than using one of the standard sizes and it solves the hyperlink problem.
    – cfr
    Dec 12 '19 at 16:21
  • You could do \documentclass{standalone} \usepackage{tikz} \usepackage{hyperref} \begin{document} \begin{tikzpicture} \node {\href{https://www.google.de}{% \scalebox{0.2}{\begin{minipage}{1cm}test test test est set\end{minipage}}}}; \end{tikzpicture} \end{document} but I agree with @cfr that this is perhaps not good typography.
    – user194703
    Dec 12 '19 at 18:07
  • I use [align=center] instead of [text width=1cm], and it seems to be better!
    – Black Mild
    Dec 12 '19 at 18:47
  • @cfr I want to use very small fonts in my current setting, so font=\tiny and even \fontsize{1}{2} is even too large
    – Arne
    Dec 12 '19 at 20:38
  • 1
    I didn't know which borders you want. You could do \documentclass{standalone} \usepackage{tikz} \usepackage{hyperref} \begin{document} \begin{tikzpicture} \node {\scalebox{0.2}{\begin{minipage}{1cm}\href{https://www.google.de}{test test test est set}\end{minipage}}}; \end{tikzpicture} \end{document}, same reservations as above.
    – user194703
    Dec 12 '19 at 21:06
1

One way to go is to use \scalebox, which is part of graphicx that gets autoloaded by tikz.

\documentclass[tikz]{standalone} 
\usepackage{hyperref} 
\begin{document} 
\begin{tikzpicture} 
\node {\scalebox{0.2}{\begin{minipage}{1cm}\href{https://www.google.de}{test test test
est set}\end{minipage}}}; 
\end{tikzpicture} 
\end{document}

enter image description here

1
  • For me, the minipage was the crux.
    – Arne
    Dec 13 '19 at 9:34

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.