我不太清楚如何在文本中引用代码片段。我还需要代码的标题。我发现唯一可行的方法是将铸币包装在图中。问题是我想将图与代码片段区分开来。
\begin{figure} [ht]
\centering
\begin{minted}[mathescape,
numbersep=5pt,
frame=lines,
framesep=5mm]{sql}
natural join library.Book with amazon.Book as jointarge.BookCollection
with keep attributes library.Book.title
\end{minted}
\caption{A Caption}
\label{fig:Figure}
\end{figure}
答案1
改用listing
环境。
\documentclass[]{article}
\usepackage{minted}
\begin{document}
\begin{listing}[ht]
\begin{minted}[mathescape,
numbersep=5pt,
frame=lines,
framesep=5mm]{sql}
natural join library.Book with amazon.Book as jointarge.BookCollection
with keep attributes library.Book.title
\end{minted}
\caption{A Caption}
\label{lst:Listing}
\end{listing}
Listing \ref{lst:Listing} contains an example of a listing.
\end{document}