# Preventing caption in new page [duplicate]

This is not about keeping the picture or table close to where they have been mentioned.

It is about keeping the caption of the picture (or table) together with the picture. Otherwise the picture and the caption will be displayed in different pages (or columns). Then, how to do it?.

\documentclass[journal,twoside]{IEEEtran}
\usepackage[spanish,english]{babel}
\usepackage{circuitikz}
\usepackage[justification=centering]{caption}

\begin{document}
\title{Minimal Working}

\maketitle

\begin{center}
\includegraphics[scale=0.2444]{MultiplierSimulationI.png}
\captionof{figure}{\small Multiplier circuit x3.}
\end{center}

\begin{center}
\begin{circuitikz}[american]
\draw (-0.5,-0.5) to[open, l=$Anode$] (0,-0.5);
\draw (-1,0) to[D, v=$V_D$] (-1,-2);
\draw (-1,0) to[open, o-o] (-1,-2);
\draw (0,-0.5) -- (0,-1.3) to[short, i=$i_D$] (0,-1.5);
\draw (-0.5,-2.3) to[open, l=$Cathode$] (0,-2.3);
\end{circuitikz}
\captionof{figure}{\small Ideal Diode.}
\end{center}

\end{document}

This is how I insert pictures (correct me if I am wrong, I insert them like this to put them wherever I want and avoid that the position itself anywhere in the page, and to give them a location). Anyway, if you add forced spaces before the picture there is a time where the picture will stay in the first column and the caption in the first line of the second column (same situation with the circuit).

• When would this ever happen? Perhaps only when you use specialized packages or other trickery. As such, can you provide us with a minimal working example (MWE) that replicates your problem? – Werner Apr 3 '14 at 5:50
• As Werner said, this is not the normal behaviour. You have certainly tweaked something. Without the code, it is impossible for use to guess and help. – user11232 Apr 3 '14 at 6:30

• Use a figure environment to keep picture and caption together, and to let the picture float.
• Without figure (if you don't want it to float), use a minipage environment to prevent a page break between picture and caption. No floating can result in bad page breaks though, such as much whitespace at the end of the previous page.

Other possibilities: samepage environment, \nopagebreak command, but I recommend the options above.

• Would you please give a minimal example of the \nopagebreak command, or explain how it works. – Hans Apr 5 '14 at 6:15
• @Hans: How about providing us with a minimal working example (MWE) that replicates your problem? – Werner Apr 5 '14 at 6:17
• @Werner I did, check out the edited question. – Hans Apr 5 '14 at 6:30
• @Hans: Now it makes sense why you have a caption broken from your image. Thank you for this information. It's because the "block" that you use to contain your image/caption pair is breakable (the center environment). And easy option here is to use the float package, use a \begin{figure}[H] \centering ... \caption{..} \end{figure} that replaces your enter environment. – Werner Apr 5 '14 at 6:41
• @Werner Will it work with the circuit as well? – Hans Apr 5 '14 at 6:59

Solved by using the Float Package:

\documentclass[journal,twoside]{IEEEtran}
\usepackage[spanish,english]{babel}
\usepackage{circuitikz}
\usepackage[justification=centering]{caption}
\usepackage{float}

\begin{document}
\title{Minimal Working}

\maketitle

\begin{figure}[H]
\centering
\includegraphics[scale=0.2444]{MultiplierSimulationI.png}
\caption{\small Multiplier circuit x3.}
\end{figure}

\begin{figure}[H]
\centering
\begin{circuitikz}[american]
\draw (-0.5,-0.5) to[open, l=$Anode$] (0,-0.5);
\draw (-1,0) to[D, v=$V_D$] (-1,-2);
\draw (-1,0) to[open, o-o] (-1,-2);
\draw (0,-0.5) -- (0,-1.3) to[short, i=$i_D$] (0,-1.5);
\draw (-0.5,-2.3) to[open, l=$Cathode$] (0,-2.3);
\end{circuitikz}
\caption{\small Ideal Diode.}
\end{figure}

\end{document}

When inserting forced spaces the caption won't separate of the picture.