Quantcast
Channel: Fallback image file for includegraphics - TeX - LaTeX Stack Exchange
Viewing all articles
Browse latest Browse all 2

Fallback image file for includegraphics

$
0
0

My question is something I feel should be relatively easy to resolve, but I cannot find any references online on how to do it. The basic premise of my situation is as follows:

I have a number of image files for a project I am working on which are based on data that occasionally changes. When this data changes, I run a Python script that regenerates the data at various resolutions, starting with the least detailed versions so that I have a quick draft of what the new graphics will look like and then moving up through the resolutions. Creating a final version can take up to an hour, and I'd rather not have to wait that long for the image referenced in my code to update.

As such, I was wondering if it is possible to set up my \includegraphics command to allow a sequence of fallback images, such that when I regenerate the graphics I delete the old versions and allow new ones with the same filenames to show up as they are generated, so that any existing file with that name is the most current version, without raising nonexistent-file errors in the typesetting process.

A basic idea of what I am aiming for, in TeX-ish pseudocode, is

\documentclass[12pt, oneside]{article}\usepackage{graphicx}\begin{document}...stuff...\begin{center} \includegraphics{if file1.pdf exists: file1.pdf                  elif file2.pdf exists: file2.pdf                  elif file3.pdf exists: file3.pdf                  else: file4.pdf}\end{center}...more stuff...\end{document}

I am using pdfLaTeX at the moment, so I would prefer raw-TeX or LaTex answers if possible, although I could probably make XeTeX/LuaLaTex/ConTeXt/etc. solutions work if need be.


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images