Graphics, Figures & TablesLatex images are not showing!

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
yurica
Posts: 7
Joined: Thu Mar 23, 2017 9:54 pm

Latex images are not showing!

Post by yurica »

Hi Latex Community!

I am facing some issues trying to insert images on my code. The problem is: none of them are being displayed. However, I am not getting any errors and the file compiles normally. Here is the library packages I am using followed by an image insertion code example (I am using this same code for all my images):

Note 1: Ignore the portuguese comments in my code, I am from Brazil :)
Note 2: The packages with "%" are packages that I've already tried to use to insert the images, and none of them worked.

Code: Select all

\documentclass[11pt]{book}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Inclusão de pacotes e bibliotecas
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[portuguese]{babel} %Português Brasil
\usepackage[latin1]{inputenc}  %uso de acento direto do teclado
\usepackage[dvips]{graphicx,color} %incluir figuras
\usepackage{amsthm,amsfonts} %fontes matemáticas
\usepackage{adjustbox} %Alinhar figuras
%\usepackage[pdftex]{graphicx} %incluir figuras PDF
%\usepackage{epsfig} %inserir figuras eps
%\graphicspath{{Figuras/}} %Buscar imagens nessa pasta

\definecolor{cinza}{RGB}{238,238,238} %define um padrão de cor
\definecolor{cinza1}{RGB}{150,150,150} %define um padrão de cor
\usepackage[Bjornstrup]{fncychap} %estilo para titulo do capitulo
\usepackage{verbatim} %comentários de várias linhas

%\usepackage[tc]{titlepic} %estilo para figura na capa
%\titlepic{\includegraphics[width=\textwidth]{fig/capa.eps}}

\usepackage{fancyhdr} %rodape e cabeçalho
\pagestyle{fancy} %estilo de cabecalho
\fancyhf{} % apagar as configuracoes atuais
\fancyhead[LE,RO]{\footnotesize\bfseries\thepage}
\fancyhead[LO]{\scriptsize\bfseries\rightmark}
\fancyhead[RE]{\scriptsize\bfseries\leftmark}
\renewcommand{\headrulewidth}{0.2pt}
\renewcommand{\footrulewidth}{0pt}
\addtolength{\headheight}{0.3pt} % fazer espaço para o risco
\fancypagestyle{plain}{%
  \fancyhead{} % Tirar cabeçalhos de página vazias
  \renewcommand{\headrulewidth}{0pt} % e o risco
}


\usepackage{listings} %inserção de códigos-fontes de programação
% opções do pacote listings
\lstset{numbers=left,
  language=C,
  basicstyle=\ttfamily\footnotesize,
  keywordstyle=\color{red}\bfseries,
  stringstyle=\color{blue},
  commentstyle=\color{cinza1},
  extendedchars=true,
  showspaces=false,
  showstringspaces=false,
  numberstyle=\tiny,
  breaklines=true,
  backgroundcolor=\color{cinza},
  breakautoindent=true,
  captionpos=b,
  xleftmargin=0pt,
}

Code: Select all

\begin{figure}[!htb]
	\centering %centralizar a figura
	\includegraphics[height=5cm]{Figuras/Imagem001.eps}
\end{figure}
Thanks in advance! Any help would be appreciated. I am completely new in the latex language and syntax.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Latex images are not showing!

Post by Stefan Kottwitz »

Hi yurica,

welcome to the forum!

Your code has to run LaTeX in DVI mode. Perhaps the editor or something causes it to run in pdfLaTeX mode. Could you please post your .log file, as attachment?
EPS files are only supported by LaTeX in DVI mode that produces DVI, and PDF is created for example using dvi2ps and ps2pdf. pdfLaTeX goes the direct way but doesn't support EPS, but with epstopdf in addition.

Stefan
LaTeX.org admin
yurica
Posts: 7
Joined: Thu Mar 23, 2017 9:54 pm

Latex images are not showing!

Post by yurica »

Helo Stefan,

