这是一个关于 tikz 绘图的两个对象的非常具体的问题。第一个显示了以下内容:
第二个来自这个讨论:鱼尾纹 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 重现。这是错误代码的屏幕截图。我不知道细长部分(U+2009)在哪里……inputenc 手册在第 4 页也没有显示更多有用的信息。(或者我不明白其中的意思……)任何帮助都感激不尽……
答案1
无论有没有第二部分,第一部分都会出现错误,因为键arrow
未定义。
添加行
\tikzset{arrow/.style={-stealth})
回到序言。