I want to use the pgfmath engine, but the result is not what I expect. In this example, I want both lines to have the same length.
\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfmath}
\begin{document}
\begin{tikzpicture}
\draw[color=blue, very thick] (0,0) -- (2,0);
\pgfmathparse{ceil(1.7)} % Why is the red line shorter? It should be 2 units in length
\draw[color=red, very thick] (0,0.5) -- (\pgfmathresult,0.5);
\end{tikzpicture}
\end{document}
Sorry if this question seems too stupid, but I don't know what's wrong. Thanks for your help.
{\pgfmathresult}
? – daleif Jun 27 '19 at 10:55\pgfmathresult
was getting overwitten. – frougon Jun 27 '19 at 11:07\pgfmathsetmacro\myceil{ceil(1.7)}
and then\myceil
instead of\pgfmathresult
. – Henri Menke Jun 27 '19 at 11:11\pgfmathresult
contains the most recent result of what the user computed in their code, and not the most recent result of whatever TikZ has been doing in the background. – Marijn Jun 27 '19 at 11:38