Troubleshooting Image Display in LaTeX

In summary, if the image is in the same folder as the LaTeX file, the \includegraphics command should only include the name of the file and not the folder name. Additionally, if you want a floating figure, you can use the "figure" environment instead of the "graphics" environment.
  • #1
Rectifier
Gold Member
313
4
Hey!

I can't get my images to appear in ##LaTeX## :(
Could you please help me out?

I have read that you can use \includegraphics but when I add it in my code nothing happens.

Code:
\documentclass[a4paper,11pt]{article}
\usepackage[swedish]{babel}
\usepackage{graphicx}

\begin{document}

\begin{graphics}
\includegraphics[width=0.7\textwidth]{folder/test.jpg}
\end{graphics}

\end{document}

Where image is in the same folder as the LaTeX file.

What am I doing wrong?
 
Last edited:
Physics news on Phys.org
  • #2
There are many threads on the problem, they are listed below as related discussions - see if comments in these threads don't help.

AFAIR in most cases it is a problem of correctly assigning directories, but I know next to nothing about LaTeX.
 
  • Like
Likes 1 person
  • #3
There is no such thing as a "graphics" environment. If you want a floating figure, try instead
Code:
\begin{figure}
...
\end{figure}
Otherwise, you can simply put the \includegraphics by itself.

If you figure resides in the same directory as the LaTeX file, don't explicitly include a folder name, just the name of the file.
 
Last edited:
  • Like
Likes 1 person
  • #4
DrClaude said:
If you figure resides in the same directory as the LaTeX file, do explicitly include a folder name, just the name of the file.

I think Dr Claude means, "If your figure resides in the same directory as the LaTeX file, don't explicitly include a folder name, just the name of the file."

In other words, if the file test.jpg is in the same folder as the latex file, the includegraphics line should read:

Code:
\includegraphics[width=0.7\textwidth]{test.jpg}
 
  • Like
Likes 1 person
  • #5
Will try that out when I am home thank you all.
 
  • #6
phyzguy said:
I think Dr Claude means, "If your figure resides in the same directory as the LaTeX file, don't explicitly include a folder name, just the name of the file."
Thanks for spotting that!
 

FAQ: Troubleshooting Image Display in LaTeX

How can I include images in my LaTeX document?

To include images in a LaTeX document, you need to use the "graphicx" package. This can be done by adding the following line to your preamble:
\usepackage{graphicx}. Then, you can use the command \includegraphics{image_file_name} to insert an image in your document, where "image_file_name" is the name of your image file.

What file formats are supported for images in LaTeX?

LaTeX supports various file formats for images, such as PNG, JPEG, PDF, and EPS. However, it is recommended to use vector formats like PDF and EPS for better quality and scalability.

How can I resize an image in LaTeX?

You can use the optional arguments of the \includegraphics command to resize an image in LaTeX. For example, \includegraphics[width=0.5\textwidth]{image_file_name} will scale the image to half the width of the text area.

Can I add a caption and label to my images in LaTeX?

Yes, you can use the \caption and \label commands to add a caption and label to your images. This is useful when you want to refer to the image in your document using the \ref command.

How can I align images in LaTeX?

You can use the optional argument "align" in the \includegraphics command to specify the alignment of the image. The options for alignment include "center", "left", and "right". Alternatively, you can use the "float" environment, such as \begin{figure}[h], to control the placement and alignment of your image in the document.

Similar threads

Replies
4
Views
2K
Replies
3
Views
452
Replies
1
Views
5K
Replies
2
Views
753
Replies
2
Views
3K
Replies
2
Views
5K
Back
Top