gpoore / minted

minted is a LaTeX package that provides syntax highlighting using the Pygments library. Highlighted source code can be customized using fancyvrb.
1.73k stars 124 forks source link

Minted in imported .tex files gives Error: Missing Pygments #233

Open casper-hansen opened 5 years ago

casper-hansen commented 5 years ago

I'm on Overleaf, using pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017) (preloaded format=pdflatex 2017.7.12)

My setup is that I do this for every chapter:

\chapter{Implementation}
    \import*{chapters/}{implementation.tex}

But if I write any code in implementation.tex, minted gives me the error. If I just write it in my main document, minted works. I'm wondering why it won't work with import?

I tried different supposed solutions from stackexchange, with regards to how you import it. Including frozencache, cache, outputdir.


[22]) (/compile/chapters/3neuralnetworks.tex) [23]
Chapter 3.
(/compile/chapters/implementation.tex
\openout3 = `output.pyg'.

runsystem(pygmentize -S default -f latex -P commandprefix=PYG > cache/_minted-o
utput/default-pyg-prefix.pygstyle)...executed.

! 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.3 \end{minted}^^M

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.

runsystem(pygmentize -S default -f latex -P commandprefix=PYGdefault > cache/_m
inted-output/default.pygstyle)...executed.

! 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.3 \end{minted}^^M

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.

runsystem(pygmentize -l python -f latex -P commandprefix=PYG -F tokenmerge -o c
ache/_minted-output/467EF5CF54F8D271C6FBB03A2C39FE16.pygtex cache/output.pyg)..
.executed.

! 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.3 \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.

)
gpoore commented 5 years ago

This is a known incompatibility with the import package. See https://github.com/gpoore/minted/issues/172.

casper-hansen commented 5 years ago

Thanks, I guess this can be closed, if it is duplicate. Has this been added to the documentation yet? I could not really find anything about it.

gpoore commented 5 years ago

It looks like the other issue got closed before a note was added to the documentation. So I am going to reopen this issue to make sure that it gets into the documentation this time.

sebacea commented 2 years ago

You know if it is realted to this: https://tex.stackexchange.com/questions/531738/minted-environment-not-working-in-overleaf ? Is the yo' solution

usepackage[outputdir=../]{minted}

a valid one. I am not able to use it.

gpoore commented 2 years ago

@sebacea This issue is primarily about the import package, which is incompatible with minted. What you linked to is related to Overleaf's internal functionality, which is a different situation and something that minted cannot address. It appears that the solution for the linked Overleaf situation is to avoid using subdirectories.

JoostScheffer commented 6 months ago

I noticed that unfortunately the same problem arises when using the subfiles package

jeyci94 commented 3 weeks ago

So if I have an overleaf a folder structure similar to: \maindir -- \subdir1 -- \subdir2 --- \Resources ---- Preamble.tex --- main.tex Meaning, the main.tex file is under \subdir2 and at the same level as the /Resources folder, while the Preamble.tex with all the /usepackage is under \Resources. Is there then no way minted will work this way? Do I have to forcefully move the files from the folders they currently are?