如何使用 \cref 來引用已建立的環境?

如何使用 \cref 來引用已建立的環境?

我試過了

\begin{listing}
\begin{minted}{SQL}
SELECT COUNT(*) FROM lineitem
WHERE l_shipdate <= :shipdate
\end{minted}
\label{test}
\end{listing}

但它不起作用。\cref{test}參考父部分

答案1

你需要有一個數字的東西,就是\caption

在此輸入影像描述

\documentclass{article}
\usepackage{minted}
\usepackage{cleveref}

\begin{document}
\begin{listing}
\begin{minted}{SQL}
SELECT COUNT(*) FROM lineitem
WHERE l_shipdate <= :shipdate
\end{minted}
\caption{Testing}
\label{test}
\end{listing}
See \cref{test}.
\end{document}

相關內容