`abs` 内部坐标计算

`abs` 内部坐标计算

如何abs在 TikZ 中放入坐标计算?我尝试了以下方法,但不起作用(参见 MWE 中的第 4 行和第 5 行)。

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\newcommand{\asd}[1]{\node[circle,draw] at ($(1+#1,0)$) {B};} %this works
\newcommand{\zxc}[1]{\node[circle,draw] at ($abs(#1),0$) {B};} %this doesn't
\begin{document}
\begin{tikzpicture}
\node[circle,draw] at (1,0) {A};
\zxc{-2}
\end{tikzpicture}
\end{document}

答案1

您将需要使用($({abs(#1)},0)$),首先我们当然需要()在坐标计算中。其次在中{abs(#1)}{}需要确保表达式被传递到求值,从而不会破坏可能正在寻找的解析器()|-

相关内容