1

Could somebody tell me why with that code

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}

\usetikzlibrary{positioning}
\usetikzlibrary{calc}


\newcommand{\loga}[1]{{log10(#1)}}

%definition longueurs------
\def\lMarqueStd{0.4}
\def\vMin{1}
\def\homothRap{1}
%--------------------------


\begin{document}
\begin{tikzpicture}
\def\homothRap{1}
\draw (\lMarqueStd,-\homothRap*\loga\vMin)--++(-\lMarqueStd,0);
\end{tikzpicture}
\end{document}

I get an error? It sure comes frome \homothRap*. I try do fix it with some $ but I failed.

Could somebody help me please?

  • Is there any particular reason to not use directly (\lMarqueStd,{-\homothRap*log10(\vMin)})? – Claudio Fiandrino Aug 20 '14 at 12:48
  • @ClaudioFiandrino : juste laziness but you're right it works in that case – Frednight Aug 20 '14 at 13:20
  • Put math operations in a brace pairwhen used as coordinate expression – percusse Aug 20 '14 at 13:21
2

Remove the extra pair of braces from the \newcommand definition and add them back in around the entire calculation in the coordinate expression:

\documentclass{standalone}
\usepackage{tikz}

\usetikzlibrary{positioning}
\usetikzlibrary{calc}


\newcommand{\loga}[1]{log10(#1)} % removed brace pair here

%definition longueurs------
\def\lMarqueStd{0.4}
\def\vMin{1}
\def\homothRap{1}
%--------------------------


\begin{document}
\begin{tikzpicture}
\def\homothRap{1}
\draw (\lMarqueStd,{-\homothRap*\loga\vMin})--++(-\lMarqueStd,0); % added brace pair here
\end{tikzpicture}
\end{document}

The braces must encapsulate the entire calculation inside a coordinate expression, not just part of it.

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.