97

I want to insert a .jpg image(that is in my current folder, where the .tex file is) after a paragraph. How can I do it in Latex? What should I include / what commands should I use?

qwerty
  • 1,967
  • 6
  • 22
  • 22

2 Answers2

186

You need to use a graphics library. Put this in your preamble:

\usepackage{graphicx}

You can then add images like this:

\begin{figure}[ht!]
\centering
\includegraphics[width=90mm]{fixed_dome1.jpg}
\caption{A simple caption \label{overflow}}
\end{figure}

This is the basic template I use in my documents. The position and size should be tweaked for your needs. Refer to the guide below for more information on what parameters to use in \figure and \includegraphics. You can then refer to the image in your text using the label you gave in the figure:

And here we see figure \ref{overflow}.

Read this guide here for a more detailed instruction: http://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions

Jonno_FTW
  • 8,601
  • 7
  • 58
  • 90
  • The image it's displayed OK, the caption also, but at the compile time i got the error '\caption outside float' – qwerty Jun 28 '10 at 16:36
  • You don't really need to worry about these errors that much. You can also place the label inside the caption, like so: `\caption{caption \label{overflow}` – Jonno_FTW Jun 28 '10 at 16:40
  • Could you be using `\caption` after `\end{figure}`, i.e. outside the float? – Aniko Jun 28 '10 at 16:47
  • No, i'm using: \begin{figure}[ht!] \centering \includegraphics[width=100mm]{fig1.jpg} \caption{My caption....} \label{Fig.1} \end{figure} – qwerty Jun 28 '10 at 16:59
  • If you want the image to fit *half* the width of your *text block*, just write `\includegraphics[width=0.5\textwidth]{fixed_dome1.jpg}`. Instead of `\textwidth` you can use `\paperwidth` (width of the whole page) `\linewidth` (within the current line). – Agostino Nov 24 '14 at 12:01
9

if you add a jpg,png,pdf picture, you should use pdflatex to compile it.

威武君
  • 99
  • 1
  • 1