插入具有定义自定义节点的 tikz 独立版时出现问题

插入具有定义自定义节点的 tikz 独立版时出现问题

我正在尝试将已实现的 tikz 图形插入另一个 latex 文档。我在独立文档中定义了 tikz 图形。我定义了 \tikzset 以绘制十字节点。当我单独编译此图形时,它正常工作,这意味着十字线被识别。当我使用输入将图形插入另一个 latex 文档时,图形可以编译,但十字线无法识别,因此它们在文档中被忽略。

\input{}

我的图形的独立文档如下所示:

\documentclass[tikz, border=2mm]{standalone}
\usetikzlibrary{shapes.misc}
\usepackage{tkz-euclide}

\tikzset{cross/.style={cross out, draw=black, minimum size=2*(#1-\pgflinewidth), inner sep=0pt, outer sep=0pt},
%default radius will be 1pt. 
cross/.default={1pt}}

\begin{document}
\begin{tikzpicture}%[scale = 0.4, every node/.style={scale=0.7}]
\tkzInit[xmax=12,ymax=12,xmin=-3,ymin=-3]
\tkzGrid
\tkzAxeXY
\coordinate (p1) at (0,0);
\coordinate (p2) at (6.6,5);
\coordinate (p3) at (5,7) ;
\draw  (0,0)node[cross = 4pt, thick, red, rotate = 90, label = {[black] above right :  \huge BS}](BS) {};
\draw  (6.6,5) node[cross = 4pt, thick, red, rotate = 90, label = {[black] below :  \huge UE}](UE) {};
\draw [shorten >=1em, -> ,shorten <=1em,  dashed, thick](BS) [out = 70, in = 175] to node[above,left, scale = 1.5]{TPC}(p2);
\draw [shorten >=1em, -> ,shorten <=1em,  dashed, thick](UE) [out = 250, in = 5] to node[below,left, scale = 1.5]{Signal}(p1);
\draw [->](p2) to node[above, left, scale = 1.5]{$\vec{v}$}(p3);
\end{tikzpicture}%}
\end{document}
 

这是应该实现的图形:

在此处输入图片描述

这里给出了插入独立 tikz 图形的最小文档:

\documentclass{article}
\usepackage{tikz}
\usepackage{standalone}
\usepackage{tkz-euclide}


\begin{document}
    
\begin{figure}
    \centering
    \adjustbox{width = 0.6\textwidth}{  \input{path to standlone document}}
    \caption{case1: problem setting}
    \label{fig:probl_sett}
\end{figure}
    
\end{document}  

当我编译第二段代码(插入独立文档)时,我得到以下图形: 在此处输入图片描述

答案1

您应该cross在主tex文件中包含样式定义:

\documentclass{article}
\usepackage{tikz}
\usepackage{standalone}
\usepackage{tkz-euclide}
\tikzset{cross/.style={cross out, draw=black, minimum size=2*(#1-\pgflinewidth), inner sep=0pt, outer sep=0pt},
%default radius will be 1pt. 
cross/.default={1pt}}


\begin{document}
    
\begin{figure}
    \centering
    \adjustbox{width = 0.6\textwidth}{  \input{path to standlone document}}
    \caption{case1: problem setting}
    \label{fig:probl_sett}
\end{figure}
    
\end{document}  

答案2

在主文件中您需要tkz-base

\documentclass[tikz, border=2mm]{standalone}
%\usetikzlibrary{shapes.misc}
\usepackage{tkz-base,tkz-euclide}

在子文件中:您只需要:

\documentclass{article}
\usepackage{standalone}

\begin{document}

\begin{figure}
    \centering
    \adjustbox{width = 0.6\textwidth}{%
    \input{test}
      %\input{path to standlone document
      }}
    \caption{case1: problem setting}
    \label{fig:probl_sett}
\end{figure}

\end{document}

相关内容