Has anyone ever drawn a football field in latex? I know that could seem like a strange request. But I'm looking for a package that allows me to draw a football field.
TikZ PGF – Drawing a Football Field in LaTeX
tikz-pgf
Related Solutions
Further explanations will follow, for now so much:
- put your sketch in a node
- recreate the lines using draw commands (I used
to[in=,out=,looseness=]
) - remove the sketch
It's far from perfect, somee labels are missing. You can increase the quality ba adding more intermediate points.
(Final) Code
\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}
\usetikzlibrary{scopes,intersections}
\newcommand{\Coordinate}[2]%
{ \coordinate (#1) at (#2);
%\fill[red] (#2) circle (0.05) node[above] {#1};
}
\begin{document}
\begin{frame}
\begin{tikzpicture}
% \node[above right,inner sep=0,outer sep=0] (a) {\includegraphics{klein.png}};
% \draw[orange,thin,dashed,] (a.south west) grid (a.north east);
% \foreach \x in {0,...,10}{\node [below] at (\x,0) {\x};}
% \foreach \y in {0,...,12}{\node [left] at (0,\y) {\y};}
\node[fill=blue,circle,label=0:P1,inner sep=0.5mm] (P1) at (4.9,6.7) {};
\node[fill=blue,circle,label=270:P2,inner sep=0.5mm] (P2) at (2.5,5.4) {};
\node[fill=blue,circle,label=45:P3,inner sep=0.5mm] (P3) at (1.6,4) {};
\Coordinate{e5b}{3.6,1.3}
\Coordinate{e4l}{0.7,4.8}
\Coordinate{e4r}{9.9,3.7}
\Coordinate{si}{4.5,7.4}
\Coordinate{bottom}{6.8,0.9}
{[very thick,black]
\draw (e4l) to[out=270,in=160,looseness=1] (P3);
\draw (P3) to[out=340,in=270,looseness=0.3] node[above,pos=0.7,black] {$e_4$} (e4r);
\draw[name path=P2e4r] (P2) to[out=120,in=80,looseness=3.7] node[below left,pos=0.7,black] {$f_2$} (e4r);
\draw[name path=P1P1] (P1) to[out=160,in=270,looseness=1] (2.6,9) to[out=90,in=90,looseness=1.3] node[above, pos=0.5,black] {$e_3$} (6.6,9.6) to[out=270,in=40,looseness=1] (P1) ;
\draw (P2) to[out=315,in=315,looseness=0.5] node[below right,pos=0.5,black] {$e_1$} (P1);
\draw[dashed] (P2) to[out=135,in=135,looseness=0.5] node[below right,pos=0.5,black] {$f_1$} (P1);
\draw (P2) to[out=220,in=90,looseness=1] (P3);
\draw (P3) to[out=270,in=150,looseness=1] (e5b);
\draw (e4l) to[out=270,in=160,looseness=1.3] (e5b);
\draw (e5b) to[out=340,in=260,looseness=1.1] (e4r);
\draw[dashed] (P2) to[out=300,in=330,looseness=1] (e5b);
\draw[dashed] (e4l) to[out=90,in=90,looseness=0.6] (e4r);
\draw[dashed] (P1) to[out=320,in=190,looseness=0.4] (bottom);
\draw (P1) to[out=110,in=300,looseness=1] (si);
\draw (si) to[out=120,in=270,looseness=1] (4,8.5) to[out=90,in=180,looseness=1] (5.2,9.7) to[out=0,in=90,looseness=1] (6,9) to[out=270,in=20,looseness=1] (si);
\path[name path=e4lsi] (e4l) to[out=90,in=200,looseness=0.8] (si);
\draw[name intersections={of=e4lsi and P2e4r}] (e4l) to[out=90,in=210,looseness=1] (intersection-1) coordinate (h1);
\draw[dashed] (intersection-1) to[out=30,in=200,looseness=0.6] (si);
}
\end{tikzpicture}
\end{frame}
\end{document}
Output
The crows foot can be done quite simply with an arrow head. The rest is a matter of simplification using styles
and macros, which can be done in many ways. Here is one:
\documentclass[border=0.25in]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart}
\usetikzlibrary{matrix}
\usetikzlibrary{positioning}
\usetikzlibrary{shadows}
\usetikzlibrary{calc}
\makeatletter
\pgfarrowsdeclare{crow's foot}{crow's foot}
{
\pgfarrowsleftextend{+-.5\pgflinewidth}%
\pgfarrowsrightextend{+.5\pgflinewidth}%
}
{
\pgfutil@tempdima=0.5pt%
\advance\pgfutil@tempdima by.25\pgflinewidth%
\pgfsetdash{}{+0pt}%
\pgfsetmiterjoin%
\pgfpathmoveto{\pgfqpoint{0pt}{-6\pgfutil@tempdima}}%
\pgfpathlineto{\pgfqpoint{-6\pgfutil@tempdima}{0pt}}%
\pgfpathlineto{\pgfqpoint{0pt}{6\pgfutil@tempdima}}%
\pgfusepathqstroke%
}
\tikzset{
entity/.code={
\tikzset{
label=above:#1,
name=#1,
inner sep=0pt,
every entity/.try,
fill=white,
general shadow={
shadow xshift=0.0625in,
shadow yshift=-0.0625in,
opacity=0.5,
fill=black!50
}
}%
\def\entityname{#1}%
},
entity anchor/.style={matrix anchor=#1.center},
every entity/.style={
draw,
},
every property/.style={
inner xsep=0.25cm, inner ysep=0.125cm, anchor=west, text width=1in
},
zig zag to/.style={
to path={(\tikztostart) -| ($(\tikztostart)!#1!(\tikztotarget)$) |- (\tikztotarget)}
},
zig zag to/.default=0.5,
one to many/.style={
-crow's foot, zig zag to
},
many to one/.style={
crow's foot-, zig zag to
},
many to many/.style={
crow's foot-crow's foot, zig zag to
}
}
\def\property#1{\node[name=\entityname-#1, every property/.try]{#1};}
\def\properties{\begingroup\catcode`\_=11\relax\processproperties}
\def\processproperties#1{\endgroup%
\def\propertycode{}%
\foreach \p in {#1}{%
\expandafter\expandafter\expandafter\gdef\expandafter\expandafter\expandafter\propertycode%
\expandafter\expandafter\expandafter{\expandafter\propertycode\expandafter\property\expandafter{\p}\\}%
}%
\propertycode%
}
\begin{document}
\begin{tikzpicture}[every node/.style={font=\ttfamily}, node distance=1.25in]
\matrix [entity=Class] {
\properties{
classkey,
class_type,
class_desc
}
};
\matrix [entity=Product, right=of Class-classkey, entity anchor=Product-classkey] {
\properties{
classkey,
prodkey,
prod_name,
pkg_type
}
};
\matrix [entity=Sales, right=of Product-classkey, entity anchor=Sales-classkey] {
\properties{
perkey,
classkey,
prodkey,
prod_name,
storekey,
promokey,
quantity,
dollars
}
};
\matrix [entity=Period, right=of Sales-perkey, entity anchor=Period-perkey] {
\properties{
perkey,
date,
day,
week,
month,
qtr,
year
}
};
\matrix [entity=Promotion, below=of Period, entity anchor=Promotion-promokey] {
\properties{
promokey,
promo_type,
promo_desc,
value,
start_date,
end_date
}
};
\matrix [entity=Store, below=of Product, entity anchor=Store-storekey] {
\properties{
storekey,
mktkey,
store_type,
store_name,
street,
city,
state,
zip
}
};
\matrix [entity=Market, left=of Store-mktkey, entity anchor=Market-mktkey] {
\properties{
mktkey,
hq_city,
hq_state,
district,
region
}
};
\draw [one to many] (Class-classkey) to (Product-classkey);
\draw [one to many] (Product-classkey) to (Sales-classkey);
\draw [one to many] (Product-prodkey) to (Sales-prodkey);
\draw [many to one] (Sales-perkey) to (Period-perkey);
\draw [one to many] (Market-mktkey) to (Store-mktkey);
\draw [many to one] (Sales-storekey) to (Store-storekey);
\draw [many to one] (Sales-promokey) to (Promotion-promokey);
\end{tikzpicture}
\end{document}
Best Answer
Just for fun:
Some comments:
The code for the football field is from Alenanno.
I've copied player names (and positions) from Spanish newspapers which doesn't show correct spelling for Croacian/French players. Please fill free to correct them or let me know the correct spelling.
Update:
marmot
suggested atikzmarmots
version. Here it is.2nd Update: I almost forgot
tikzpeople
.I've been unable to customize Croatian shirt. If you know how to do it, please let me know or feel free to edit the code.