超链接旋转的节点部分

超链接旋转的节点部分

我想让整个节点部分成为链接。但是,一旦旋转,似乎hyperref就会出现问题。下面的参考资料说将旋转的内容放置在超链接中,但不确定在使用时如何做到这Tikz一点nodepart

enter image description here

笔记:

  • \def\VerticalText{}如果有评论,链接就可以正常工作。
  • 理想情况下,我希望整个矩形区域作为链接,但只有文本也是可以接受的。

参考

代码:

\def\VerticalText{}% <--- All links work if comment this out.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes}

\usepackage[colorlinks=true]{hyperref}

\ifdefined\VerticalText
    \tikzset{My Rotate/.style={rotate=90}}%
\else
    \tikzset{My Rotate/.style={}}%
\fi

\tikzset{Node Label Style/.style={
    anchor=south, 
    above, 
    align=center,
    }
}

\tikzset{Rectangle Split Style/.style={
        rectangle split, rectangle split parts=3, 
        My Rotate,
        anchor=south,
        thick, fill=gray!10,
    }
}
\tikzset{Node Part Style/.style={draw, minimum width=2.1cm, align=center}}


\newcommand*{\GoogleLink}{\href{http://www.google.com}{\shortstack{Google \\ Web Site}}}%


\begin{document}

This multi-line link works: \GoogleLink

The link in the title also work:

\bigskip
\begin{tikzpicture}

\node[Rectangle Split Style] (MyNode) at (0,0) [Node Part Style]  
        {\nodepart{one}   \GoogleLink %% <-- This link does NOT work if \VerticalText is defined
         \nodepart{two}   \shortstack{Yahoo \\ Web Site} 
         \nodepart{three} \shortstack{TeX.SE \\ Web Site}
        };
        
\ifdefined\VerticalText
    \coordinate (Title Location) at (MyNode.east);
\else
    \coordinate (Title Location) at (MyNode.north);
\fi

%% This link works fine:
\node [Node Label Style] at (Title Location)  {\GoogleLink};

\end{tikzpicture}
\end{document}

答案1

类似这样的事?

\href{<www-Link>}{\tikz{<....>}}

或者

\node [<styles>] 
{\rotatebox{90}{<...>}
\nodepart{two}  \rotatebox{90}{<...>}
\nodepart{three} \rotatebox{90}{<...>}
};

enter image description here

\documentclass[10pt]{article}
\usepackage{tikz}
\usetikzlibrary{shapes}

\usepackage[colorlinks=true]{hyperref}

\newcommand*{\GoogleLink}{\href{http://www.google.com}{\shortstack{Google \\ Web Site}}}%
\newcommand*{\YahooLink}{\href{http://www.google.com}{\shortstack{Yahoo \\ Web Site}}}%
\newcommand*{\TeXLink}{\href{http://www.google.com}{\shortstack{TeX.SE \\ Web Site}}}%
\begin{document}
\tikzset{Rectangle Split Style/.style={
rectangle split, 
rectangle split horizontal, 
rectangle split parts=3, 
anchor=south, align=left, 
draw=black, thick, fill=gray!10,
text width=2em, minimum size=2cm,
},
}

\newcommand\AllOneLink{%
\tikz{\node [Rectangle Split Style] 
{\rotatebox{90}{All}   
\nodepart{two}  \rotatebox{90}{one}
\nodepart{three} \rotatebox{90}{Link}
};
}}

\href{http://www.google.com}{\AllOneLink}

\begin{tikzpicture}[]
\node [Rectangle Split Style] 
{\rotatebox{90}{\GoogleLink}   
\nodepart{two}  \rotatebox{90}{\YahooLink}
\nodepart{three} \rotatebox{90}{\TeXLink}
};
\end{tikzpicture}
\end{document}

相关内容