0

I found this nice answer on reversing tikz coordinates

Reverse coordinate system/axis in TikZ

However, it fails one you use \newlength as shown in this example:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\newlength{\lspan}
\setlength{\lspan}{0.5cm}
\begin{document}
\begin{tikzpicture}[y=-1cm]
  \draw[green] (0, 0) -- ($(0, 0) + (\lspan, \lspan)$);
  \draw[red] (0, 0) -- ($(0, 0) + (0.5, 0.5)$);

  \draw (0, 0) -- (1, 0) node[below] {$x$};
  \draw (0, 0) -- (0, 1) node[left] {$y$};
\end{tikzpicture}
\end{document}

enter image description here

Following the logic the red and green lines should coincide.

What is wrong?

  • 2
    Possibly a bug, but if you do \def\lspan{0.5} the result is as expected. Anyway, if you use an explicit unit of measure, it is not multiplied by the scaling factor, I guess by general rule. And you should not mix absolute lengths with relative ones. – egreg Oct 23 at 17:02
  • This works as expected. Only when the y-coordinate is unit-less, y-vector (set by y=-1cm) is multiplied. – muzimuzhi Z Oct 23 at 19:50

Your Answer

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

Browse other questions tagged or ask your own question.