xqms / graphicscache

Caching & DPI control for the LaTeX graphicx package
BSD 3-Clause "New" or "Revised" License
9 stars 5 forks source link

Use of variables in includegraphics breaks hashing #2

Closed MatthiasNieuwenhuisen closed 5 years ago

MatthiasNieuwenhuisen commented 5 years ago

When using variables as parameters in \includegraphics, the hash of different figures might be the same.

The following example should include two figures with different size (Expected result):

\documentclass{article}

\usepackage{graphicx}
\usepackage{graphicscache}

\newlength{\figurewidth}

\begin{document}
\begin{figure}
\centering
\setlength{\figurewidth}{0.5\linewidth}
\includegraphics[width=\figurewidth]{left-fig}
\caption{50\% figure}
\end{figure}

\begin{figure}
\centering
\setlength{\figurewidth}{0.1\linewidth}
\includegraphics[width=\figurewidth]{left-fig}
\caption{10\% figure}
\end{figure}

\end{document}

but the actual result are two figures of equal size (Actual result).

LaTeX and image files: parameter-hashing-issue.zip

xqms commented 5 years ago

Fixed!

xqms commented 5 years ago

Note: doing this correctly (actually expanding and parsing the arguments) allowed me to render the images using standalone tex documents in 55ebcf7b612 - much faster than the preview package :-)

MatthiasNieuwenhuisen commented 5 years ago

Wow, it's super fast now!