Given the following LaTeX document (minimal.tex):

int main() {
    printf("hello, world");
    return 0;

I can build it with:

pdflatex -shell-escape  minimal.tex

But I would like to put the build files in another directory, so I use -output-directory=build, like:

pdflatex -shell-escape -output-directory=build minimal.tex

But this way I get:

[Loading MPS to PDF converter (version 2006.09.02).]
))) (./_minted-minimal/default-pyg-prefix.pygstyle)Error: cannot read infile: [Errno 2] No such file or directory: 'minimal.pyg'
system returned with code 256

! Package minted Error: Missing Pygments output; \inputminted was
probably given a file that does not exist--otherwise, you may need 
the outputdir package option, or may be using an incompatible build tool.

See the minted package documentation for explanation.
Type  H <return>  for immediate help.

l.9 \end{minted}

The minimal.pyg actually is inside build directory, but it seems not to be found.

What can I do?


You need \usepackage[outputdir=build]{minted} to tell minted where the files went.


You can use currfile-abspath (a sub-package of currfile) to set minted's output directory automatically. Must be done before loading the minted package.

\ifthenelse{\equal{\theabsdir}{\thepwd}}% using ifthen package
%\ifdefstrequal{\theabsdir}{\thepwd}% using etoolbox package

Apparently doesn't work reliably with MiKTeX, see https://github.com/gpoore/minted/issues/268

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.