How do I insert an image on a LaTex doc?

  • LaTeX
  • Thread starter Saladsamurai
  • Start date
  • Tags
    Image Latex
In summary: Just the file name should suffice. If your image is in a different folder, then you will need to include the path as well.
  • #1
Saladsamurai
3,020
7
I googled this, but all articles assume previous knowledge of Latex.

I am brand new to Latex. I am using TeXshop on my Mac.

I have a template open and I want to insert a jpg in the document.

I clicked on the "Graphics Template" and then pasted the the name of my picture in there like the template implies. But that doesn't do it (nor do I think it should). Clearly I am missing something here.

Here is a screenshot of my attempt.

Picture2-14.png


Thanks,
Casey
 
Physics news on Phys.org
  • #2
What is your error message?

did you use \usepackage{graphics} or \usepackage{graphicx}?
http://www.artofproblemsolving.com/LaTeX/AoPS_L_PictMan.php
 
Last edited by a moderator:
  • #3
robphy said:
What is your error message?

did you use \usepackage{graphics} or \usepackage{graphicx}?
http://www.artofproblemsolving.com/LaTeX/AoPS_L_PictMan.php

I tried \usepackage{graphicx} but got nothing... noob question: I put "\usepackage{graphicx} " with all the other "usepackages" at the top of the page right?
 
Last edited by a moderator:
  • #4
Where does the mage need to be saved? Does that matter?
 
  • #5
Error message:

Picture3-10.png
 
  • #6
robphy said:
What is your error message?

did you use \usepackage{graphics} or \usepackage{graphicx}?
http://www.artofproblemsolving.com/LaTeX/AoPS_L_PictMan.php

So I went to this site and copy/pasted this into a doc:

\documentclass{article}
\usepackage[pdftex]{graphicx}
\begin{document}

This is my first image.

\includegraphics{myimage.png}

That's a cool picture up above.
\end{document}
I saved an image as "myimage.png"

I compiled and got nothing.

So I deleted everything except document class and such.

Then I just drag-and-dropped the image from my desktop to the doc and it worked!

It appears to have put the entire file path which I am not sure why the website does not?
 
Last edited by a moderator:
  • #7
This is kind of annoying. The template implies that you only need to put in the argument {moon.jpg} but when I do that, it does not work.

When I drag and drop an image it automatically prints the line with the entire address. But the address looks like this

../../Users/me/moon.jpg

It literally prints the dots "..."

I use a Mac and cannot figure out how to find the address for certain files?

On PC its just right-click-->properties and you're there.

But with Mac?
 
  • #8
Not sure if that will be helpful (because I am on a Windows machine and use TeXnicCenter and MikTeX) but the following works for me:

after the declaration of my document class I have

\usepackage{graphicx}

then where I want my figure I use

\begin{figure}[h]
\begin{center}
\scalebox{0.80}{\includegraphics{propagator.eps}}
\caption{\label{mprop} Majorana propagator.}
\end{center}
\end{figure}

where the file propagator.eps is in the same directory as my TeX file. The factor of 0.80 simply scales down the figure to 80%.
 
  • #9
Saladsamurai said:
It appears to have put the entire file path which I am not sure why the website does not?

Is your image in the same folder as your tex file? If so, then you should not need the entire path.
 

Related to How do I insert an image on a LaTex doc?

1. How do I insert an image in LaTex?

To insert an image in LaTex, you first need to include the graphicx package in your preamble by adding \usepackage{graphicx}. Then, use the \includegraphics{} command to insert the image in your document. Make sure to specify the file name and location within the curly brackets.

2. What file formats are supported for images in LaTex?

LaTex supports several file formats for images, including PNG, JPG, and PDF. However, it is recommended to use vector graphics in PDF format for better quality and scalability.

3. How do I resize an image in LaTex?

To resize an image in LaTex, you can use the \scalebox{} command. Within the curly brackets, specify the scale factor as a decimal value. For example, \scalebox{0.5}{\includegraphics{image.png}} will resize the image to 50% of its original size.

4. Can I add a caption to my image in LaTex?

Yes, you can add a caption to your image in LaTex using the \caption{} command. This will automatically number your image and add it to the list of figures. Make sure to place the \caption command after the \includegraphics command.

5. How can I position my image in a specific location on the page in LaTex?

To position an image in a specific location on the page, you can use the \begin{figure}[placement] command. Within the square brackets, specify the placement option as h (here), t (top), b (bottom), or p (page). You can also use an exclamation mark (!) before the placement option to override the default settings.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
Back
Top