代码相同,但重新安装 MikTex 后生成不同的 pdf 文件

代码相同,但重新安装 MikTex 后生成不同的 pdf 文件

在我的计算机上重新安装 MiKTeX 之前,我使用了以下代码:

\documentclass[tikz]{standalone}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}

\coordinate (A0) at (4.04,0);
\coordinate (A1) at (2.93,2.79);
\coordinate (B0) at (-2.02,3.5);
\coordinate (B1) at (-3.88,1.14);
\coordinate (C0) at (-2.02,-3.5);
\coordinate (C1) at (0.95,-3.93);
\coordinate (O) at  (0,0);
\coordinate (An-1) at  (-2.64, 3.06);
\coordinate (Bn-1) at  (-1.33,-3.81);
\coordinate (Cn-1) at  (3.97,.75);

% Draw x and y axis lines
\draw [->, thick] (-4.51,0) -- (5.73,0) node [below] {$x$};
\draw [->,thick] (0,-4.43) -- (0,5.31) node [left] {$y$};

\draw[very thick] (O) circle (4.04cm);
\draw[blue, very thick] (A0) -- (B0)--(C0) --(A0);
\draw[blue, very thick] (A1) -- (B1)--(C1) --(A1);
\draw[dashed] (O) -- (B0);
\draw[very thick] (O) -- (A0);
\draw[very thick] (O) -- (A1);


\def\angleRadius{30pt}
    % draw the arc
    \draw[->,thick] let \p1=(O), \p2=(A0), \p3=(A1), 
        \n1={atan2(\x2-\x1,\y2-\y1)}, \n2={atan2(\x3-\x1,\y3-\y1)} in
        ($(\p1)!\angleRadius!(\p2)$) arc (\n1:\n2:\angleRadius);
    % draw the label
    \draw let \p1=(O), \p2=(A0), \p3=(A1), 
         \n1={atan2(\x2-\x1,\y2-\y1)}, \n2={atan2(\x3-\x1,\y3-\y1)} in
         (\p1)+(\n1/2+\n2/2:\angleRadius) node[right] {$\beta$};

\def\angleRadius{15pt}
    \draw[thick] let \p1=(O), \p2=(A0), \p3=(B0), 
        \n1={atan2(\x2-\x1,\y2-\y1)}, \n2={atan2(\x3-\x1,\y3-\y1)} in
        ($(\p1)!\angleRadius!(\p2)$) arc (\n1:\n2:\angleRadius);
    \draw[dashed] let \p1=(O), \p2=(A0), \p3=(A1), 
         \n1={atan2(\x2-\x1,\y2-\y1)}, \n2={atan2(\x3-\x1,\y3-\y1)} in
         (\p1)+(\n1/2+\n2/2:\angleRadius) node[above=15, left=-5] {$120^\circ$};


\shade [ball color = blue] (A0) circle (0.5ex) node [right=8, below=3] {$A_0$};
\shade [ball color = blue] (B0) circle (0.5ex) node [above] {$B_0$};
\shade [ball color = blue] (C0) circle (0.5ex) node [left=9, below] {$C_0$};
\shade [ball color = blue] (A1) circle (0.5ex) node [right=3] {$A_1$};
\shade [ball color = blue] (B1) circle (0.5ex) node [above=5, left=1] {$B_1$};
\shade [ball color = blue] (C1) circle (0.5ex) node [ below] {$C_1$};
\shade [ball color = blue] (An-1) circle (0.5ex) node [left=3] {$A_{n-1}$};
\shade [ball color = blue] (Bn-1) circle (0.5ex) node [below] {$B_{n-1}$};
\shade [ball color = blue] (Cn-1) circle (0.5ex) node [right] {$C_{n-1}$};

\shade [ball color = black] (O) circle (0.5ex) node [below=8, left=3] {$O$};

\end{tikzpicture}
\end{document}

它产生了

重新安装MikTex之前的图片

然而,当我重新安装 MiKTeX 时,出现了问题。上面的代码

重新安装MikTexe之后的图

问题是箭头的位置不对。标记角度的技巧似乎不再有效。我该如何解决这个问题?最简单的方法可能是使用另一个标记技巧。但我宁愿不这样做,因为我用那个技巧画了很多图形。任何建议都将不胜感激。

答案1

的语法atan2在版本 3 中发生了变化,交换了参数的顺序。原因是,在此函数的所有实现中,坐标在前,而在旧 PGF 版本 2 中,坐标必须按以下顺序给出坐标

如果您想要一个可以使用 TikZ/PGF 版本(2 或 3)进行编译的文档,您可以定义自己的函数,根据版本号改变其行为。

在这里,我在序言中定义了一个Xatan2与版本 3 具有相同语法的函数atan2。当使用 TikZ/PGF 版本 2 编译文档时,该函数会调用atan2但交换参数;否则它只是调用atan2

