my wrappers around “includegraphics”

To put an image to a document, LaTeX provides the command “\includegraphics“. As it often happens, due to LaTeX was designed for manual typesetting, this command is a nightmare for automatic generation. For a long time, I use a wrapper to solve 99% of the problems.



Without this package, code

raises the dummy error:
! LaTeX Error: Unknown graphics extension: .boat.v1.pdf.


\typeout{! LaTeX warning: File `#2' not found.}%

If there is no image file, LaTeX

* annonces this problem to the console and the log file,
* uses the image “dummy.pdf” instead



This allows to specify a file name with the underscore symbol using the standard LaTeX escaping rules:


instead of


Benefit: no need for special escaping rules in an automatic XML to LaTeX converter.

Actually, the code must be extended, to include “\{”, “\textless” and other special symbols, but it’s TODO.

Leave a Reply