我想知道,如果铸造环境不适合当前页面的剩余空间,是否可以让其自动显示在新页面上。
目前显示的代码分布在两页上。
答案1
你可以minted
用 围绕区块minipage
。比较以下两个铸造的区块:
\documentclass[]{article}
\usepackage{minted}
\begin{document}
\rule{\textwidth}{0.9\textheight}
\begin{minted}{python}
for i in range(5):
print("foo")
print("foo")
print("foo")
print("foo")
print("foo")
print("foo")
\end{minted}
\clearpage
\rule{\textwidth}{0.9\textheight}
\begin{minipage}[]{\linewidth}
\begin{minted}{python}
for i in range(5):
print("foo")
print("foo")
print("foo")
print("foo")
print("foo")
print("foo")
\end{minted}
\end{minipage}
\end{document}
答案2
samepage
-> 强制整个列表出现在同一页面上,即使它不适合。
\documentclass{article}
\textheight5cm% Just to make the textblock small for the example.
\usepackage{minted}
\begin{document}
\begin{minted}[samepage]{Java}
{Wombat}
{Wombat}
{Wombat}
{Wombat}
{Wombat}
{Wombat}
{Wombat}
{Wombat}
{Wombat}
{Wombat}
{Wombat}
{Wombat}
{Wombat}
{Wombat}
{Wombat}
{Wombat}
{Wombat}
\end{minted}
\end{document}