Images
LaTeX will make a judgement on where best to place an image although you can force its hand with several commands as we shall see.
Last updated
LaTeX will make a judgement on where best to place an image although you can force its hand with several commands as we shall see.
Last updated
To help organise your document, I recommend creating a dedicated folder for your images. Do this using the file panel on the left hand side. I have uploaded an image of my cat called bose.jpeg
You can use .jpg .jpeg or .png file formats. Gif files are not supported
To insert an image we need to load the graphicx package. Include the following code near the top of your document with the other packages
To insert an image use the following code:
The caption is optional but LaTeX will automatically number your images if you include one.
The 0.5\linewidth
tells LaTeX to make the image half the width of the page. Adjust accordingly.
The [h]
after \begin{figure}
tells LaTeX to attempt to put the images where you have placed it in your code. The following other command are available.
Images can be captioned, labelled and referenced by means of the figure
environment as shown below:
There are three important commands in the example:
\caption{a nice plot}
: As you may expect this command sets the caption for the figure. If you create a list of figures this caption will be used there. You can place it above or below the figure.
\label{fig:mesh1}
: If you need to refer the image within your document, set a label with this command. The label will number the image, and combined with the next command will allow you to reference it.
\ref{fig:mesh1}
: This code will be substituted by the number corresponding to the referenced figure.
When placing images in a LATEX document, we should always put them inside a figure
environment or similar so that LATEX will position the image in a way that fits in with the rest of your text.
Note: If you are using captions and references on your own computer, you will have to compile the document twice for the references to work. Overleaf will do this for you automatically.'