我在 Overleaf 中使用 LaTex。在序言中,我写道
% 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}
我在投影机的主体中写道
\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}
在我编译它之后,Python 代码没有出现在幻灯片中(该幻灯片是空白的。我还收到错误消息:
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}