[Tex/LaTex] `abs` inside coordinate calculation

calculationstikz-pgf

How can I put abs inside a coordinate calculation in TikZ? I have tried the following but it doesn't work (see lines 4 and 5 inside the MWE).

\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}

Best Answer

You will need to use ($({abs(#1)},0)$), firstly we of course need () inside the coordinate calculation. Secondly in {abs(#1)}, the {}'s are needed to ensure that the expression is passed on to evaluation and thus does not croak the parser that might be looking for ()'s and |- etc