我已经相应地改变了你的宏定义,以便-坐标优先。

\documentclass[tikz]{standalone}
\usetikzlibrary{calc}

\makeatletter
\begingroup
\def\IfPGFversionIIorIII{%
  \expandafter\getPGFv@rsion\pgfversion\@nil
}
\def\getPGFv@rsion#1.#2\@nil{%
  \ifnum#1<3
    \expandafter\endgroup\expandafter\@firstoftwo
  \else
    \expandafter\endgroup\expandafter\@secondoftwo
  \fi}
\IfPGFversionIIorIII
  {\pgfmathdeclarefunction{Xatan2}{2}{\csname pgfmathatan2\endcsname{#2}{#1}}}% PGF version 2
  {\pgfmathdeclarefunction{Xatan2}{2}{\csname pgfmathatan2\endcsname{#1}{#2}}}% PGF version 3
\makeatother

\begin{document}

\begin{tikzpicture}

\coordinate (A0) at (4.04,0);
\coordinate (A1) at (2.93,2.79);
\coordinate (B0) at (-2.02,3.5);
\coordinate (B1) at (-3.88,1.14);
\coordinate (C0) at (-2.02,-3.5);
\coordinate (C1) at (0.95,-3.93);
\coordinate (O) at  (0,0);
\coordinate (An-1) at  (-2.64, 3.06);
\coordinate (Bn-1) at  (-1.33,-3.81);
\coordinate (Cn-1) at  (3.97,.75);

% Draw x and y axis lines
\draw [->, thick] (-4.51,0) -- (5.73,0) node [below] {$x$};
\draw [->,thick] (0,-4.43) -- (0,5.31) node [left] {$y$};

\draw[very thick] (O) circle (4.04cm);
\draw[blue, very thick] (A0) -- (B0)--(C0) --(A0);
\draw[blue, very thick] (A1) -- (B1)--(C1) --(A1);
\draw[dashed] (O) -- (B0);
\draw[very thick] (O) -- (A0);
\draw[very thick] (O) -- (A1);


\def\angleRadius{30pt}
    % draw the arc
    \draw[->,thick] let \p1=(O), \p2=(A0), \p3=(A1), 
        \n1={Xatan2(\y2-\y1,\x2-\x1)}, \n2={Xatan2(\y3-\y1,\x3-\x1)} in
        ($(\p1)!\angleRadius!(\p2)$) arc (\n1:\n2:\angleRadius);
    % draw the label
    \draw let \p1=(O), \p2=(A0), \p3=(A1), 
         \n1={Xatan2(\y2-\y1,\x2-\x1)}, \n2={Xatan2(\y3-\y1,\x3-\x1)} in
         (\p1)+(\n1/2+\n2/2:\angleRadius) node[right] {$\beta$};

\def\angleRadius{15pt}
    \draw[thick] let \p1=(O), \p2=(A0), \p3=(B0), 
        \n1={Xatan2(\y2-\y1,\x2-\x1)}, \n2={Xatan2(\y3-\y1,\x3-\x1)} in
        ($(\p1)!\angleRadius!(\p2)$) arc (\n1:\n2:\angleRadius);
    \draw[dashed] let \p1=(O), \p2=(A0), \p3=(A1), 
         \n1={Xatan2(\y2-\y1,\x2-\x1)}, \n2={Xatan2(\y3-\y1,\x3-\x1)} in
         (\p1)+(\n1/2+\n2/2:\angleRadius) node[above=15, left=-5] {$120^\circ$};


\shade [ball color = blue] (A0) circle (0.5ex) node [right=8, below=3] {$A_0$};
\shade [ball color = blue] (B0) circle (0.5ex) node [above] {$B_0$};
\shade [ball color = blue] (C0) circle (0.5ex) node [left=9, below] {$C_0$};
\shade [ball color = blue] (A1) circle (0.5ex) node [right=3] {$A_1$};
\shade [ball color = blue] (B1) circle (0.5ex) node [above=5, left=1] {$B_1$};
\shade [ball color = blue] (C1) circle (0.5ex) node [ below] {$C_1$};
\shade [ball color = blue] (An-1) circle (0.5ex) node [left=3] {$A_{n-1}$};
\shade [ball color = blue] (Bn-1) circle (0.5ex) node [below] {$B_{n-1}$};
\shade [ball color = blue] (Cn-1) circle (0.5ex) node [right] {$C_{n-1}$};

\shade [ball color = black] (O) circle (0.5ex) node [below=8, left=3] {$O$};

\end{tikzpicture}
\end{document}

我使用 TeX Live 2012(TikZ/PGF 版本 2.10)或 TeX Live 2013(TikZ/PGF 版本 3.0.0)进行编译得到的结果是相同的。

在此处输入图片描述

相关内容