以下代码:
\documentclass[margin = 10mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\coordinate (a) at (0, 0);
\coordinate (b) at (0, 1);
\draw[->] (a) -- (b);
\node(t) at ($(a)!0.5!(b) + (0.2, 0)$) {l};
\end{tikzpicture}
\end{document}
给出结果:
现在,我想通过在坐标上t
添加位移来调整节点的路径:(0, 0.2)
a
\node(t) at ($((a) + (0, 0.2))!0.5!(b) + (0.2, 0)$) {l};
如何修正这个表达式以符合tikz
calc
规则?
答案1
您可以继续在 TikZ 需要扫描坐标或形状名称的任何地方添加嵌套计算语法。
\documentclass[tikz]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\draw[style=help lines] (-1,-1) grid[step=1)] (2,2);
\coordinate[label={[below left]:A}] (a) at (0, 0);
\coordinate[label={[above right]:B}] (b) at (0, 1);
\draw[->] (a) -- (b);
% put something at (0.5, 0.5) relative to a and b
\node[inner sep=0](t) at ($($(a) + (-1,-1)$)!0.5!($(b) + (2, 1)$)$) {.};
\end{tikzpicture}
\end{document}