Gabriel Kelly
Gabriel Kelly

Reputation: 85

Increase spacing between itemize 'items' to avoid splitting pages

I'm currently working on some homework for my Theory of Computation course; right now I am creating state diagrams in LaTeX with the TikZ library (in Overleaf). We have a template file where problems are listed in an itemize block and I am inserting tikzpicture blocks to create the state diagrams in each of the item blocks.

\begin{itemize}
\item[a.] $\{w~|~w$ begins with a $\input{1}$ and ends with a $\input{0} \}$
\begin{figure}[ht]
    \begin{tikzpicture}
        \node[state, initial] (q0) {$q_0$};
        \node[state, right of=q0] (q1) {$q_1$};
        \node[state, below of=q1] (qR) {$q_R$};
        \node[state, accepting, right of=q1] (q2) {$q_2$};
        
        \draw (q0) edge[bend right, below] node{0} (qR)
              (qR) edge[loop below] node{0,1} (qR)
              (q0) edge[above] node{1} (q1)
              (q1) edge[loop above] node{1} (q1)
              (q1) edge[bend left, above] node{0} (q2)
              (q2) edge[bend left, below] node{1} (q1)
              (q2) edge[loop right] node{0} (q2);
    \end{tikzpicture}
\end{figure}
... Cut some code out here to save space
\item[d.] The empty set
\begin{figure}[ht]
    \begin{tikzpicture}
        \node[state, initial] (q) {$q$};
        \draw (q) edge[loop right, above] node{0,1} (q);
    \end{tikzpicture}
\end{figure}
\end{itemize}

The thing that is bothering me, and I know it's not a huge deal and I'm just being anal, is that it comes out looking like this when compiled:The pesky page split

Is there a way I could change this code so that both the problem statement and my solution diagram will fit on the same page of the pdf? It really bothers me to look at it and I run into stuff like this a lot working with LaTeX. Thanks!

Upvotes: 0

Views: 401

Answers (1)

Federico Pellegatta
Federico Pellegatta

Reputation: 174

A \vbox might do what you want:

\item \vbox{
    % the contents you want to enclose on the same page
}

Upvotes: 2

Related Questions