[twg-tds] Question: how to include an image file in a document class?
Reinhard Kotucha
reinhard.kotucha at web.de
Mon Sep 14 00:41:59 CEST 2015
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
--
------------------------------------------------------------------
Reinhard Kotucha Phone: +49-511-3373112
Marschnerstr. 25
D-30167 Hannover mailto:reinhard.kotucha at web.de
------------------------------------------------------------------
More information about the twg-tds
mailing list