# How can I center this tikz picture?

I have a graph that clips off the screen. I tried to center it with \begin{center}, but it doesn't seem to have any effect.

Here's my code:

\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}

\usetikzlibrary{arrows}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{positioning}

\begin{document}

\begin{center}
\begin{tikzpicture}
\node[text width=5cm,align=center,draw] (ftli) {
\textbf{FTLI}:
$\int_{C}\nabla f \cdot \,d \vec{s} = f(\vec{B}) - f(\vec{A})\,.$

for any curve $C$ in $X$ which starts at $\vec{A}$ and ends at $\vec{B}$.
};
\node[text width=5cm,align=center,draw] (pi) [below left= 3cm of ftli] {
\textbf{Path Independent on} $X$:
$\int_{C_1} F\,ds = \int_{C_2} F\,ds$
for any two curves $C_1$ and $C_2$ in $X$ which start and end at the same points.
};
\node[text width=5cm,align=center,draw] (cons) [below right= 3cm of ftli] {
\textbf{$F$ Conservative}
$\nabla f = \vec{F}.$
on $X$ for some function $f$.
};
\node[draw,dotted,align=center] (0) [below= 3cm of pi] {
$$\oint_{C} Fds=0$$
for all closed curves $C$ on $X$.
};

\node[draw,dotted,align=center] (sym) [below= 5cm of cons] {$D\vec{F}$ is symmetric on $X$.};

\draw[shorten >=0.5cm,double,-{>[length=5pt]},double distance = 2pt] (ftli) -- (pi) node[midway,above] {(Corollary of the FTLI)};

\draw[shorten <=0.5cm,double,-{>[length=5pt]},double distance = 2pt] (cons) -- (ftli) node[midway,above] {$X$ \textcolor{ForestGreen}{open}, \textcolor{Blue}{connected}.};

\draw[shorten <=0.1cm,shorten >=0.1cm,double,{<[length=5pt]}-{>[length=5pt]},double distance = 2pt] (pi) -- (0);

\draw[shorten >=0.1cm,shorten <=0.1cm,double,{[length=5pt]}-{>[length=5pt]},double distance = 2pt] (cons) -- (sym) node[midway,above] {$X$ \textcolor{ForestGreen}{open}, \textcolor{Blue}{\textit{connected}}.};

\draw[shorten >=0.1cm,shorten <=0.1cm,double,{[length=5pt]}-{>[length=5pt]},double distance = 2pt] (sym) -- (0) node[midway,above] {$X$ \textcolor{ForestGreen}{open}, \textcolor{Brown}{\textit{simply connected}}, $\vec{F}$ is $C^1$.};
\end{tikzpicture}
\end{center}

\end{document}


Here's what it looks like:

1. How can I center the graph?
2. How can I make the base of the 'pentagon' (The one where it says X open, simply connected) be flush. I approximated the y-position, but I'm wondering how can I specify that it should be below one node and to the right of the other?
• You can use \makebox[\textwidth]{...} and have it run off the page on both sides. Apr 5, 2023 at 2:23

A couple of suggestions:

• the default textwidth of article is very small. If you make it larger, e.g. with the geometry package, you'll have more space for your diagram.

• move the two branches of your diagram closer together

• you can use the positioning library syntax to specify the below of and right of parts separately:

\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}

\usepackage{geometry}

\usetikzlibrary{arrows}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{positioning}

\begin{document}

\begin{center}
\begin{tikzpicture}[node distance=5cm and -2cm]
\node[text width=5cm,align=center,draw] (ftli) {
\textbf{FTLI}:
$\int_{C}\nabla f \cdot \,d \vec{s} = f(\vec{B}) - f(\vec{A})\,.$

for any curve $C$ in $X$ which starts at $\vec{A}$ and ends at $\vec{B}$.
};
\node[text width=5cm,align=center,draw,below left=of ftli] (pi) {
\textbf{Path Independent on} $X$:
$\int_{C_1} F\,ds = \int_{C_2} F\,ds$
for any two curves $C_1$ and $C_2$ in $X$ which start and end at the same points.
};
\node[text width=5cm,align=center,draw,below=of ftli,right=2cm of pi] (cons) {
\textbf{$F$ Conservative}
$\nabla f = \vec{F}.$
on $X$ for some function $f$.
};
\node[draw,dotted,align=center,below=of pi,text width=5cm] (0)  {
$$\oint_{C} Fds=0$$
for all closed curves $C$ on $X$.
};

