Graphics, Figures & TablesProblem with the package graphicx

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

Problem with the package graphicx

Post by NELLLY »

Hi
I have to follow the style of a given scientific journal's paper.
Graphics should be inserted using this command

Code: Select all

\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

Code: Select all

\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

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Problem with the package graphicx

Post by Stefan Kottwitz »

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
LaTeX.org admin
NELLLY
Posts: 113
Joined: Thu Nov 26, 2009 2:21 am

Problem with the package graphicx

Post by NELLLY »

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

Code: Select all

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.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Problem with the package graphicx

Post by Stefan Kottwitz »

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
LaTeX.org admin
NELLLY
Posts: 113
Joined: Thu Nov 26, 2009 2:21 am

Problem with the package graphicx

Post by NELLLY »

Hi Stefan
I saved the graphic with pdf extension and it works that time. However I get the following error

Code: Select all

\begin{figure}[htp]
\includegraphics [width=0.95\textwidth, angle=-90]
{figurename}
 \caption{...}\label{f1}
\end{figure}

Code: Select all

Cannot determine the size of graphic in figurename
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Problem with the package graphicx

Post by localghost »

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
Post Reply