0

I have a macro that draw some objects, which takes as argument an optional parameter (left or right). To avoid repetitive code, I check for the input argument and condition TikZ parameter on that (left=of or right=of):

\newcommand{\mycommand}[1]{
    \ifthenelse{\equal{#1}{left}}{
        \def\side left
    }{
        \def\side right
    }
    \node (A) {$A$}
    \node (B) [\side=of A] {$B$};

I obtained the following error:

Use of \side doesn't match its definition.

Could you please help me to resolve this issue? Thank you very much in advance!

2
  • Do you want \def\side{left}?
    – Symbol 1
    Commented Jun 21, 2020 at 0:13
  • @Symbol1 Oh!! My bad! It works, indeed! Please post an answer. Thanks a lot!
    – f10w
    Commented Jun 21, 2020 at 0:21

1 Answer 1

3

The (simplified) syntax of \def is \def\tokenname#1...{...}

\newcommand{\mycommand}[1]{
    \ifthenelse{\equal{#1}{left}}{
        \def\side{left}
    }{
        \def\side{right}
    }
    \node (A) {$A$}
    \node (B) [\side=of A] {$B$};
1
  • Thanks for the answer!
    – f10w
    Commented Jun 21, 2020 at 0:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .