编辑 2(2 月 20 日):新问题(希望更清楚)
可以获得pgfplots
“内部”和“外部”图例(参见Paul Gessler 的回答) 作为:
我想用“简单”的 Tikz 图片实现相同的效果(IE不是一个情节。
目前,得益于这个答案或 John Kormylo 的回答以下,我能够创建一个带有 Tikzpicture 定位的图例current bounding box.south east
(参见末尾的 MWE):
因此,用 定位current bounding box.south east
相当于用 进行“外部”定位pgfplots
。
如何才能达到与上图中图例相同的“内部”定位效果并且不使用绝对移位(IE [yshift=.., xshift=..]
)但使用类似pos=
inner
current bounding box.south east
反而?
我指定在我的 MWE 中构建图例的方式没有限制,也就是说,如果这可以实现“内部”定位,我愿意接受使用其他方式创建图例(使用scope
,, ...) 。path
编辑 3(2 月 24 日):第一次尝试
感谢下面的 Ulrike Fischer 评论,我得到了这个(这非常符合我的需要):
最后一个问题是图例与节点重叠。我想知道我是否可以检测或访问legend
节点高度,以便绘制legend
与节点高度相等的节点yshift
(因为图例可能是多行矩阵)。
谢谢在这里敲击答案我能够获得这个:
其中,“蓝色图例”是我想要获得的最终结果。“黑色图例”仅用于确定legend
节点高度,我想删除它...红色文本和线条显示yshit
存储在节点高度\mytemp
中的长度legend
。
确定黑色图例的高度后,如何删除它?
或者还有其他想法可以自动设置yshift
以避免重叠?
MWE 表示:
\documentclass[tikz=true,crop=true,class=minimal,border=1pt,10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\begin{scope}[local bounding box=localbox]
% NODES
\node (n1) [draw, text width=5em, minimum height=8em] {node 1};%
% ARROWS
\coordinate[above right=of n1.east] (aux2a);
\coordinate[below right=of n1.east] (aux2b);
%
\draw[-latex] (aux2a -| n1.east)
to (aux2a) node[right] {short label};
\draw[-latex] (aux2b -| n1.east)
to (aux2b) node[right] {a bit longer label};
\end{scope}
% LEGEND
% First black Legend
\path (localbox.north west)%
node[name=legend,matrix,anchor=west,cells={nodes={font=\sffamily,anchor=west}},
draw,thick,inner sep=0.3ex]{%
\draw[-latex](0,0) -- ++ (0.6,0); & \node{arrow};\\
};%
% Access to black legend node height
\pgfpointdiff{\pgfpointanchor{legend}{south west}}{\pgfpointanchor{legend}{north west}}
\pgfmathsetmacro\mytemp{\csname pgf@y\endcsname}
\draw[red] ([xshift=1mm]legend.north east) -- ++(0pt,\mytemp pt)
node[midway,right] {\mytemp pt};
% Final blue legend
\path ([yshift=\mytemp pt]localbox.north west)%
node[name=legend,matrix,anchor=west,cells={nodes={font=\sffamily,anchor=west}},
draw,thick,inner sep=0.3ex,draw=blue!80]{%
\draw[-latex](0,0) -- ++ (0.6,0); & \node{arrow};\\
};%
\end{tikzpicture}
\end{document}
老问题(不清楚)
谢谢这个答案我能够用 Tikzpicture 绘制这样的图例(图例位于下图的右下角,用 放置\path(current bounding box.south east)
,请参阅末尾的 MWE):
但我更喜欢这个结果(警告:最终结果中不需要红色的东西,这只是为了解释目的):
开始编辑 1.1换句话说,我想将图例放置在与 等同的位置,(current bounding box.south east)
但不是从 开始,而是从“图片边框内部”开始south east
(bounding box
下south east
图中的绿色坐标)。(顺便说一句,我不确定红线是否反映了取消标记时的真实行为和坐标(current bounding box.south east)
)
结束编辑1.1
另一个预期结果的示例是,具有更大的节点:
或者这样(类似north east
):
- 有没有办法通过使用类似
(current
“limits
”之类的东西来自动获得这种行为box.south east)
? - 如果是,那么也可以选择
ymin
上图所表示的最小垂直距离(可以取负值)\path([ymin=-5mm]current limits box.south east)
:? - 如果是,那么也可以选择
xmin
这样的最小水平距离:
妇女权利委员会:
\documentclass[tikz=true,crop=true,class=minimal,border=1pt,10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
% NODES
\node (n1) [draw, text width=5em, minimum height=8em] {node 1};%
% ARROWS
\coordinate[above right=of n1.east] (aux2a);
\coordinate[below right=of n1.east] (aux2b);
%
\draw[-latex] (aux2a -| n1.east)
to (aux2a) node[right] {short label};
\draw[-latex] (aux2b -| n1.east)
to (aux2b) node[right] {a bit longer label};
% LEGEND
\path (current bounding box.south east)%
node[matrix,anchor=north west,cells={nodes={font=\sffamily,anchor=west}},
draw,thick,inner sep=0.3ex]{%
\draw[-latex](0,0) -- ++ (0.6,0); & \node{arrow};\\
};%
\end{tikzpicture}
\end{document}
开始编辑 1.2 我为什么想要这个?
自动定位图例“在图像限制内”将允许使用紧凑的图片进行非常快速的定位,只需给出ymin
以确保不与图例重叠任何内容即可。
这种“聪明”的行为可以通过自动添加图例和设置来更好地自动化图片生成,例如ymin=1mm
防止xmin=1mm
任何重叠问题。
结束编辑1.2
答案1
你把我弄糊涂了,因为我看不懂“传奇”的构造。在普通的 tikzpicture 中使用 pgfplots 样式的图例寻找替代方案。
您还可以使用它\begin{scope}[shift=(fred.south east)] ...\end{scope}
来定位相对于本地边界框(fred)的另一个范围。
\documentclass[tikz=true,crop=true,class=minimal,border=1pt,10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\begin{scope}[local bounding box=fred]
% NODES
\node (n1) [draw, text width=5em, minimum height=8em] {node 1};%
% ARROWS
\coordinate[above right=of n1.east] (aux2a);
\coordinate[below right=of n1.east] (aux2b);
%
\draw[-latex] (aux2a -| n1.east)
to (aux2a) node[right] {short label};
\draw[-latex] (aux2b -| n1.east)
to (aux2b) node[right] {a bit longer label};
\end{scope}
% LEGEND
\path (fred.south east)%
node[matrix,anchor=north west,cells={nodes={font=\sffamily,anchor=west}},
draw,thick,inner sep=0.3ex]{%
\draw[-latex](0,0) -- ++ (0.6,0); & \node{arrow};\\
};%
\end{tikzpicture}
\end{document}
答案2
我不太清楚你想做什么。也许下面的方法有用!?
\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\newcommand{\ymin}{-5mm}
\newcommand{\xmin}{0mm}
% NODES
\node (n1) [draw, text width=5em, minimum height=8em] {node 1};%
% ARROWS
\coordinate[above right=of n1.east] (aux2a);
\coordinate[below right=of n1.east] (aux2b);
%
\draw[-latex] (aux2a -| n1.east)
to (aux2a) node[right] {short label};
\draw[-latex] (aux2b -| n1.east)
to (aux2b) node[right, inner sep=0] (n) {a bit longer label};
% LEGEND
\path ([yshift=\ymin, xshift=\xmin]current bounding box.south east)%
node[matrix,anchor=north west,cells={nodes={font=\sffamily,anchor=west}},
draw,thick,inner sep=0.3ex]{%
\draw[-latex](0,0) -- ++ (0.6,0); & \node{arrow};\\
};%
\draw[red, dashed] (n.south east) -- +(0,3) -- +(0,-2);
\draw[red, dashed] (n1.south west) -| (n.south east);
\end{tikzpicture}
\end{document}
答案3
这里给出这个答案是为了不让这个问题没有几乎“有效”的答案,如果有人(很有可能)碰到这个解决方案并希望(奇怪的是)使用它。
这是我最终使用的丑陋的解决方案,以两种方式呈现:手动方法和使用新环境的方法。
两种方法都使用图例锚点来实现正确的“内部”定位(感谢 Ulrike Fischer 的评论)。
手动解决方案
如果有不重叠,图例只是用(使用范围
local bounding box=localbox
:)\path (localbox.south east) node[name=legend,anchor=
west
...
如果有重叠(图例根据其自身大小移动):
其次,提取该图例的尺寸(宽度和高度)(感谢percusse 的回答在这里)。
第三,临时图例完全被白色矩形隐藏:
\node (whiterec) [rectangle,fill=white,draw=white,minimum height=
\legendheight
pt,minimum width=
\legendwidth
pt] at (legend){};
第四,绘制Tikzpicture的内容。
妇女权利委员会:
\documentclass[tikz=true,crop=true,class=minimal,border=1pt,10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,calc}
\begin{document}
\begin{tikzpicture}
\begin{scope}[local bounding box=localbox]
% First temporary black Legend
\path (0,0)%
node[name=legend,matrix,anchor=west,cells={nodes={font=\sffamily,anchor=west}},
draw,thick,inner sep=0.3ex]{%
\draw[-latex](0,0) -- ++ (0.6,0); & \node{arrow};\\
};%
% Access to black legend node height and width
\pgfpointdiff{\pgfpointanchor{legend}{south west}}{\pgfpointanchor{legend}{north west}}%
\pgfmathsetmacro\legendheight{\csname pgf@y\endcsname}
\pgfpointdiff{\pgfpointanchor{legend}{west}}{\pgfpointanchor{legend}{east}}%
\pgfmathsetmacro\legendwidth{\csname pgf@x\endcsname}%
% NODES
\node (whiterec) [rectangle,fill=white,draw=white,minimum height=\legendheight pt,minimum width=\legendwidth pt] at (legend){};
\node (n1) [draw, text width=5em, minimum height=8em] {node 1};%
% ARROWS
\coordinate[above right=of n1.east] (aux2a);
\coordinate[below right=of n1.east] (aux2b);
%
\draw[-latex] (aux2a -| n1.east)
to (aux2a) node[right] {short label};
\draw[-latex] (aux2b -| n1.east)
to (aux2b) node[right] {a bit longer label};:
% LEGEND
% Final blue legend
\path ([yshift=\legendheight/2 pt+1pt]localbox.north west)%
node[name=legend,matrix,anchor=west,cells={nodes={font=\sffamily,anchor=west}},
draw,thick,inner sep=0.3ex,draw=blue!80]{%
\draw[-latex](0,0) -- ++ (0.6,0); & \node{arrow};\\
};%
\end{scope}%
\end{tikzpicture}
\end{document}
使用新环境的方法
此方法使用一个新的tikzpictureWithInnerLegend
环境,它充当tikzpicture
环境,但自动绘制临时图例,获取其大小并绘制最终图例(与上面的手动方法相同)。
- 首先定义最终临时图例的样式,例如:
\tikzstyle{legend}=[name=legend,matrix,cells={nodes={font=\sffamily,anchor=west}},
draw,thick,inner sep=0.3ex,draw=blue!80]%
\tikzstyle{templegend}=[name=templegend,matrix,cells={nodes={font=\sffamily,anchor=west}},
draw,thick,inner sep=0.3ex,draw=white,fill=white]%
- 图例内容存储到宏中,例如:
\newcommand{\legendcontent}{%
\draw[-latex](0,0) -- ++ (0.6,0); \& \node{arrow};\\% Be carefful to put \& instead of &
\draw[-stealth](0,0) -- ++ (0.6,0); \& \node{arrow2};\\% Be carefful to put \& instead of &
}%
- 该环境被调用,例如带有图例
current bounding box.south east
:
\begin{tikzpictureWithInnerLegend}{\legendcontent}{current bounding box.south east}[xshift=\xmin, yshift=\ymin, autoshiftsign=true]
% NODES
\node (n1) [draw, text width=5em, minimum height=8em] {node};%
% ARROWS
\coordinate[above right=of n1.east] (aux2a);
\coordinate[below right=of n1.east] (aux2b);
%
\draw[-latex] (aux2a -| n1.east)
to (aux2a) node[right] {short label};
\draw[-stealth] (aux2b -| n1.east)
to (aux2b) node[right] {a bit longer label};:
\end{tikzpictureWithInnerLegend}
- 环境选项如下:
[xshift=\xmin, yshift=\ymin]
:分别应用axshift
和ayshift
进行最终的图例定位。[autoshiftsign=true]
xshift
:自动更改和的符号yshift
以避免图例重叠。false
即使您只写[autoshiftsign]
(即符号直接用xshift
和yshift
选项给出,例如xshift=-3pt
:),默认值也是。
局限性和可能的改进
- 代码可以得到很大的改进,以便更具可读性和效率,例如,许多东西在几个地方写得相同(例如,在带有或不带有可选参数的启动环境代码中),宏就是这种情况
\pgfkeys
。 - 包的使用
listofitems
可能可以避免。此包仅用于分割用户给出的图例位置,例如,提取current bounding box.south east
键east
以设置图例锚点。此外,它还允许区分current bounding box.south east
和current bounding box.south
。
完整(丑陋的)代码:
\documentclass[tikz=true,crop=true,class=minimal,border=1pt,10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,calc,matrix}
\usepackage{listofitems}
\usepackage{xparse}
\NewDocumentEnvironment{tikzpictureWithInnerLegend}{m m o}%
{\IfNoValueTF{#3}{%
% # Start code if no opt arg
%-----------------------------------------------------------
% ## Initialization
\pgfkeys{
/tikzpictureWithInnerLegend/.is family, /tikzpictureWithInnerLegend/.cd, %<-added /.cd
autoshiftsign/.is choice,
autoshiftsign/.default=false,
autoshiftsign/true/.code={\renewcommand{\autoShiftSignBool}{1}},
autoshiftsign/false/.code={\renewcommand{\autoShiftSignBool}{0}},
xshift/.estore in ={\xShift},
yshift/.estore in ={\yShift},
}
\newcommand*{\pathLocation}{}
\newcommand*{\lgdAnchor}{}
\newcommand{\xshiftSign}{0}
\newcommand{\yshiftSign}{0}
\newcommand{\xShift}{0}
\newcommand{\yShift}{0}
\newcommand{\xAutoShiftBool}{0}
\newcommand{\yAutoShiftBool}{0}
\newcommand{\autoShiftSignBool}{0}
\def\zero{0}%
\def\plus{+}%
\def\minus{-}%
\def\north{north}%
\def\south{south}%
\def\east{east}%
\def\west{west}%
% ## Main Start Code
\ignoreemptyitems% Ingnore empty items from the list
\setsepchar{.}%
\readlist\mylist{#2}%
\setsepchar{ }%
\itemtomacro\mylist[2]\mylistmacro
\readlist\mysublist{\mylistmacro}%
\itemtomacro\mysublist[1]\cardinal
\if\mysublistlen2
\renewcommand*{\pathLocation}{\mylist[1].\mysublist[1] \mysublist[2]}%
\renewcommand*{\lgdAnchor}{\mysublist[2]}%
\ifx\north\cardinal
\renewcommand{\yshiftSign}{+}%
\renewcommand{\yAutoShiftBool}{1}%
\else
\ifx\south\cardinal
\renewcommand{\yshiftSign}{-}%
\renewcommand{\yAutoShiftBool}{1}%
\else
\renewcommand{\yshiftSign}{+}%
\renewcommand{\yAutoShiftBool}{0}%
\ifx\east\cardinal
\renewcommand{\xshiftSign}{+}%
\renewcommand{\xAutoShiftBool}{1}%
\else
\renewcommand{\xshiftSign}{-}%
\renewcommand{\xAutoShiftBool}{1}%
\fi
\fi
\fi
\else
\renewcommand*{\pathLocation}{\mylist[1].\mysublist[1]}%
\renewcommand*{\lgdAnchor}{\mysublist[1]}%
\ifx\north\cardinal
\renewcommand{\yshiftSign}{+}%
\renewcommand{\yAutoShiftBool}{1}%
\renewcommand*{\lgdAnchor}{center}%
\else
\ifx\south\cardinal
\renewcommand{\yshiftSign}{-}%
\renewcommand{\yAutoShiftBool}{1}%
\renewcommand*{\lgdAnchor}{center}%
\else
\renewcommand{\yshiftSign}{+}%
\renewcommand{\yAutoShiftBool}{0}%
\ifx\east\cardinal
\renewcommand{\xshiftSign}{+}%
\renewcommand{\xAutoShiftBool}{1}%
\else
\renewcommand{\xshiftSign}{-}%
\renewcommand{\xAutoShiftBool}{1}%
\fi
\fi
\fi
\fi
\begin{tikzpicture} [ampersand replacement=\&]
% ### Print temporary legend node
\path (0,0)%
node[templegend]{#1};%
% ### Access to temporary legend node height and width
\pgfpointdiff{\pgfpointanchor{templegend}{south west}}{\pgfpointanchor{templegend}{north west}}%
\pgfmathsetmacro\legendheight{\csname pgf@y\endcsname}
\pgfpointdiff{\pgfpointanchor{templegend}{west}}{\pgfpointanchor{templegend}{east}}%
\pgfmathsetmacro\legendwidth{\csname pgf@x\endcsname}%
\node (whiterec) [rectangle,fill=white,draw=white,minimum height=\legendheight pt,minimum width=\legendwidth pt] at (templegend){};
}%
{%
% # Start code if opt arg
%-----------------------------------------------------------
% ## Initialization
\pgfkeys{
/tikzpictureWithInnerLegend/.is family, /tikzpictureWithInnerLegend/.cd, %<-added /.cd
autoshiftsign/.is choice,
autoshiftsign/.default=false,
autoshiftsign/true/.code={\renewcommand{\autoShiftSignBool}{1}},
autoshiftsign/false/.code={\renewcommand{\autoShiftSignBool}{0}},
xshift/.estore in ={\xShift},
yshift/.estore in ={\yShift},
}
\newcommand*{\pathLocation}{}
\newcommand*{\lgdAnchor}{}
\newcommand{\xshiftSign}{0}
\newcommand{\yshiftSign}{0}
\newcommand{\xShift}{0}
\newcommand{\yShift}{0}
\newcommand{\xAutoShiftBool}{0}
\newcommand{\yAutoShiftBool}{0}
\newcommand{\autoShiftSignBool}{0}
\def\zero{0}%
\def\plus{+}%
\def\minus{-}%
\def\north{north}%
\def\south{south}%
\def\east{east}%
\def\west{west}%
% ## Main Start Code
\pgfkeys{/tikzpictureWithInnerLegend,#3}%
\ifx\minus\xshiftSign
\renewcommand{\xAutoShiftBool}{1}%
\else
\ifx\plus\xshiftSign
\renewcommand{\xAutoShiftBool}{1}%
\else
\renewcommand{\xAutoShiftBool}{0}%
\fi
\fi
\ifx\minus\yshiftSign
\renewcommand{\yAutoShiftBool}{1}%
\else
\ifx\plus\yshiftSign
\renewcommand{\yAutoShiftBool}{1}%
\else
\renewcommand{\yAutoShiftBool}{0}%
\fi
\fi
\ignoreemptyitems% Ingnore empty items from the list
\setsepchar{.}%
\readlist\mylist{#2}%
\setsepchar{ }%
\itemtomacro\mylist[2]\mylistmacro
\readlist\mysublist{\mylistmacro}%
\itemtomacro\mysublist[1]\cardinal
\if\mysublistlen2
\renewcommand*{\pathLocation}{\mylist[1].\mysublist[1] \mysublist[2]}%
\renewcommand*{\lgdAnchor}{\mysublist[2]}%
\ifx\north\cardinal
\renewcommand{\yshiftSign}{+}%
\renewcommand{\yAutoShiftBool}{1}%
\else
\ifx\south\cardinal
\renewcommand{\yshiftSign}{-}%
\renewcommand{\yAutoShiftBool}{1}%
\else
\renewcommand{\yshiftSign}{+}%
\renewcommand{\yAutoShiftBool}{0}%
\ifx\east\cardinal
\renewcommand{\xshiftSign}{+}%
\renewcommand{\xAutoShiftBool}{1}%
\else
\renewcommand{\xshiftSign}{-}%
\renewcommand{\xAutoShiftBool}{1}%
\fi
\fi
\fi
\else
\renewcommand*{\pathLocation}{\mylist[1].\mysublist[1]}%
\renewcommand*{\lgdAnchor}{\mysublist[1]}%
\ifx\north\cardinal
\renewcommand{\yshiftSign}{+}%
\renewcommand{\yAutoShiftBool}{1}%
\renewcommand*{\lgdAnchor}{center}%
\else
\ifx\south\cardinal
\renewcommand{\yshiftSign}{-}%
\renewcommand{\yAutoShiftBool}{1}%
\renewcommand*{\lgdAnchor}{center}%
\else
\renewcommand{\yshiftSign}{+}%
\renewcommand{\yAutoShiftBool}{0}%
\ifx\east\cardinal
\renewcommand{\xshiftSign}{+}%
\renewcommand{\xAutoShiftBool}{1}%
\else
\ifx\west\cardinal
\renewcommand{\xshiftSign}{-}%
\renewcommand{\xAutoShiftBool}{1}%
\else% Center
\renewcommand{\xshiftSign}{+}%
\renewcommand{\yshiftSign}{+}%
\renewcommand{\xAutoShiftBool}{0}%
\renewcommand{\yAutoShiftBool}{0}%
\renewcommand*{\lgdAnchor}{center}%
\fi
\fi
\fi
\fi
\fi
\begin{tikzpicture} [ampersand replacement=\&]%
% ### Print temporary legend node
\path (0,0)%
node[templegend]{#1};%
% ### Access to temporary legend node height and width
\pgfpointdiff{\pgfpointanchor{templegend}{south west}}{\pgfpointanchor{templegend}{north west}}%
\pgfmathsetmacro\legendheight{\csname pgf@y\endcsname}%
\pgfpointdiff{\pgfpointanchor{templegend}{west}}{\pgfpointanchor{templegend}{east}}%
\pgfmathsetmacro\legendwidth{\csname pgf@x\endcsname}%
\node (whiterec) [rectangle,fill=white,draw=white,minimum height=\legendheight pt,minimum width=\legendwidth pt] at (templegend){};%
}}%
{\IfNoValueTF{#3}{%
% # End code if no opt arg
%-----------------------------------------------------------
% ## LEGEND
\path ([xshift=\xAutoShiftBool*\legendwidth*\xshiftSign1 pt+\autoShiftSignBool*\xShift*\xshiftSign1+(1-\autoShiftSignBool)*\xShift,yshift=\yAutoShiftBool*\legendheight/2*\yshiftSign1 pt+\autoShiftSignBool*\yShift*\yshiftSign1+(1-\autoShiftSignBool)*\yShift]#2)%
node[legend,anchor=\lgdAnchor]{#1};%
\end{tikzpicture}%
}%
{%
% # End code if opt arg
%-----------------------------------------------------------
% ## LEGEND
\path ([xshift=\xAutoShiftBool*\legendwidth*\xshiftSign1 pt+\autoShiftSignBool*\xShift*\xshiftSign1+(1-\autoShiftSignBool)*\xShift,yshift=\yAutoShiftBool*\legendheight/2*\yshiftSign1 pt+\autoShiftSignBool*\yShift*\yshiftSign1+(1-\autoShiftSignBool)*\yShift]#2)%
node[legend,anchor=\lgdAnchor]{#1};%
\end{tikzpicture}%
}}%
\begin{document}
% Legend Formating
\tikzstyle{legend}=[name=legend,matrix,cells={nodes={font=\sffamily,anchor=west}},
draw,thick,inner sep=0.3ex,draw=blue!80]%
\tikzstyle{templegend}=[name=templegend,matrix,cells={nodes={font=\sffamily,anchor=west}},
draw,thick,inner sep=0.3ex,draw=white,fill=white]%
% Legend Content
\newcommand{\legendcontent}{%
\draw[-latex](0,0) -- ++ (0.6,0); \& \node{arrow};\\% Be carefful to put \& instead of &
\draw[-stealth](0,0) -- ++ (0.6,0); \& \node{arrow2};\\% Be carefful to put \& instead of &
}%
% Legend manual shift
\newcommand{\xmin}{0pt}% Minimal xshift to avoid ovelapping
\newcommand{\ymin}{1pt}% Minimal yshift to avoid ovelapping
\begin{tikzpictureWithInnerLegend}{\legendcontent}{current bounding box.south east}[xshift=\xmin, yshift=\ymin, autoshiftsign=true]
% NODES
\node (n1) [draw, text width=5em, minimum height=8em] {node};%
% ARROWS
\coordinate[above right=of n1.east] (aux2a);
\coordinate[below right=of n1.east] (aux2b);
%
\draw[-latex] (aux2a -| n1.east)
to (aux2a) node[right] {short label};
\draw[-stealth] (aux2b -| n1.east)
to (aux2b) node[right] {a bit longer label};:
\end{tikzpictureWithInnerLegend}
\end{document}