Graphics, Figures & TablesYipes! pdflatex command placing graphs in wrong place

Information and discussion about graphics, figures & tables in LaTeX documents.
Michael_590
Posts: 51
Joined: Wed Aug 06, 2014 6:59 pm

Yipes! pdflatex command placing graphs in wrong place

Post by Michael_590 »

Doxygen can be setup to produce HTML reports and LaTeX reports because Doxygen commands are embedded in computer source code. It creates documentation of computer progams. The two types of reports produced should be identical except being in different formats (HTML versus LaTeX).

I've been able to produce the HTML reports with graphs appearing in the right place. By right place, I mean graphs appear directly under the Doxygen text referencing them.

But, with the latex file version of the report, I run the "pdflatex" against them to produce a PDF report. The problem is the graphs in this PDF report usually appear much later in the report than the text referencing them. This is very sloppy!

I can't change the text referencing the graphs because Doxygen produces the text.

Question: Do you have any suggestions on how I can fix this problem. (I find that questions such as this are too difficult for the general Doxygen community.)

Thank you,

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Yipes! pdflatex command placing graphs in wrong place

Post by Johannes_B »

This behaviour isn't sloppy at all, this is bu design. It is called floating behaviour and makes texts more easy to read and more efficient.

You can prevent that by not using a figure environment and instead using a minipage to put the figure and the caption (using \captioof{figure}{Your caption}).

As i recall from your previous thread DOXygen uses package float along with the H option to prevent floating.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Michael_590
Posts: 51
Joined: Wed Aug 06, 2014 6:59 pm

Yipes! pdflatex command placing graphs in wrong place

Post by Michael_590 »

Johannes_B wrote:You can prevent that by not using a figure environment and instead using a minipage to put the figure and the caption (using \captioof{figure}{Your caption}).
How do I center "Your caption."

Thank you,
Michael_590
Posts: 51
Joined: Wed Aug 06, 2014 6:59 pm

Yipes! pdflatex command placing graphs in wrong place

Post by Michael_590 »

Johannes_B wrote:instead using a minipage to put the figure and the caption (using \captioof{figure}{Your caption}).
So, how do I incorporate your code: \captioof{figure}{Your caption}

into the following:

Code: Select all

\begin{minipage}[position]{width}
  text
\end{minipage}
using a pdf figure called xyz_453 and caption saying "this is my caption."

Thanks,
Last edited by Stefan Kottwitz on Wed Aug 13, 2014 10:43 am, edited 1 time in total.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Yipes! pdflatex command placing graphs in wrong place

Post by Johannes_B »

I made a typing mistake above, please note that the command is named captionof.

Code: Select all

\documentclass{article}
\usepackage{caption}
\begin{document}
\listoffigures

\bigbreak

\begin{minipage}{\linewidth}
	\begin{center}
		\rule{5cm}{4cm}
		\captionof{figure}{this is my caption}
	\end{center}
\end{minipage}
\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Michael_590
Posts: 51
Joined: Wed Aug 06, 2014 6:59 pm

Yipes! pdflatex command placing graphs in wrong place

Post by Michael_590 »

Johannes_B wrote:I made a typing mistake above, please note that the command is named captionof.

Code: Select all

\documentclass{article}
\usepackage{caption}
\begin{document}
\listoffigures

\bigbreak

\begin{minipage}{\linewidth}
	\begin{center}
		\rule{5cm}{4cm}
		\captionof{figure}{this is my caption}
	\end{center}
\end{minipage}
\end{document}
When I put that into the file (a few times), I get:

!LaTeX Error: \begin{minipage} on input line ... ended by \end{document}.

!Emergency stop.

a Fatal error occured no output PDF File produced.
Last edited by Michael_590 on Wed Aug 13, 2014 2:50 pm, edited 1 time in total.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Yipes! pdflatex command placing graphs in wrong place

Post by Johannes_B »

Might be; as you can see, my code is correct. So i guess somewhere in the conversion process something went crazy. Best way to find the cause is to prepare a minimal working example and share it with us.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Yipes! pdflatex command placing graphs in wrong place

Post by Stefan Kottwitz »

Michael_590 wrote: When I put that into the file (a few times), I get:

!LaTeX Error: \begin{minipage} on intput line ... ended by \end{document}.
This looks like you forgot to insert \end{minipage}at one place.

Stefan
LaTeX.org admin
Michael_590
Posts: 51
Joined: Wed Aug 06, 2014 6:59 pm

Yipes! pdflatex command placing graphs in wrong place

Post by Michael_590 »

All the "\begin{minipage}" had a corresponding "\end{minipage}".

With the Doxygen output, I went back and replaced only one figure from:

Code: Select all

My caption for the figure is this.
\nopagebreak
\begin{figure}[H]
\leavevmode
\includegraphics[width=200pt]{classone_0_0two_three_1_1graph}
\end{center}
\end{figure}
to the following:

Code: Select all

\begin{minipage}{\linewidth}
   \begin{center}
       \rule{5cm}{4cm}
          \captionof{classone_0_0two_three_1_1graph}
          {My caption for the figure is this.}
    \end{center}
\end{minipage}
The resulting PDF file had a completely black figure with a right adjusted caption something like "classone_0_0two_three_1_1graphMycaption", but with the underscores gone and the numbers converted to subscripts. The caption fell off the right side of the page. The figure should have had boxes and arrows.

Thank you,
Michael_590
Posts: 51
Joined: Wed Aug 06, 2014 6:59 pm

Post by Michael_590 »

_____________________
Last edited by Michael_590 on Wed Aug 13, 2014 6:51 pm, edited 1 time in total.
Post Reply