3

I wish to reproduce an object by drawing with tikz. My concept is measuring the coordinates of a raster image then reproduce the image with tikz \draw. Finally I wish replace absolute unit (cm or pt or etc) with a scale factor and integrate the object into a macro.

My MWE:

\documentclass{memoir}

\usepackage{xcolor}
\usepackage{tikz}
  \usetikzlibrary{shapes.geometric,positioning,calc,patterns}

\usepackage{tikzpagenodes}
\usepackage{calc}

\newcommand{\fsymbolI}[5]{%
\def\aII{0.013797449*#1 }
 \begin{tikzpicture}[rotate=#4,overlay, remember picture, -latex]%
  \node[shift={(#2,#3)}] at (current page.north west){%
   \begin{tikzpicture}[rotate=180,overlay, remember picture]%
    \begin{scope}[xshift=-11.7cm,yshift=1.1cm]%
    \draw[#5,-] (6.4cm,15cm) -- (6.4cm,15.6cm) -- (11.6cm,11.8cm) -- (11.6cm,4.1cm) arc (0:-90:5.1cm)  -- (6.4cm,4.1cm) -- (6.4*\aII,8.6*\aII) arc (270:360: 3.6cm and 2.1cm) -- cycle ;%
     \draw[#5,-] (5.8cm,10.7cm) ellipse (1.05cm  and 0.85cm);
    \end{scope}%
   \end{tikzpicture}%
  };%
 \end{tikzpicture}%
}

\begin{document}
 \fsymbolI{1cm}{0mm}{0mm}{0}{green}
\end{document}

works fine. But:

My idea is replace all the 'cm' with '*\aII' (defined in the macro fsymbolI by \def\aII{0.013797449*#1 }). Working fine except when I wish to change the 3rd param. of ellipse. So

\draw[#5,-] (5.8*\aII,10.7*\aII) ellipse (1.05cm  and 0.85*\aII);

works fine but

\draw[#5,-] (5.8*\aII,10.7*\aII) ellipse (1.05*\aII  and 0.85*\aII);

causes an error:

! Package PGF Math Error: Unknown operator a' oran' (in '1.05*0.013797449*1cm and 0.85*0.013797449*1cm ').

I've added a white space in definition '\aII' but it didn't sole the problem.

Any help will be welcomed.

1 Answer 1

4

Put the length expression into braces.

\draw[#5,-] (5.8*\aII,10.7*\aII) ellipse ({1.05*\aII} and 0.85*\aII);
2
  • Thanks! I am not really understand why does the 3rd and the 4th argument behave different, but the solution works fine. Thanks again!
    – Tom Solid
    Commented Dec 27, 2016 at 14:06
  • @TomSolid When the \aII macro is parsed, the space following it is also eaten (even if you have several spaces, it counts just as one). Apparently the tikz parser expects and to be preceded by a space. If you remove the space in front of and in the working solution above, you will get again the same error as before.
    – gernot
    Commented Dec 27, 2016 at 14:13

You must log in to answer this question.

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