使用独立包编译 TikZ 图片时出错

使用独立包编译 TikZ 图片时出错

我正在尝试使用该standalone包来外部化我的 TiZ 图形。在我的设置中,我有一个主.tex文件,将其命名main.tex为 TiZ 代码在另一个.tex文件中,请graphic.tex在同一目录中调用它。 就其本身而言,graphics.tex编译良好并输出.pdf包含预期图像的文件。 但是,如果我尝试使用该命令graphics.tex从内部调用,我会得到一个图像,其中某些元素的位置不对。 以下是产生错误的 MWE:main.tex\includestandalonemain.tex

\documentclass{article}
\usepackage{standalone}
\usepackage{tikz,tkz-euclide}
\usetkzobj{all}
\usetikzlibrary{arrows.meta}

\makeatletter
\DeclareFontFamily{U}{tipa}{}
\DeclareFontShape{U}{tipa}{m}{n}{<->tipa10}{}
\newcommand{\arc@char}{{\usefont{U}{tipa}{m}{n}\symbol{62}}}%

\newcommand{\arc}[1]{\mathpalette\arc@arc{#1}}

\newcommand{\arc@arc}[2]{%
  \sbox0{$\m@th#1#2$}%
  \vbox{
    \hbox{\resizebox{\wd0}{\height}{\arc@char}}
    \nointerlineskip
    \box0
  }%
}
\makeatother
\begin{document}
\includestandalone{graphic}
\end{document}

以下是代码graphic.tex

\documentclass[tikz]{standalone}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usetikzlibrary{arrows.meta}

\makeatletter
\DeclareFontFamily{U}{tipa}{}
\DeclareFontShape{U}{tipa}{m}{n}{<->tipa10}{}
\newcommand{\arc@char}{{\usefont{U}{tipa}{m}{n}\symbol{62}}}%

\newcommand{\arc}[1]{\mathpalette\arc@arc{#1}}

\newcommand{\arc@arc}[2]{%
  \sbox0{$\m@th#1#2$}%
  \vbox{
    \hbox{\resizebox{\wd0}{\height}{\arc@char}}
    \nointerlineskip
    \box0
  }%
}
\makeatother
\begin{document}
  \begin{tikzpicture}
  \path[use as bounding box] (-4.9,-4.1) rectangle (4.9,5.1);
  \tkzDefPoint(0,0){O}
  \tkzDefPoint(160:4){A}
  \tkzDefPoint(127:4){B}
  \tkzDefPoint(20:4){D}
  \tkzDefPoint(55:4){C}
  \tkzDefPoint(3.75,-2){X} % For Legend
  \tkzDrawCircle(O,A)
  \tkzDrawSegments(A,D B,C)
  \tkzDrawPoint[size=10](O)
  \tkzDrawPoints(A,B,C,D)
  \tkzLabelPoints[above left](A,B)
  \tkzLabelPoints[above right](C,D)
  \tkzDrawArc[R with nodes, color=blue, very thick,>=Stealth,arrows=<->](O,5)(D,A) %Create arc centered at origin with a radius of 4.75 that starts at D and ends at A
  \tkzDrawArc[R with nodes, color=red, very thick,>=Stealth,arrows=<->](O,4.5)(B,A)
  \tkzDrawArc[R with nodes, color=green!60!black, very thick,>=Stealth,arrows=<->](O,4.75)(C,B)
  \shade[ball color=blue] (X) circle (0.1cm) node[right=0.1cm]{$\arc{AD}$};
  \shade[ball color=green!60!black] ($ (X)+(0,-0.5) $) circle (0.1cm) node[right=0.1cm]{$\arc{BC}$};
  \shade[ball color=red] ($ (X)+(0,-1) $) circle (0.1cm) node[right=0.1cm]{$\arc{AB}$};
  \end{tikzpicture}
\end{document}

有什么方法可以让它正确编译吗?我知道我可以只使用\includegraphics来插入.pdf图形文件,但缺点是任何格式更改(文本、文本大小)都不会反映在图形中。

相关内容