0

I have been using TeXworks and it worked fine. Recently, I am testing with Command Prompt to work with this line:

xelatex foo.tex

The content of the file is below:

\documentclass[a4paper,14pt,twoside]{book}
\usepackage{graphicx}
\graphicspath{ {./img/} }

\begin{document}
\includegraphics{38}
\end{document}

It is a tex file which worked perfectly on TeXwork (compiled with XeLaTeX), but not through Command Prompt. The error message was this:

! Unable to load picture or PDF file './img/38.png'.

Funny thing is, my corresponding line was

\includegraphics{38}

so it appears that it actually found my file '38.png'.

I am working on a Win10 workstation.

Working log-file from TeXwork:

This is XeTeX, Version 3.14159265-2.6-0.99999 (TeX Live 2018/W32TeX) (preloaded format=xelatex)
 restricted \write18 enabled.
entering extended mode
(./foo.tex
LaTeX2e <2018-12-01>
(d:/texlive/2018/texmf-dist/tex/latex/base/book.cls
Document Class: book 2018/09/03 v1.4i Standard LaTeX document class
(d:/texlive/2018/texmf-dist/tex/latex/base/bk10.clo))
(d:/texlive/2018/texmf-dist/tex/latex/graphics/graphicx.sty
(d:/texlive/2018/texmf-dist/tex/latex/graphics/keyval.sty)
(d:/texlive/2018/texmf-dist/tex/latex/graphics/graphics.sty
(d:/texlive/2018/texmf-dist/tex/latex/graphics/trig.sty)
(d:/texlive/2018/texmf-dist/tex/latex/graphics-cfg/graphics.cfg)
(d:/texlive/2018/texmf-dist/tex/latex/graphics-def/xetex.def)))

LaTeX Warning: Unused global option(s):
    [14pt].

(./foo.aux) [1] (./foo.aux) )
Output written on foo.pdf (1 page).
SyncTeX written on foo.synctex.gz.

Transcript written on foo.log.

The not-working log:

This is XeTeX, Version 3.14159265-2.6-0.99999 (TeX Live 2018/W32TeX) (preloaded format=xelatex)
 restricted \write18 enabled.
entering extended mode
(D:\Documents\LaTex/foo.tex
LaTeX2e <2018-12-01>
(d:/texlive/2018/texmf-dist/tex/latex/base/book.cls
Document Class: book 2018/09/03 v1.4i Standard LaTeX document class
(d:/texlive/2018/texmf-dist/tex/latex/base/bk10.clo))
(d:/texlive/2018/texmf-dist/tex/latex/graphics/graphicx.sty
(d:/texlive/2018/texmf-dist/tex/latex/graphics/keyval.sty)
(d:/texlive/2018/texmf-dist/tex/latex/graphics/graphics.sty
(d:/texlive/2018/texmf-dist/tex/latex/graphics/trig.sty)
(d:/texlive/2018/texmf-dist/tex/latex/graphics-cfg/graphics.cfg)
(d:/texlive/2018/texmf-dist/tex/latex/graphics-def/xetex.def)))

LaTeX Warning: Unused global option(s):
    [14pt].

(D:\Documents\LaTex/foo.aux)
! Unable to load picture or PDF file './img/38.png'.
<to be read again>
                   }
l.6 \includegraphics{38}

How should I solve it? Thanks!

  • 2
    As always on this site, please provide a full minimal example, we'd like to see what you have in that test file foo.tex. Unless you have anything else configured \includegraphics{38} will never find ./img/38.png, thus the request for the contents of foo.tex – daleif May 14 '19 at 09:33
  • Thank you for your advice. I have included a simplified version of the document. This version is also tested on TeXworks and command prompt, and the same problem still stands(aka It works on TeXworks while command prompt cannot load the picture). – KAItO CHAN May 14 '19 at 09:43
  • Does \graphicspath{{./img/}} make a difference? Also in texworks, are you 100% sure you are using xelatex there and not pdflatex? – daleif May 14 '19 at 10:02
  • I just tested with TeXLive 2019, everything works as it should. Exactly which latex installation do you have and which version. – daleif May 14 '19 at 10:05
  • Show your log-files (from the working and from the failing compilation. – Ulrike Fischer May 14 '19 at 10:12
  • @daleif 1.No, '\graphicspath{{./img/}}' did not make a difference; 2. Yes, I am sure it was xelatex in texworks. 3. I am using TexLive 2018. TeXwork Version 0.6.2, XeTeX Version 3.14159265-2.6-0.99999 (TeX Live 2018/W32TeX) – KAItO CHAN May 14 '19 at 10:21
  • @UlrikeFischer Both log-files included. Thanks! – KAItO CHAN May 14 '19 at 10:27
  • 1
    You seem not to run xelatex foo on the command line but xelatex D:\Documents\LaTex/foo.tex. Are you sure that you are in the LaTeX-folder on the prompt? – Ulrike Fischer May 14 '19 at 10:32
  • @UlrikeFischer nice catch. I have no issues with TL18 while standing in the folder containing foo.tex. Both pdflatex and xelatex fails if using running from a different folder – daleif May 14 '19 at 10:33
  • @UlrikeFischer I see! I did not know the prompt had to move to the specific path too. Thank you so much! – KAItO CHAN May 14 '19 at 10:35
  • Related answer here many problems stem from slight variations as to where command prompt is active (Its often started by default from the comspec directory) "using xelatex.exe, it seems to be the case that Latex requires the relative paths in your source files to be defined relative to the folder in which the Latex compiler is executed (not relative to the location of your main Latex file)." see https://tex.stackexchange.com/a/232452/170109 –  May 15 '19 at 02:34

0 Answers0