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

Information and discussion about graphics, figures & tables in LaTeX documents.
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 »

\captionof{figure}{Your caption}

The rule is a replacement for the actual figure. The word figure in the captionof command gives the type of the figure.
Please read up on some introductory material.

Do you even test the complete and fully working minimal examples i post?
Please click on »Open in writelatex« this time.

Code: Select all

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

    \bigbreak

    \begin{minipage}{\linewidth}
            \begin{center}
                    \includegraphics[width=\textwidth]{example-image}
                    \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.

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

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Yipes! pdflatex command placing graphs in wrong place

Post by cgnieder »

Michael_590 wrote:it looks like the pdflatex command is not loading the caption package!
A command never loads a package. If a user doesn't load the package that is needed for a command and still uses the command he'll get the error message ! Undefined control sequence.

Regards
site moderator & package author
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:\captionof{figure}{Your caption}

Code: Select all

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

    \bigbreak

    \begin{minipage}{\linewidth}
            \begin{center}
                    \includegraphics[width=\textwidth]{example-image}
                    \captionof{figure}{this is my caption}
            \end{center}
    \end{minipage}
    \end{document}
This works for me. All I can say is thank you to Johannes_B. I've made about 10 changes and it appears to be doing what I want!

So, this solution is after running Doxygen to manually go into less than 20 LaTeX files and make this change less than a total of a 100 times.

Question: In a practical way, how can I improve apon making this change.

After all, this fix involves tedious work! And, I will make mistakes and have to undo things etc. I also have a brand new mouse and the cursor still jumps all over the place.

Thank you,
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 »

As already said, preventing figures from floating is considered bad style. The captionof-approach was merely an alternative to using package float along with the placement specifier H.
It is less work for you to type (would be if hand generated) and give the classic look and feel.
You could also change the Doxygen conversion routine to output the minipage/captionof-approach, but since i never used doxygen, i don't know how to do that.


Btw: you are a mouse person, pity, there are editors like emacs or vim (i prefer vim) where touching the mouse is completely nonsense. By moving your arm you will lose time better spent in writing or thinking about what to write.
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

Re: Yipes! pdflatex command placing graphs in wrong place

Post by Stefan Kottwitz »

I can move my arm and think, at the same time. ;-)

I'm using a mouse like Michael, and I assume the computer mouse has increased productivity in general. While touch screens possibly increased comfort and decreased productivity.

A jumping mouse cursor - if it's not a too sensitive setting, you could change the surface where you move the mouse on, optical mouse may work bad on a homogenous surface. Like a mouse pad, even if it's optical and without ball.

Stefan
LaTeX.org admin
Post Reply