두 개의 tikz 그림이 간섭하고 있습니다.

두 개의 tikz 그림이 간섭하고 있습니다.

이것은 tikz 그림의 두 가지 개체에 대한 매우 구체적인 질문입니다. 첫 번째는 다음을 보여줍니다.

사용 사례다이어그램확장 및 포함

두 번째는 이 토론에서 나온 것입니다.Crow's Foot ERM은 좋은 방법입니다.

둘 다 작동하려면 tikset{또는 설정을 변경해야 합니다 .tikzpicture{

이것은 MWE입니다:

\documentclass{article}
\usepackage{array}
\renewcommand{\arraystretch}{1.1}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart}
\usetikzlibrary{positioning}
\usetikzlibrary{shadows}
\usetikzlibrary{calc}

% code for "one to omany", etc. is taken from https://tex.stackexchange.com/q/141797/101651
\makeatletter
\pgfarrowsdeclare{crow's foot}{crow's foot}
{
    \pgfarrowsleftextend{+-.5\pgflinewidth}%
    \pgfarrowsrightextend{+.5\pgflinewidth}%
}
{
    \pgfutil@tempdima=0.6pt%
    %\advance\pgfutil@tempdima by.25\pgflinewidth%
    \pgfsetdash{}{+0pt}%
    \pgfsetmiterjoin%
    \pgfpathmoveto{\pgfqpoint{0pt}{-9\pgfutil@tempdima}}%
    \pgfpathlineto{\pgfqpoint{-13\pgfutil@tempdima}{0pt}}%
    \pgfpathlineto{\pgfqpoint{0pt}{9\pgfutil@tempdima}}%
    \pgfpathmoveto{\pgfqpoint{0\pgfutil@tempdima}{0\pgfutil@tempdima}}%
    \pgfpathmoveto{\pgfqpoint{-8pt}{-6pt}}% 
    \pgfpathlineto{\pgfqpoint{-8pt}{-6pt}}%  
    \pgfpathlineto{\pgfqpoint{-8pt}{6pt}}% 
    \pgfusepathqstroke%
}

\pgfarrowsdeclare{omany}{omany}
{
    \pgfarrowsleftextend{+-.5\pgflinewidth}%
    \pgfarrowsrightextend{+.5\pgflinewidth}%
}
{
    \pgfutil@tempdima=0.6pt%
    %\advance\pgfutil@tempdima by.25\pgflinewidth%
    \pgfsetdash{}{+0pt}%
    \pgfsetmiterjoin%
    \pgfpathmoveto{\pgfqpoint{0pt}{-9\pgfutil@tempdima}}%
    \pgfpathlineto{\pgfqpoint{-13\pgfutil@tempdima}{0pt}}%
    \pgfpathlineto{\pgfqpoint{0pt}{9\pgfutil@tempdima}}%
    \pgfpathmoveto{\pgfqpoint{0\pgfutil@tempdima}{0\pgfutil@tempdima}}%  
    \pgfpathmoveto{\pgfqpoint{0\pgfutil@tempdima}{0\pgfutil@tempdima}}%
    \pgfpathmoveto{\pgfqpoint{-6pt}{-6pt}}% 
    \pgfpathcircle{\pgfpoint{-11.5pt}{0}} {3.5pt}
    \pgfusepathqstroke%
}

\pgfarrowsdeclare{one}{one}
{
    \pgfarrowsleftextend{+-.5\pgflinewidth}%
    \pgfarrowsrightextend{+.5\pgflinewidth}%
}
{
    \pgfutil@tempdima=0.6pt%
    %\advance\pgfutil@tempdima by.25\pgflinewidth%
    \pgfsetdash{}{+0pt}%
    \pgfsetmiterjoin%
    \pgfpathmoveto{\pgfqpoint{0\pgfutil@tempdima}{0\pgfutil@tempdima}}%
    \pgfpathmoveto{\pgfqpoint{-6pt}{-6pt}}% 
    \pgfpathlineto{\pgfqpoint{-6pt}{-6pt}}%  
    \pgfpathlineto{\pgfqpoint{-6pt}{6pt}}% 
    \pgfpathmoveto{\pgfqpoint{0\pgfutil@tempdima}{0\pgfutil@tempdima}}%
    \pgfpathmoveto{\pgfqpoint{-8pt}{-6pt}}% 
    \pgfpathlineto{\pgfqpoint{-8pt}{-6pt}}%  
    \pgfpathlineto{\pgfqpoint{-8pt}{6pt}}%    
    \pgfusepathqstroke%
}
\makeatother

\tikzset{%
    arrow/.style={-stealth},
    %Define style for boxes around first tikzpicture
    punktblue/.style={ % <-- see here is no args as below
           rectangle,
           rounded corners,
           draw=blue, very thick,
           text centered},
    punktred/.style={
           rectangle,
           rounded corners,
           draw=red, very thick,
           %text width=6.5em,
           %minimum height=2em,
           text centered},        
    pics/entity/.style n args={3}{code={%  <-- see here are more definitions then above
            \node[draw, blue,
            shade, top color=white, bottom color=blue!30,
            drop shadow={gray!70,
                shadow xshift=3pt,
                shadow yshift=-3pt,
                rounded corners},  
            rounded corners,  
            font=\ttfamily\footnotesize, 
            rectangle
            ] (#1)
            {\color{black}\begin{tabular}{>{\raggedright\arraybackslash}p{4.5em}>{\raggedleft\arraybackslash}p{6em}}
                    #3
                \end{tabular}
            };%
            \node[font=\ttfamily\footnotesize,
            text height=1.5ex,text depth=.25ex,
            above =0pt of #1
            ] 
            {#2};%
    }},
    pics/entitysimple/.style n args={3}{code={%
            \node[draw, rounded corners,             
            rectangle split,
            rectangle split parts=2,
            font=\ttfamily\footnotesize,
            text height=1.5ex,text depth=.25ex
            ] (#1)
            {#2 \nodepart{second} 
                \begin{tabular}{>{\raggedright\arraybackslash}p{4.5em}>{\raggedleft\arraybackslash}p{6em}}
                    #3
                \end{tabular}
            };%
    }},
    zig zag to/.style={
        to path={(\tikztostart) -| ($(\tikztostart)!#1!(\tikztotarget)$) |- (\tikztotarget)}
    },
    zig zag to/.default=0.5,   
    one to one/.style={
        one-one, zig zag to
    },    
    one to many/.style={
        one-crow's foot, zig zag to,
    },
    one to omany/.style={
        one-omany, zig zag to
    },      
    many to one/.style={
        crow's foot-one, zig zag to
    },
    many to many/.style={
        crow's foot-crow's foot, zig zag to
    }, 
}
\begin{document}
%this is the first part that doesn't work since i added the second part
    \begin{tikzpicture}[node distance=0cm, auto,]
      \node[punktblue,inner sep=5pt] (A) {A};
      \node[punktred,inner sep=5pt,right=2cm of A] (B) {B};
      \node[right=of A] (t) {\footnotesize include}  edge[arrow, bend left=0] (B.west); %<-- if you comment out this line it works.
    \end{tikzpicture}
% this is the second part i added:
    \begin{center}
        \begin{tikzpicture}
        \pic {entitysimple={empl}{Employee}{%
                Username: & \textcolor{red}{(PK)} \\
                Password: & varchar(255) \\        
                Name: & varchar(255) \\
                LastName: & varchar(255) \\ 
        }};
        \pic[right=7em of empl] {entitysimple={stud}{Student}{%
                Username: & \textcolor{red}{(PK)} \\
                Password: & varchar(255) \\        
                Name: & varchar(255) \\
                LastName: & varchar(255) \\ 
        }};
        \pic[below=12ex of stud] {entitysimple={thesis}{Thesis}{%
                Title: & \textcolor{red}{(PK)} \\
                Year: & numeric(4) \\        
        }};
        \draw[one to omany] (empl.east) -- node[above]{\footnotesize\texttt{teaches}} (stud.west);
        \draw[one to one] (stud.south) -- node[left]{\footnotesize\texttt{writes}} (thesis.north);
        \draw[one to many] (empl.south) |- node[left, yshift=44pt, xshift=-2pt] {\footnotesize\texttt{supervises}} (thesis.west);
        \end{tikzpicture}
    \end{center}        
\end{document}

두 가지가 모두 작동하도록 첫 번째 부분을 어떻게 변경할 수 있습니까?

편집하다: MWE로 재현할 수 없는 또 다른 문제가 있는 것 같습니다. 오류코드 스크린샷입니다. Thinspce(U+2009)가 어디에 있는지 전혀 모르겠습니다... inputenc 매뉴얼은 4페이지에도 더 유용한 정보를 표시하지 않습니다. (아니면 의미를 모르겠습니다...) 어떤 도움이라도 감사하겠습니다...

스크린샷

답변1

arrow키가 정의되지 않았기 때문에 첫 번째 부분에서는 두 번째 부분이 있든 없든 오류가 발생합니다 .

라인을 추가하세요

\tikzset{arrow/.style={-stealth})

서문에.

관련 정보