尺寸过大,错误数量较少

时间:2017-07-24 09:28:56

标签: tikz

由于\tmp我收到“尺寸太大”错误,但我不明白为什么,因为结果不是很大(大约1)。

\begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-0.10000, xscale=0.10000, inner sep=0pt, outer sep=0pt]

\def\xxpl{834.5599}
\def\yxpl{-46.1934}

\def\xxpr{1567.4944}
\def\yxpr{723.6958}

\def\tmp{(\yxpr-\yxpl)/(\xxpr-\xxpl)}
\draw[black] (0,0) -- ++({10*\tmp},{-1*10});      % Works
\draw[black] (0,0) -- ++({100*\tmp},{-1*100});    % Doesn't work

\end{tikzpicture}

你知道为什么吗?

提前感谢

1 个答案:

答案 0 :(得分:1)

使用\def,定义的表达式只是在后续代码中替换。不幸的是,看起来tikz无法计算复杂的表达式,例如(\yxpr-\yxpl)/(\xxpr-\xxpl)。您可以使用\pgfmathsetmacro代替\def

\begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-0.10000, xscale=0.10000, inner sep=0pt, outer sep=0pt]

\def\xxpl{834.5599}
\def\yxpl{-46.1934}

\def\xxpr{1567.4944}
\def\yxpr{723.6958}

\pgfmathsetmacro\tmp{(\yxpr-\yxpl)/(\xxpr-\xxpl)}

%\draw[black] (0,0) -- ++({10*\tmp},{-1*10});      % Works
\draw[black] (0,0) -- ++({100*\tmp},{-1*100});      % Now work!

\end{tikzpicture}