## LaTeX forum ⇒ Graphics, Figures & Tables ⇒ Problem with the package graphicx

Information and discussion about graphics, figures & tables in LaTeX documents.
NELLLY
Posts: 113
Joined: Thu Nov 26, 2009 2:21 am

### Problem with the package graphicx

Hi
I have to follow the style of a given scientific journal's paper.
Graphics should be inserted using this command
\begin{figure}[htp]\usepackage{graphics}\begin{center}\includegraphics[angle=0,width=7cm]{figurename}\caption{....} \label{fig1}\end{center}\end{figure}

when I typset a text sample I didn't get the graphic. In my past works, when I insert a graphic I indicate its path in the line
\begin{figure}[H]\center\includegraphics [width=0.95\textwidth, angle=-90]{C:/MESIMAGES/figurename}  \caption{...}\label{f2}  \end{figure}

While in the first code, there is no path of the figure's placement. Where should I save my figure? Note: I use Winedit

Tags:

Stefan Kottwitz
Posts: 9549
Joined: Mon Mar 10, 2008 9:44 pm
The editor doesn't matter.

In the first code snippet, \usepackage{graphics} is wrong. It should be in the preamble, and it should be graphicx instead. Furthermore, the center environment causes additional vertical spacing, \centering is better. \center is bad, it's a bad abbreviation of the center environment.

[H] in the second code snippet is bad for automatic page breaking.

Regarding the path to the file, you can specify one, or omit it if the image is in the same directory as the main document. (Or graphicspath is used or an environment variable)

Stefan

NELLLY
Posts: 113
Joined: Thu Nov 26, 2009 2:21 am
Hi
I made a mistake when I posted the message. Instead I used \usepackage{graphicx} before \begin{document}.
I saved the image in the same folder containing the latex file. When I compile the file the following error appears
LaTeX Error: File'figurename' not found

I tried to use the path that I used for my previous figures and also I got the same problems. Notice that I saved some of my figures in the pdf format and some other with bmp extension. Previously, I didn't have such errors using the same instructions. Also when I typset my old files tHE same errors appears for all my figures.I didn't know what happened.

Stefan Kottwitz
Posts: 9549
Joined: Mon Mar 10, 2008 9:44 pm
NELLLY wrote:Notice that I saved some of my figures in the pdf format and some other with bmp extension.

The bmp format is not supported by pdfLaTeX. I suggest to convert it to PNG format.

Stefan

NELLLY
Posts: 113
Joined: Thu Nov 26, 2009 2:21 am
Hi Stefan
I saved the graphic with pdf extension and it works that time. However I get the following error
\begin{figure}[htp]\includegraphics [width=0.95\textwidth, angle=-90]{figurename}  \caption{...}\label{f1}\end{figure}

Cannot determine the size of graphic in figurename

localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm
NELLLY wrote:[…] I saved the graphic with pdf extension and it works that time. […]

What does that exactly mean? did you really convert the image or did you only change the suffix (.bmp→.pdf)? Which program did you use? The error indicates that the image file has not really been converted.

Thorsten
LaTeX Community Moderator

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1