Thanks for the quick reply, and sorry for my late answer. I figured it out that my LaTeX was running in pdfLaTeX mode. So I converted my first image (Imagem001.pdf) to a pdf file and now I get an error while trying to compile it:

"Cannot determine size of graphic in Figuras/Imagem001.pdf (no BoundingBox). ...aphics[height=5cm]{Figuras/Imagem001.pdf}"

I am using this code to insert it:

Code: Select all

\begin{figure}[!htb]
	\centering %centralizar a figura
	\includegraphics[height=5cm]{Figuras/Imagem001.eps}
\end{figure}
Also, how do I "copy" my log to post it here as an attachment? Sorry, I am really a beginner using this software. Thanks again for the answer!
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Latex images are not showing!

Post by Stefan Kottwitz »

Hi yurica!

In your code, there is ".eps", not ".pdf".

Besides that, the "Cannot determine size of graphic" still looks like LaTeX is running in DVI mode, trying to get bounding box information from an eps but that doesn't work worth pdf. Ensure that it's really pdf.

You can attach a .log file here, this way: below the edit field for writing a post, when writing, there's a tab options and a tab "Attachments", click this. Then click the "Add files" button.

Stefan
LaTeX.org admin
yurica
Posts: 7
Joined: Thu Mar 23, 2017 9:54 pm

Latex images are not showing!

Post by yurica »

Hi Stefan!

Thank you! I got every image showing up perfectly now in the .eps format and DVI mode! But now that they showed up, I got another problem. They are not in the position that I want them to be. How do I insert them exactly at the place where the code is? Also, using .eps format, how do I move the image to the right/left and also change its size? Thank you again for your patience and time.

Yuri.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Latex images are not showing!

Post by Stefan Kottwitz »

LaTeX figures are designed to move to an optimal place for best page breaks, filling the page. If you place them exactly in the code, you can get page break issues since the code place may not be the best fit for page breaks - often one can then get white space at page bottoms. The figure philosophy, also in good books, is placing figure near, such as at the top of the next page, floating text before, filling the page. And that's why book's figures have numbers for referencing: they appear a bit later in the text, for page design.

So, I would use \begin{figure}[!htbp] to allow floating but to the next possible place here, top, bottom or page.

If you insist on here, definitely, even if there's no space, you can use \begin{figure}[H] but before load the float package: \usepackage{float}.

Stefan
LaTeX.org admin
yurica
Posts: 7
Joined: Thu Mar 23, 2017 9:54 pm

Latex images are not showing!

Post by yurica »

Hi Stefan!

Thank you for the help. I have one last (maybe) question. When compiling and previewing my DVI file using the standard "Yet Another Previewer (YAP)", I can see that everything is okay. However, if I update anything in my code (text, images...) and compile it again, I keep seeing the "old" preview file, without the new changes. Do you know how to fix this? Thank you in advance.

Ps.: I am writing a SciLab programming book for one of my professors in the university. I work with him only on Thursdays and Fridays, and that's why I take some time to answer/ask.

Yuri
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Latex images are not showing!

Post by Stefan Kottwitz »

Hi Yuri,

is the file actually changed? So, is it updated if you close the previewer and open it again? I just think about the possibility that an error in the code may prevent creating a new output file.

As far as I know, YAP is for previewing DVI, not PDF. That may also be a reason. SumatraPDF is a very good and fast PDF reader on windows, syncing with TeX.

Stefan
LaTeX.org admin
yurica
Posts: 7
Joined: Thu Mar 23, 2017 9:54 pm

Latex images are not showing!

Post by yurica »

Hi Stefan,

I am constantly changing the file and even if I close YAP and open it again, it shows me an old version of it. Many people have the same problem with YAP, and I never find a solution. I was wondering if you knew a fix for this issue. I am working with DVI format for now on, as well as EPS images, not a PDF file. Anyway, thanks for the tips and I'll try to find a new DVI previewer. See ya!

Yuri
Post Reply