当文本超链接时,TikZ 节点中的换行符

当文本超链接时,TikZ 节点中的换行符

hyperref标题是不言自明的。当文本是(在本例中是电子邮件地址)时,我想在 TikZ 节点中引入换行符。

align我知道我可以使用选项和在节点中引入换行符\\,但是当文本时hyperref,这会出现错误。

我尝试过这个text width选项,但是在很多情况下它会产生未满警告,而且我无法解决它......

这是我的 MWE:

\documentclass{article}

\usepackage{tikz}

\usetikzlibrary{calc,positioning}

\usepackage{hyperref}

\hypersetup{pdfborder = {0 0 0}}


\begin{document}

\begin{tikzpicture}[every node/.style={inner sep=0,outer sep=0, fill=yellow}]
\node[anchor=east, align=right] (A) at (0,0) {I can split normal text\\
    into two lines};

\node[below=1cm of A.south east, anchor=north east] (B) {\href{mailto:complete\[email protected]}{complete\[email protected]}};%I WANT TO SPLIT THIS TOO, AFTER THE @

\node[below=1cm of B.south east, anchor=north east] (C) {\href{mailto:[email protected]}{[email protected]}};%AND THIS IN THE SAME WAY

%\node[below=1cm of C.south east, anchor=south east, align=right] (D) {\href{mailto:complete\[email protected]}{complete\_name\\
%@longaddress.com}}; %IF I USE align=right AND \\ AS ABOVE, I GET ERROR

\node[below=1cm of C.south east, anchor=north east, text width=2.8cm, align=right] (D) {\href{mailto:complete\[email protected]}{complete\_name\\
        @longaddress.com}}; %WITH text width WORKS OK FOR THIS CASE, BUT FOR OTHERS I GET UNDERFULL

\node[below=1cm of D.south east, anchor=north east, text width=2.8cm, align=right] (E) {\href{mailto:[email protected]}{name\\
        @longaddress.com}};%UNDERFULL, IS THERE A WAY I CAN SPLIT THIS TEXT WITHOUT WARNINGS?


\end{tikzpicture}


\end{document}

它产生了所需的视觉输出,但在最后一个节点中出现了 UNDERFULL 警告,我想将其删除。有什么建议吗?

图。1

答案1

tabular按照建议的那样在 a 内设置显示的文本TikZ 节点中的手动/自动换行和文本对齐

在此处输入图片描述

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{calc,positioning}

\usepackage{hyperref}
\hypersetup{pdfborder = {0 0 0}}

\begin{document}

\begin{tikzpicture}[every node/.style={inner sep=0,outer sep=0, fill=yellow}]
  \node[anchor=east, align=right] (A) at (0,0) {I can split normal text \\
    into two lines};

  \node[below=1cm of A.south east, anchor=north east] (B) 
    {\href{mailto:complete\[email protected]}{%
      \begin{tabular}{@{}l@{}}
        complete\_name@ \\
        longaddress.com
      \end{tabular}}};

\end{tikzpicture}

\end{document}

您可以修改列规范以获得不同的对齐方式。

相关内容