Minted 环境编译后返回空白

Minted 环境编译后返回空白

我想在 Latex 中显示以下计算机代码:但是当我编译时我什么也得不到!

    \documentclass{beamer}

    \usetheme{Berkeley}%{Marburg}

    
    \pgfdeclarelayer{pre main}
    \usepackage{etoolbox}
    \usepackage{minted}
\makeatletter
  \setbeamertemplate{sidebar \beamer@sidebarside}
  {
    \beamer@tempdim=\beamer@sidebarwidth%
    \advance\beamer@tempdim by -6pt%
    \vskip4em%
    \insertverticalnavigation{\beamer@sidebarwidth}%
    \vfill
    \ifx\beamer@sidebarside\beamer@lefttext%
    \else%
      \usebeamercolor{normal text}%
      \llap{\usebeamertemplate***{navigation symbols}\hskip0.1cm}%
      \vskip2pt%
    \fi%
  }%

  \ifx\beamer@sidebarside\beamer@lefttext%
    \defbeamertemplate*{sidebar right}{sidebar theme}
    {%
      \vfill%
      \llap{\usebeamertemplate***{navigation symbols}\hskip0.1cm}%
´      \vskip2pt}  \fi

\setbeamertemplate{section in sidebar}%{sidebar theme}
{%
  \vbox{%
    \vskip1ex%
    \beamer@sidebarformat{3pt}{section in sidebar}{\insertsectionheadnumber
~\insertsectionhead}%
  }%
}
\setbeamertemplate{section in sidebar shaded}%{sidebar theme}
{%
  \vbox{%
    \vskip1ex%
    \beamer@sidebarformat{3pt}{section in sidebar shaded}{\insertsectionheadnumber
~\insertsectionhead}%
  }%
}
\makeatother

\begin{document}
\begin{frame}[fragile]
\begin{minted}{Python}

from sympy import Symbol, solve, Eq, plot 

r = Symbol('r') 

s = Symbol('s')

equation = Eq(r**0.6 * s**0.4, 8.79)

sol = solve(equation, s) 

s_of_r = sol[0]

for ri in range(3, 19):

    si = s_of_r.subs(r, ri).evalf()
    
    print(f"for r={5-ri*.25} the corresponding value for s={5-si*.25:.6f}")
\end{minted}

\end{frame}

\end{document}

这是我编译时的结果:

我的文档

_符号{未显示。

我还调用了 -shell-escape 标志 在此处输入图片描述

答案1

逐字逐句的环境需要一个[fragile]框架:

在此处输入图片描述

\documentclass{beamer}
\usetheme{Berkeley}%{Marburg}
\usepackage{minted}

\begin{document}
\begin{frame}[fragile]
\begin{minted}{Python}

from sympy import Symbol, solve, Eq, plot 

r = Symbol('r') 

s = Symbol('s')

equation = Eq(r**0.6 * s**0.4, 8.79)

sol = solve(equation, s) 

s_of_r = sol[0]

for ri in range(3, 19):

    si = s_of_r.subs(r, ri).evalf()
    
    print(f"for r={5-ri*.25} the corresponding value for s={5-si*.25:.6f}")
\end{minted}

\end{frame}
\end{document}

相关内容