[twg-tds] Question: how to include an image file in a document class?
Lei Ye
lei at uow.edu.au
Mon Sep 14 06:07:14 CEST 2015
Hi, Reinhard
The uowthesis package is installed with the MiKTeX Package Manager.
The UoWlogo.png went to doc/latex/uowthesis/, therefore
kpsewhich UoWlogo.png
returns nothing.
kpsewhich UoWthesis.cls
returns
C:/Users/lei/AppData/Roaming/MiKTeX/2.9/tex/latex/uowthesis/UoWthesis.cls
It's my first time to know \graphicspath is deprecated.
In the following scenario, what is the best way to do it.
I first have a subfolder call images/ to hold my figures and have 100
\includegraphics{images/myimage.png}
Then later I decide to change the hosting folder to figures/. Instead of
replacing "images/" in all 100 \includegraphics commands, what is a
better way to do it?
>From time to time, we provide some advice to students on how to do
things in Latex for their papers and theses. It would be good to have a
published document to refer to on the deprecation of \graphicspath so
that we can suggest them to avoid deprecated constructs.
Regards,
Lei
On 14/09/2015 8:42 AM, Reinhard Kotucha wrote:
> Ulrike, if I understand Lei's problem correctly, MiKTeX doesn't find
> tex/latex/uowthesis/UoWlogo.png for some reason. I can't believe it.
> Can you reproduce the problem?
>
>
> On 2015-09-13 at 04:08:32 +0000, Lei Ye wrote:
>
> > In the document "A Directory Structure for TEX Files" version 1.1, June
> > 23 2004, it defines the TDS texmf directory tree and use "texmf" to
> > refer to its root.
> >
> > e.g. texmf/doc
>
> The TDS tells you where to *put* your files. If you put them into the
> right directories they will be found by your TeX system automatically.
>
> > Are there generic, platform-independent TEX variables like @TEXMF and
> > @TEXMFLOCAL to resolve the directory tree defined in TDS for both Tex
> > Live and MikTeX?
> >
> > e.g. To allow any of the following to work:
> >
> > \IfFileExists{\@TEXMFLOCAL /doc/latex/uowthesis/UoWlogo.png}
> > \includegraphics{\@TEXMFLOCAL /doc/latex/uowthesis/UoWlogo.png}
>
> There is neither a need to specify a path nor is it desired. Use
>
> \IfFileExists{UoWlogo.png}{}{}
>
> and
>
> \includegraphics{UoWlogo.png}
>
> instead and rely on your TeX system. You can check it on the command
> line. On TeX Live I get
>
> $ kpsewhich UoWthesis.cls
> /xopt/texlive/2015/texmf-dist/tex/latex/uowthesis/UoWthesis.cls
>
> and
>
> $ kpsewhich UoWlogo.png
> /xopt/texlive/2015/texmf-dist/tex/latex/uowthesis/UoWlogo.png
>
> I suppose that on MiKTeX the first command works for you. If the
> second doesn't, please note that there are already 61 PNG files under
> TEXMF/tex/latex. I can't imagine that MiKTeX is unable to find any
> of them. Did you install the PNG file manually and forgot to update
> the filename database?
>
>
> > \graphicspath{ {\@TEXMF /tex/latex/uowthesis/} {\@TEXMFLOCAL
> > /tex/latex/uowthesis/} {\@TEXMFLOCAL /doc/latex/uowthesis/} {\@TEXMF
> > /doc/latex/uowthesis/} }
>
> I assume that you tried \graphicspath because something else went
> wrong. The short answer is "hands off!".
>
> First of all, ***never*** use absolute paths.
>
> \graphicspath is supposed to contain a list of paths relative to the
> location of a particular document. It should never be used in .cls or
> .sty files.
>
> The original idea was to allow you to write
>
> \graphicspath{{photos/}{drawings/}}
> \includegraphics{my_dog.jpg}
> \includegraphics{my_house.pdf}
>
> instead of
>
> \includegraphics{photos/my_dog.jpg}
> \includegraphics{drawings/my_house.pdf}
>
> but the latter solution is much more efficient wrt TeX's memory
> consumption. Therefore \graphicspath is deprecated nowadays. It
> unnecessarily adds things to TeX's string pool without providing a
> significant benefit to the user.
>
> Regards,
> Reinhard
>
More information about the twg-tds
mailing list