# How can I adjust this tikzpicture to my a4 page?

How can I adjust this tikzpicture to my a4 page? I write this after my paragraph. But it goes to before my title, to the top of my page.

 \documentclass{ltxdoc}
\usepackage[demo]{tikzpeople}
\usepackage[OT1]{fontenc}
\usepackage{hyperref}
\usepackage{microtype}
\usepackage{xspace}
\usepackage[most]{tcolorbox}
\usepackage[title]{appendix}
\usetikzlibrary{shapes.callouts}
\begin{document}
\section{Commintment}
//explanation some
\begin{figure}
\begin{tikzpicture}[font=\small]
\node[alice,minimum size=1.5cm] (A) {};
\node[bob,right=3cm of A,minimum size=1.5cm,mirrored] (B) {};
\node[anchor=north east] at (A.north west) (a2) {$(\mathsf{com},\mathsf{dec}) \gets \mathsf{Com}(a)$};
\node[anchor=south] at (a2.north) (a1) {$a\gets\{0,1\}$};
\node[anchor=south west] at (B.south east){$a \gets \mathsf{Opn}(\mathsf{com},\mathsf{dec})$};
\draw (A.35) edge[->] node[above] {$\mathsf{com}$} (B.145);
\node[anchor=south west] at (B.east |- B.180) {$b\gets\{0,1\}$};
\draw (A.0) edge[<-] node[above] {$b$} (B.180);
\draw (A.325) edge[->] node[above] {$\mathsf{dec}$} (B.215);
\draw (A.270) ++(0,-.5) node {$a\oplus b$} edge[<-] (A.270);
\draw (B.270) ++(0,-.5) node {$a\oplus b$} edge[<-] (B.270);
\end{tikzpicture}
\caption{A secure coin flipping protocol constructed from bit commitment.}
\label{fig:protocolexample}
\end{figure}

\end{document}

• Welcome! Please provide a compilable code, which starts with \documentclass and ends with \end{document}. Those trying to help you will need this information. – user121799 Nov 29 '17 at 1:58
• You're doing something non-standard. By default, LaTeX won't put a float at the top of a page with \maketitle. – cfr Nov 29 '17 at 2:18
• What placement specifier do you use in the figure environment? If you use \begin{figure}[t!]...\end{figure}, then obviously the figure will be at the top of the page. – Ilbant Nov 29 '17 at 10:09
• Give some placement specifier, i.e. \begin{figure}[htbp] – samcarter_is_at_topanswers.xyz Nov 29 '17 at 14:58

Use some placement specifiers to your figures. See for instance the detailed answer here: How to influence the position of float environments like figure and table in LaTeX? or here: What does [t] and [ht] mean?

If you just remove the figure environment you will not be able to add captions and labels. In your MWE, I added the [ht] placement, which will try to put the figure at the insertion point or on the top of the next page.

\documentclass{ltxdoc}
\usepackage[demo]{tikzpeople}
\usepackage[OT1]{fontenc}
\usepackage{hyperref}
\usepackage{microtype}
\usepackage{xspace}
\usepackage[most]{tcolorbox}
\usepackage[title]{appendix}
\usetikzlibrary{shapes.callouts}
\usepackage{lipsum}
\begin{document}
\section{Commintment}
\lipsum[2]
\begin{figure}[ht]
\begin{tikzpicture}[font=\small]
\node[alice,minimum size=1.5cm] (A) {};
\node[bob,right=3cm of A,minimum size=1.5cm,mirrored] (B) {};
\node[anchor=north east] at (A.north west) (a2) {$(\mathsf{com},\mathsf{dec}) \gets \mathsf{Com}(a)$};
\node[anchor=south] at (a2.north) (a1) {$a\gets\{0,1\}$};
\node[anchor=south west] at (B.south east){$a \gets \mathsf{Opn}(\mathsf{com},\mathsf{dec})$};
\draw (A.35) edge[->] node[above] {$\mathsf{com}$} (B.145);
\node[anchor=south west] at (B.east |- B.180) {$b\gets\{0,1\}$};
\draw (A.0) edge[<-] node[above] {$b$} (B.180);
\draw (A.325) edge[->] node[above] {$\mathsf{dec}$} (B.215);
\draw (A.270) ++(0,-.5) node {$a\oplus b$} edge[<-] (A.270);
\draw (B.270) ++(0,-.5) node {$a\oplus b$} edge[<-] (B.270);
\end{tikzpicture}
\caption{A secure coin flipping protocol constructed from bit commitment.}
\label{fig:protocolexample}
\end{figure}

\lipsum[2]
\end{document}