12

How can I rotate the link of a text in a node. Here is my MWE:

\documentclass{article}
\usepackage{tikz}
\usepackage{hyperref}

\begin{document}

\begin{tikzpicture}
\node (rect) [rectangle, fill=blue, rotate=90] {\hyperlink{rec}{Damn it!}};
\end{tikzpicture}

\end{document}

I can get rid of the box surrounding the text obviously but this does not solve my problem.

Additionally, any way that I can link the node itself, that is the shape such as a rectangle, circle, etc?


Thanks all for the answers but I think my MWE was to minimal. To answer the answers below:

  • with \rotatebox the shape changes,
  • and I cannot hyperlink the whole environment because I have other nodes.

So here is the new MWE: I would like the shape as in "shape ok" but the link as in "link ok" box; and just rotate and link one of the nodes.

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{positioning}
\tikzstyle{block} =[fill=red!20, rectangle, minimum height=1cm, minimum width=2cm]

\begin{document}

\begin{frame}
\makebox[\textwidth][c]{%
\begin{tikzpicture}%
\node (rect1) [block, rotate=90] {\hyperlink{link}{shape ok}};
\node (rect2) [block, above=2cm of rect1] {\rotatebox{90}{\hyperlink{link}{link ok}}};
\end{tikzpicture}}%
\end{frame}

\end{document}
0

3 Answers 3

8

This has slightly different link spacing, but it works: Just put the entire rotated content in the \hyperlink:

\documentclass{article}
\usepackage{tikz}
\usepackage{hyperref}

\begin{document}

\hyperlink{rec}{%
\begin{tikzpicture}
\node (rect) [rectangle, fill=blue, rotate=90] {Damn it!};
\end{tikzpicture}%
}

\end{document}

3
  • When i use \rotatebox, the shape of the node changes. ANy idea why?
    – jejuba
    Oct 3, 2011 at 0:21
  • No, no idea, sorry. I came to my answer by logic only, I usually draw and rotate few things only.
    – doncherry
    Oct 3, 2011 at 8:39
  • OK, thanks. I'll keep looking and post something if I find an answer. I guess I could create some kind of invisible node, over that one, with just the link...
    – jejuba
    Oct 3, 2011 at 17:17
6

For this specific effect you could also use adjustbox in one of the following ways. As a nice side-effect you can even use verbatim content.

\documentclass{article}
\usepackage{xcolor}
\usepackage{adjustbox}
\usepackage{hyperref}

\begin{document}

\adjustbox{angle=90,margin=2pt,bgcolor=blue}{\hyperlink{rec1}{Damn it!}}
%
\hyperlink{rec2}{\adjustbox{angle=90,margin=2pt,bgcolor=blue}{Damn it!}}
%
\adjustbox{angle=90,margin=2pt,bgcolor=blue,precode=\hyperlink{rec3}}{Damn it!}
%
\newcommand{\bluehyperlink}[1]{%
    \adjustbox{angle=90,margin=2pt,bgcolor=blue,precode=\hyperlink{#1}}%
}%
\bluehyperlink{rec}{Damn \verb+$%^!+}
\end{document}

Results

3
  • I just want to rotate and link that node in the environment. I have other nodes.
    – jejuba
    Oct 3, 2011 at 0:21
  • I wasn't sure about that. Anyway, other people might find is useful for their documents. Oct 3, 2011 at 7:27
  • Ok, thanks. You comment was useful for sure. If you find a way to rotate my node without changing it's shape, I'm all ears so to speak. Tx,
    – jejuba
    Oct 3, 2011 at 17:19
6

You can use \rotatebox{90}{...} (provided by graphicx) instead of the rotate=90 option:

\documentclass{article}
\usepackage{tikz}% http://ctan.org/pkg/pgf
\usepackage{hyperref}% http://ctan.org/pkg/hyperref

\begin{document}
\begin{tikzpicture}
\node (rect) [rectangle, fill=blue] {\rotatebox{90}{\hyperlink{rec}{Hello!}}};
\end{tikzpicture}

\end{document}

Rotated node and hyperlink

2
  • Does the rotation happen around the same point in both cases? Oct 2, 2011 at 17:51
  • You can modify the rotation origin by using \rotatebox[origin=?]{90}{...} where ? is could be combinations of top t, bottom b, baseline B, left l, center c or right (similar to pstricks reference point notation). See the graphicx package documentation.
    – Werner
    Oct 2, 2011 at 17:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .