0

I run LaTex in Overleaf. In the preamble, I wrote

% Typesetting code
\definecolor{bg}{rgb}{0.95,0.95,0.95}
\usepackage{minted}
\usemintedstyle{friendly}
\newminted{python}{mathescape,frame=lines,framesep=4mm,bgcolor=bg}
\newminted{ipython}{mathescape,frame=lines,framesep=4mm,bgcolor=bg}

in the body of my beamer, I wrote

\begin{frame}[fragile]
\begin{minted}{python}

    In [1]: import numpy as np

    In [2]: x = np.array((2, 4, 6))

    In [3]: y = np.array((10, 10, 10))

    In [4]: x + y  # Vector addition
    Out[4]: array([12, 14, 16])

    In [6]: 2 * x  # Scalar multiplication
    Out[6]: array([ 4,  8, 12])
\end{minted}
\end{frame}

After I compile it, the python code does not appear in the slide(that slide is blank. I also get error message saying:

Package minted Error: Missing Pygments output; \inputminted was I 
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.20 \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.

\documentclass{beamer}

\definecolor{bg}{rgb}{0.95,0.95,0.95}
\usepackage{minted}
\usemintedstyle{friendly}
\newminted{python}{mathescape,frame=lines,framesep=4mm,bgcolor=bg}
\newminted{ipython}{mathescape,frame=lines,framesep=4mm,bgcolor=bg}

\begin{document}

\begin{frame}[fragile]
\begin{minted}{python}

    In [1]: import numpy as np

    In [2]: x = np.array((2, 4, 6))

    In [3]: y = np.array((10, 10, 10))

    In [4]: x + y  # Vector addition
    Out[4]: array([12, 14, 16])

    In [6]: 2 * x  # Scalar multiplication
    Out[6]: array([ 4,  8, 12])
\end{minted}
\end{frame}

\end{document}
5
  • 1
    you are not providing a complete example that can be tested, but according to the overleaf docu minted should work, so ask their support if it doesn't. Jan 5, 2023 at 9:14
  • I fixed your example to be a testable document, it produces this try that exact document in a new overleaf project. Also try removing the cached files (button in the "show logs" area of overleaf) Jan 5, 2023 at 9:53
  • When I open a new project, @DavidCarlisle's method works. But if I just copy the code to my project. It does not work. Even I click "clean cache files". This is the link to the project if you can offer some suggestion. Thanks a lot! overleaf.com/5323513613jbwfjygqyyhb
    – 1689vantil
    Jan 5, 2023 at 13:31
  • you get a timeout the document takes too long to run on the free overleaf. Jan 5, 2023 at 14:40
  • @DavidCarlisle I have deleted all irrelevant slides. Now, only slides using minted package are left. You can see that the problem is still the same. Thanks a lot! overleaf.com/7262253867mjrfkkndqycf
    – 1689vantil
    Jan 6, 2023 at 1:20

1 Answer 1

1

You need your main file at the top level so overleaf calls minted in the right place.

In the left sidebar drag everything out of the directory:

https://www.overleaf.com/read/qttzghkrzfzr

enter image description here

1
  • It works, thanks your patience! The problem is the main file.
    – 1689vantil
    Jan 6, 2023 at 12:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .