LaTeX forum ⇒ Graphics, Figures & TablesFigure doing whatever it wants. Topic is solved

Information and discussion about graphics, figures & tables in LaTeX documents.
SebRM
Posts: 1
Joined: Sat Feb 02, 2019 10:14 pm

Figure doing whatever it wants.

Postby SebRM » Sat Feb 02, 2019 10:28 pm

Hey guys! So i am working on a pdf with TexShop.
I am trying to include the following lines: [I will mark them with **]

\section{}
\bf{title}
Plain Text
Fig.~\ref{figure}
Plain Text
** \begin{figure}[h]
\includegraphics[width=\textwidth]{run_integrate2-FvsN}
\caption{}
\label{run_integrate2-FvsN}
** \end{figure}
\\

\bf{title2}
Plain Text

ISSUE: When I run these things, the figure appears below the {title2} section, It doesn't care if I write [h, or p, or t]
it still appears at the end of that section, I do not understand why.
Your help would be really apreciated!

User avatar
Stefan Kottwitz
Site Admin
Posts: 9366
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Sat Feb 02, 2019 11:40 pm

Welcome to the forum!

The code (maybe based on some older Internet sample code) is not optimal. I recommend to never use \bf and to use \\ only in tables, never in text.

It could be like this:

  1. \section{title}
  2. Plain Text
  3. For example, see fig.~\ref{run_integrate2-FvsN}% same as in \label
  4. Plain Text
  5. \begin{figure}[htbp!]
  6. \centering%if you like
  7. \includegraphics[width=\textwidth]{run_integrate2-FvsN}
  8. \caption{figure caption text}
  9. \label{run_integrate2-FvsN}
  10. \end{figure}
  11. \section{title2}
  12. Plain Text


Figures float for optimal page breaks. They stay in the same chapter though. If you want to let them stay even in the same section, use

\usepackage[section]{placeins}

in the preamble.

Stefan
Site admin


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 5 guests