\node[draw,dotted,align=center,below=of cons,right=2cm of 0,text width=5cm] (sym)  {$D\vec{F}$ is symmetric on $X$.};

\draw[shorten >=0.5cm,double,-{>[length=5pt]},double distance = 2pt] (ftli) -- (pi) node[midway,above left] {(Corollary of the FTLI)};

\draw[shorten <=0.5cm,double,-{>[length=5pt]},double distance = 2pt] (cons) -- (ftli) node[midway,above right] {$X$ \textcolor{ForestGreen}{open}, \textcolor{Blue}{connected}.};

\draw[shorten <=0.1cm,shorten >=0.1cm,double,{<[length=5pt]}-{>[length=5pt]},double distance = 2pt] (pi) -- (0);

\draw[shorten >=0.1cm,shorten <=0.1cm,double,{[length=5pt]}-{>[length=5pt]},double distance = 2pt] (cons) -- (sym) node[midway,right] {$X$ \textcolor{ForestGreen}{open}, \textcolor{Blue}{\textit{connected}}.};

\draw[shorten >=0.1cm,shorten <=0.1cm,double,{[length=5pt]}-{>[length=5pt]},double distance = 2pt] (sym) -- (0) node[midway,above=0.8cm] {$X$ \textcolor{ForestGreen}{open}, \textcolor{Brown}{\textit{simply connected}}, $\vec{F}$ is $C^1$.};
\end{tikzpicture}
\end{center}

\end{document}


• thank you so much again!! Can you explain what exactly you changed to fix those issues? Apr 5, 2023 at 0:00
• @Coder100 I added the main points at the start of the anwer Apr 5, 2023 at 0:02

Your picture remained me on a tree. It can be (relatively simple) drawn with use of forest package:

\documentclass{article}
\usepackage{geometry}

\usepackage[dvipsnames]{xcolor}
\usepackage{forest}
\usetikzlibrary{arrows.meta}

\begin{document}
\begin{center}
\begin{forest}
for tree = {draw,
text width=64mm, text centered,
outer sep=2pt,
edge = {arr=->},
l sep=12mm,
s sep=12mm,
tier/.option=level,
/tikz/arr/.style = {>=Implies, double, double distance=2pt, #1},
/tikz/ELS/.style = {% Edge Label Style
pos=0.5,
outer sep=4pt, anchor=#1},
EL/.style = {if n=1{edge label={node[ELS=east]{$#1$}}}
{edge label={node[ELS=west]{$#1$}}}}
},
%%%% diagram body
[{\textbf{FTLI}:
$\int_{C}\nabla f \cdot \,d \vec{s} = f(\vec{B}) - f(\vec{A})\,.,$
for any curve $C$ in $X$ which starts at $\vec{A}$ and ends at $\vec{B}$.,
}
[\textbf{Path Independent on} $X$:
${\int_{C_1} F\,ds = \int_{C_2} F\,ds}$
for any two curves $C_1$ and $C_2$ in $X$ which start and end at the same points.,
name=A,
EL={(Corollary of the FTLI)}
[{$\oint F\,ds$ for all closed curves $C$ on $X$}, dashed, no edge,
name=L]
]
[{\textbf{$F$ Conservative}
$\nabla f = \vec{F}$
on $X$ for some function $f$.},
name=B,
EL={$X$ \textcolor{ForestGreen}{open},
\textcolor{Blue}{connected}}
[ $D\vec{F}$ is symmetric on $X$., densely dashed, name=R,
]
]
]
\draw[arr=<->] (A) -- (L);
\draw[arr=->]  (R) -- node[above=4mm]  {$X$ \textcolor{ForestGreen}{open},
\textcolor{Brown}
{\textit{simply connected}},
$\vec{F}$ is $C^1$.} (L);
\draw[arr=->]  (B) -- node[right]  {$X$ \textcolor{ForestGreen}{open},
\textcolor{Blue}{connected}} (R);
\end{forest}
\end{center}
\end{document}


• that works great too, thank you! However, the diagonal two implications look a bit squished, how do you fix this? Apr 5, 2023 at 15:00
• @Coder100, hm, what you mean with "squished"? To me all implication looks the same (as use the same definition). What you like to change? Apr 5, 2023 at 15:17
• Maybe it's because of the font or something, but the implications to PI and conservative, their labels look squished and look smaller than the other implications Apr 5, 2023 at 15:42
• @Coder100, I see now, I will look in the code ASAP. Apr 5, 2023 at 15:50
• @Coder100, ah, just remove node font=\scriptsize, from ELS style. Corrected now. Apr 5, 2023 at 16:03