# minted environment not working in overleaf

The code it's not working on Overleaf when it comes to minted environment (or mint command) used in a file placed in a subdirectory. Note that the very same code works if placed in main directory. Tested on Chrome with LaTex,PdfLaTex,XeLaTex and LuaLaTex

You can test the example on Overleaf site but for your convenience I can add a MWE:

\documentclass{article}
\usepackage{minted}

\begin{document}
test
\begin{minted}{python}
import numpy as np

def incmatrix(genl1,genl2):
m = len(genl1)

\end{minted}

\mint{html}|<h2>Something <b>here</b></h2>|

\end{document}


This will produce only the line "test".

Please note that \inputminted works as a charm; I adopted this as a workaround but there are cases in which it is really a nuisance.

Obviously with non trivial projects it is almost impossible for me to keep every file in the same (overleaf) folder.

The log says:(twice, another almost identical is for \mint)

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,
or may be using frozencache with a missing file.

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

l.12 \end{minted}

This could be caused by using -output-directory or -aux-directory
without setting minted's outputdir, or by using a build tool that
changes paths in ways minted cannot detect,
or using frozencache with a missing file.

• what error message do you get in the log? Your file (in texlive) runs without error producing this output Mar 8, 2020 at 16:05
• I edited my question to add the log output and to state clearly that code is working if placed in main directory. Mar 8, 2020 at 16:27
• oh yes overleaf renames its files in interesting ways, it's an overleaf question then I think you'd be better asking their support Mar 8, 2020 at 16:50

(Tom from Overleaf Support Team speaking.)

Unfortunately, this is a limitation of the current setup of Overleaf, sorry for this. The main file should preferably be always placed in the main directory; this is essential in particular for any document that uses external tools, which is the case also for minted.

• Is this something that could be worked around with a change to minted?
– Eric
Nov 16, 2020 at 13:14
• Hi Eric! No, I'm afraid this is a given by our setup. We are looking into ways how to remove this burden, and we have ideas how to do that, but none of them is fully backwards-compatible; we know that if we change the ways how we call LaTeX, we'll break something for someone :-/
– yo'
Nov 16, 2020 at 13:25
• In the meantime, is there some way to point an overleaf project to a subdirectory of a larger github project?
– Eric
Nov 16, 2020 at 13:45
• @Eric I'm afraid not directly, sorry for this. But you should be able to do it relaying via a local repo using the git bridge (not the GitHub sync). You would sync the whole GitHub repo with local, and then only sync a subdir with Overleaf.
– yo'
Nov 16, 2020 at 14:29
• @Eric That was basically the idea, yes. It's not optimal, but it provides more control than the GitHub sync, which really only synces the whole repo with the project, without any finer control. (Btw, I hate to flood the comments here with unrelated issues as that's not probably a proper thing to do :) , so I suggest you contact us at support@overleaf.com if you have any more questions. Thanks!)
– yo'
Nov 16, 2020 at 15:37