I am working on a beamer template for my institute in which I am using \pgfdeclareimage
for images. I have quite a lot images and logos for different projects/experiments/groups and I organised the files as
mainfolder/
-example.tex
-beamerthememy.sty
-art/myexample.pdf
Now the problem is how to declare the images. Using
\pgfdeclareimage[width=.5\paperwidth]{test}{art/myexample.pdf}
works for the .tex
file in the same folder as the .sty
file and the art
directory.
But when I put the .sty
file and the art
directory inside my $TEXMFHOME
directory (and the .tex
file somewhere else) I have to use
\pgfdeclareimage[width=.5\paperwidth]{test}{myexample.pdf}
I there a way to declare the image which works in both cases?
\documentclass{beamer}
% works if .tex file is in the same directory as the .sty file and `testdir`
\pgfdeclareimage[width=.5\paperwidth]{test}{art/myexample.pdf}
% works if .sty file and `textdir` are in my lokal `texmf` folder
%\pgfdeclareimage[width=.5\paperwidth]{test}{myexample.pdf}
\begin{document}
\begin{frame}
\pgfuseimage{test}
\end{frame}
\end{document}
To make the example minimal I moved \pgfdeclareimage
from the .sty
file to the .tex
file. If you have the feeling, this is too minimal, I will add a .sty file
Best Answer
In a nutshell, if you pass more than a file name (a path) to
pgfdeclareimage
,pdflatex
looks just there. Otherwise, it looks for it in the complete search path, which traditionally is specified in theTEXINPUTS
environment variable.So a simple solution would be to add
./art
toTEXINPUTS
and then just use the file name inpdfdeclareimage
.However, as this is for a reusable template, you have to keep your users in mind. MikTeX, for instance, handles search paths differently and many users have difficulties to fiddle with environment variables, especially when using some LaTeX-IDE. So For ease of use, I would try to handle this in the template itself: