TeXipedia

grfext

Provides tools for customizing how graphics file extensions are handled and recognized in LaTeX documents.

Overview

Enhances control over graphics file handling by allowing users to modify which file extensions are recognized and in what order they are processed. This functionality is particularly valuable when working with different image formats or when specific file extension handling is required.

  • Enables adding new file extensions to the graphics recognition system
  • Allows reordering of extension priority for file lookup
  • Useful for projects with mixed image formats or specialized graphics requirements
  • Commonly employed in complex document workflows where precise control over graphics inclusion is needed

Getting Started

To use grfext, include it in your document preamble:

\documentclass{article}
\usepackage{graphicx}  % Required dependency
\usepackage{grfext}

This package allows you to manipulate the list of graphics file extensions recognized by the graphics package.

Examples

Adding a custom file extension to the list of recognized graphics formats.

\documentclass{article}
\usepackage{graphicx}
\usepackage{grfext}

% Add .webp as a recognized graphics extension
\PrependGraphicsExtensions*{.webp}

\begin{document}
\section{Using Custom Graphics Extensions}

With the grfext package, we can include images with extensions not natively supported by the graphics package. For example, if we have a file named "image.webp", we can include it without specifying the extension:

% This would work if you had an actual webp file
% \includegraphics[width=0.5\textwidth]{image}

The above would look for image.webp because we prepended .webp to the list of recognized extensions.

Note: This example demonstrates the syntax, but actual rendering of WebP files would require additional configuration or conversion tools.
\end{document}

Reordering the graphics file extension search order.

\documentclass{article}
\usepackage{graphicx}
\usepackage{grfext}

% Reorder the graphics extensions to prioritize PNG over PDF and JPG
\PrependGraphicsExtensions*{.png}
\RemoveGraphicsExtensions{.pdf,.jpg,.jpeg}
\AppendGraphicsExtensions{.jpg,.jpeg,.pdf}

\begin{document}
\section{Reordering Graphics Extensions}

By default, the graphics package searches for files in a specific order (e.g., .pdf, .eps, .jpg, etc.). With grfext, we can change this order.

In this example, we've:
\begin{itemize}
  \item Moved PNG to the front of the list
  \item Removed PDF, JPG, and JPEG from their original positions
  \item Added them back at the end of the list
\end{itemize}

Now when we use:
\begin{verbatim}
\includegraphics{figure}
\end{verbatim}

LaTeX will first look for figure.png before trying other formats.
\end{document}