I'd like to reference lines in the minted
environment (solved here for regular \ref
) using cleveref.
MWE:
% !TEX TS-program = arara
% arara: pdflatex: { shell: yes }
% arara: pdflatex: { shell: yes }
\documentclass{article}
\usepackage{minted}
\usepackage{cleveref}
\begin{document}
\section{First section}
\begin{minted}[linenos=true, mathescape]{c}
int i = 0;
int j = 1; // label $\label{ln:unreachable1}$
\end{minted}
Test with ref: \ref{ln:unreachable1}
Test with cref: \cref{ln:unreachable1}
\end{document}
Gives
i.e. the containing section instead of "line $number".
cleveref
, which doesn't exist yet. And I'm unlikely to have time to add it myself anytime soon. It might be easy to code the necessary support yourself, or it might be hard, depending on how theminted
environment is implemented. Thealgorithmicx
support already incleveref
might give you some clues. If you send me a patch tocleveref
to addminted
support, I'd certainly consider applying it.