我有一个很大的 python 文件,我想在我的 beamer 演示文稿上显示它。
我通常使用 minted,但在使用类似以下方法时,我找不到如何在多个框架上自动显示文件(就像使用文章文档类默认完成的那样):
\begin{frame}[fragile]
\scriptsize
\inputminted{python}{my_file.py}
\end{frame}
多谢 !
答案1
解决方案如下:
\documentclass{beamer}
\usepackage{minted}
\begin{filecontents*}{pythoncode.py}
import getopt, sys, urllib, time
def main():
status = 0
# input arguments
try:
opts, args = getopt.getopt(sys.argv[1:],"h:iq",
["help","invid=","quarter="])
except getopt.GetoptError:
usage()
tree = False
for o, a in opts:
if o in ("-h", "--help"):
usage()
if o in ("-i", "--invid"):
invid = str(a)
if o in ("-q", "--quarter"):
quarter = int(a)
kepid, invid, kepmag, mode, start, stop, release = GetMetaData(invid,quarter)
# convert Gregorian date to Julian date
def Greg2JD(year, month, day):
if (month < 3):
y = float(year) - 1.0
m = float(month) + 12.0
else:
y = float(year)
m = float(month)
a = 0; b = 0
\end{filecontents*}
\begin{document}
\begin{frame}[
t, % align text from top
allowframebreaks, % allow brake frames
fragile % allow verb content
]{Python Code}
\scriptsize
\inputminted[breaklines,breakanywhere]{python}{pythoncode.py}
\end{frame}
\end{document}