
Esta es una pregunta muy específica sobre dos objetos de dibujos tikz. El primero muestra esto:
El segundo es de esta discusión:ERM pata de gallo en una forma agradable
Tengo que cambiar la configuración tikset{
o tikzpicture{
para que ambos funcionen.
este es un 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}
¿Cómo puedo cambiar la primera parte para que ambas funcionen?
Editar: Parece que hay otro problema que no puedo reproducir con el MWE. Esta es una captura de pantalla del código de error. No tengo idea de dónde está Thinspce (U+2009)... El manual de entrada tampoco muestra más información útil en la página 4. (o no veo el significado...) Se agradece cualquier ayuda...
Respuesta1
La primera parte da un error, con o sin la segunda parte, porque la clave arrow
no está definida.
Añade la línea
\tikzset{arrow/.style={-stealth})
al preámbulo.