I have two nearly-identical documents with slightly different settings (one with 11pt font, and the other with 10pt), say book10.tex and book11.tex. They import a code snippet with minted using \inputminted.

I'm trying to reuse the minted cache from the first book to the others, unfortunately, it seems that the cache filenames are different. After compiling both books with xelatex:

xelatex --shell-escape book10.tex && xelatex --shell-escape book11.tex

I seem to have two .pygtex files, with the first part of the hash being identical, but the second part is different:

$ ls

Their contents are identical, but the file names are different.

According to a footnote in the documentation, "cache files are named using an MD5 hash of highlighting settings and highlighted text". I can understand the "highlighted text" part, but what are the highlighting settings, and why do they hash differently?

My MWE is:


module Main where

main :: IO ()
main = putStrLn "Hello world!

book10.tex and book11.tex (simplified)




Question: Can I override the produced filenames? I want to keep the hash of the contents, ignoring the settings hash.

N.B. The solution using \finalizecache doesn't work for my situation, because some files use a macro that imports snippets in a different language instead.


1 Answer 1


I found a solution! I took a closer look at the minted.sty file, and noticed that the jobname was considered as a part of the hash. So I now specify the same -jobname value to xelatex and it seemed to work!

I asked this question on the minted github, and the answer I got suggests doing something similar, specifying \minted@jobname in the .tex file directly.

If that helps, I summarized the steps on my blog.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.