\cref を使用して minted 環境を参照するにはどうすればよいですか?

\cref を使用して minted 環境を参照するにはどうすればよいですか?

私はもう試した

\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}

関連情報