3

I know that there are threads related to this, but it is really painful...

I would like to insert images saved from a tool into latex.

The images could be saved in any format of the followings: PNG, JPEG, PDF, GIF, BMP. The choice is totally up to me.

The problem is I tried

\usepackage{graphicx}
...
\begin{figure}
\includegraphics{image.suffix}
\end{figure}

The compilation gives me an error ! LaTeX Error: Cannot determine size of graphic in image.suffix (no Bound ingBox).

Someone says it is due to dvips. I do have dvips in my makefile, but I don't know how to remove it; Someone says it is pdflatex which should be used, but I don't know how to modify makefile to do so.

EPS=    $(FGS:%=%.eps)
%.eps: %.tex $(MACROS)
    latex $< &&         dvips -t letter -z -P pdf -o ${<:%.tex=%.ps} ${<:%.tex=%.dvi} &&        gs -q -dNOPAUSE -dBATCH -sDEVICE=bbox ${<:%.tex=%.ps} 2> ${<:%.tex=%.bb} &&         cat ${<:%.tex=%.ps} | perl -ne       'if (/BoundingBox/) { open BB, "${<:%.tex=%.bb}" or die; print <BB>; close BB; } else { print; }' > $@

all: paper.pdf eps
regen: $(EPS)
    make ALLDEPS=1

eps: $(EPS)
SRC=    fonts.tex       paper.bib       macros-paper.tex        packages.tex
paper.pdf: paper.tex $(SRC) $(EPS)
    latex paper.tex &&      bibtex --min-crossrefs=500 paper &&         latex paper.tex &&      latex paper.tex &&      dvips paper.dvi -o paper.ps &&      ps2pdf paper.ps paper.pdf

Could anyone help?

Update1:

Following the comment of @nickie , I modified makefile including all about epstopdf, the compilation still gave me an error:

! Package pdftex.def Error: File 'fg1-eps-converted-to.pdf' not found. for the tex \includegraphics[scale=1]{fg1}, where fg1.tex is supposed to generate a figure by pspicture.

Does anyone have any idea?

SoftTimur
  • 19,767

1 Answers1

2

I suppose that if you just substitute (with proper indentation: tabs) this part:

latex paper.tex && \
bibtex --min-crossrefs=500 paper && \
latex paper.tex && \
latex paper.tex && \
dvips paper.dvi -o paper.ps && \
ps2pdf paper.ps paper.pdf

with:

pdflatex paper.tex && \
bibtex --min-crossrefs=500 paper && \
pdflatex paper.tex && \
pdflatex paper.tex

it will work. If you're using EPS figures and pdflatex complains, you can convert them to PDF:

%.pdf: %.eps
        epstopdf $<

fg1.pdf: fg1.eps
nickie
  • 4,378
  • 2
    And probably add \usepackage{epstopdf} to the document. – egreg Nov 09 '13 at 16:44
  • Thank you, please see my Update1... – SoftTimur Nov 09 '13 at 22:37
  • 1
    If you use the epstopdf package, make sure to add the --shell-escape option to pdflatex. My answer does not require the epstopdf package; you'll just have to specify for which figures to call the epstopdf script in your Makefile. – nickie Nov 10 '13 at 00:21
  • @nickie --shell-escape is not needed for epstopdf with recent TeX Live distributions (≥2012) and, I believe, also with MiKTeX 2.9. – egreg Nov 10 '13 at 00:24
  • @egreg: I've forgotten that recent texlive distributions exist! My ubuntu 12.04 still has texlive 2009... Anyway, I think the error message he's getting means that epstopdf is not executed so this could be one possible reason. – nickie Nov 10 '13 at 00:31