I would like to compute coords X and Y to build a figure :


\usepackage{tikz} % pour dessins
\usetikzlibrary{shapes, calc, arrows} % pour complement tikz



\coordinate (P1) at (\tan(\angleg)*\focale,1.5cm);
\end{tikzpicture}%<<<== must use well balanced curly-braces


but i have got an error :

Missing \endcsname inserted \coordinate (P1) at (\tan(32)

I tried to include the compute within $ but :

Paragraph ended before \tikz@cc@parse@factor was complete
  • 3
    You just need braces, otherwise Tikz cannot recognize a calculation from a point ({tan(\angleg)*\focale},1.5cm). – zeroth Jul 11 '13 at 13:32
  • many thanks and sorry...i have scanned some introductions notes to tikz, but i should have read in details... – Patrick Dezecache Jul 11 '13 at 13:41
  • Many thanks for all participations ! I think i will use answers linked to tikz, but pstricks seems to be quite interessant too. great tools ! and a great teams to support it ! - patrick – Patrick Dezecache Jul 11 '13 at 17:27

Short answer is: Yes, you can.

Your error is that you're typing the function with a backslash \ which is the way to indicate to LaTeX that it's a command in the compilation. When calculating a number, functions shouldn't have a backslash, just tan(angleg) and so on.

For more complicated functions, use the curly bracket to indicate they are supposed to be together (as stated by @zeroth )({tan(\angleg)*\focale},1.5cm).


I disagree with the one statement of the reply about the \ (backslash) :

  • the \tan must be replaced by 'tan' because you want the mathematical function to be aplied to the \angleg and not to write 'tan(58)'
  • you must keep the '\angleg' because TeX has no idea about 'angleg ' (it's pure text)

I agree with the reply about the {} (curly brackets), which are mandatory each time you have some () in the point definition.

But the full answer would be to use the $ syntax to compute the point coordinates :

\coordinate (P1) at ($({tan(\angleg)*\focale},1.5cm)$);

Futhermore, it could be better practice to replace

\def\gnat{<some math expresion>}


\pfgmathsetmacro{\gnat}{<some math expresion>}

because the calculation is then parsed and performed immediatly when using the latter.

  • 2
    You're right about the backslash in \angleg, but it's not necessary to use the $ syntax from the calc library if you're only evaluating a mathematical expression in a coordinate component. The calc library is only necessary when you're performing calculations that use full coordinates. – Jake Jul 11 '13 at 14:12

With PSTricks. Just for comparison purposes.

PSTricks equivalent for TikZ ({tan(\complement)*\radius},1.5) is

  • (+{Tan(\complement)*\radius},1.5)
  • (**{Tan(\complement)*\radius} 1.5)


%\pnode(**{Tan(\complement)*\radius} 1.5){P1}

enter image description here


In PSTricks, there are some ways to define a coordinate. It can be expressed in terms of existing nodes or mathematics expressions. With mathematics expression, we have 4 methods as follows.

  • RPN for both abscissa and ordinate.

    For example: (!2 3 mul 1 sub 2 0 add) is a point (5,2).

  • RPN for abscissa and algebraic for ordinate. The ordinate can be a function of x.

    For example: (*{2 3 add} {x-3}) is a point (5,2).

  • Algebraic for abscissa and RPN for ordinate. The abscissa can be a function of y.

    For example: (**{y*3-1} {1 1 add}) is a point (5,2).

  • Algebraic for both abscissa and ordinate.

    For example: (+{3+2},1+1) is a point (5,2).

The following example uses \def to express algebraic expression as a function of x, y or a constant.


    \pscircle*[linecolor=red](+{\f[2],\f[1]}){2pt}% its center is (3,1)
    \pscircle*[linecolor=green](*{1 0 add} {\f[x]}){2pt}% its center is (1,1)
    \pscircle*[linecolor=blue](**{\f[y]} {2 0 add}){2pt}% its center is (3,2)
  • What's the difference between the + syntax and the ** syntax (apart from the fact that one needs a comma between the components, and the other doesn't)? – Jake Jul 11 '13 at 14:56
  • @Jake: I will update my answer to accommodate more general cases. – kiss my armpit Jul 11 '13 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.