패키지 pgf 오류: C_1 모양이 알려져 있지 않습니다.

패키지 pgf 오류: C_1 모양이 알려져 있지 않습니다.

그래프의 라텍스 코드를 컴파일하려고 했습니다. 그러나 많은 오류가 발생했습니다. 패키지 pgf 오류: 알려진 모양 C_1이 없습니다. 그래프의 모든 노드에 대해 오류가 나타납니다.

내가 사용한 코드는 다음과 같습니다.

     \documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes}
\usepackage{dot2texi}
\begin{document}
% Define layers
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}

% The scale option is useful for adjusting spacing between nodes.
% Note that this works best when straight lines are used to connect
% the nodes.
\begin{tikzpicture}[>=latex',scale=0.8]
    % set node style
    \tikzstyle{n} = [draw,shape=circle,minimum size=2em,
                        inner sep=0pt,fill=red!20]
    \begin{dot2tex}[dot,tikz,codeonly,styleonly,options=-s -tmath]
        digraph G  {
            node [style="n"];
            A_1 -> B_1; A_1 -> B_2; A_1 -> B_3;
            B_1 -> C_1; B_1 -> C_2;
            B_2 -> C_2; B_2 -> C_3;
            B_3 -> C_3; B_3 -> C_4;
        }
    \end{dot2tex}
    % annotations
    \node[left=1em] at (C_1.west)  (l3) {Level 3};
    \node at (l3 |- B_1) (l2){Level 2};
    \node at (l3 |- A_1) (l1) {Level 1};
    % Draw lines to separate the levels. First we need to calculate
    % where the middle is.
    \path (l3) -- coordinate (l32) (l2) -- coordinate (l21) (l1);
    \draw[dashed] (C_1 |- l32) -- (l32 -| C_4);
    \draw[dashed] (C_1 |- l21) -- (l21 -| C_4);
    \draw[<->,red] (A_1) to[out=-120,in=90] (C_2);
    % Highlight the A_1 -> B_1 -> C_2 path. Use layers to draw
    % behind everything.
    \begin{pgfonlayer}{background}
        \draw[rounded corners=2em,line width=3em,blue!20,cap=round]
                (A_1.center) -- (B_1.west) -- (C_2.center);
    \end{pgfonlayer}
\end{tikzpicture}
\end{document}

답변1

필수 조건:

  • 프로그램dot2tex설치해야 합니다.

  • LaTeX 실행을 위한 옵션 -shell-escape또는 (MiKTeX)입니다.--enable-write18

그런 다음 패키지dot2texi파일의 TikZ 명령을 사용하여 도트 데이터를 TeX 코드로 변환합니다 \jobname-dot2tex-fig1.tex(패키지 참조)선적 서류 비치):

%%
\node (A_1) at (147bp,162bp) [n] {$A_1$};
  \node (C_1) at (30bp,18bp) [n] {$C_1$};
  \node (C_3) at (186bp,18bp) [n] {$C_3$};
  \node (C_2) at (108bp,18bp) [n] {$C_2$};
  \node (C_4) at (264bp,18bp) [n] {$C_4$};
  \node (B_1) at (69bp,90bp) [n] {$B_1$};
  \node (B_2) at (147bp,90bp) [n] {$B_2$};
  \node (B_3) at (225bp,90bp) [n] {$B_3$};
  \draw [->] (B_1) -- (C_1);
  \draw [->] (B_3) -- (C_4);
  \draw [->] (B_3) -- (C_3);
  \draw [->] (B_1) -- (C_2);
  \draw [->] (A_1) -- (B_1);
  \draw [->] (A_1) -- (B_3);
  \draw [->] (A_1) -- (B_2);
  \draw [->] (B_2) -- (C_2);
  \draw [->] (B_2) -- (C_3);
%

그런 다음 C_1다른 노드가 정의되고 예제가 오류 없이 실행됩니다.

결과

관련 정보