Skip to content

Instantly share code, notes, and snippets.

@programminghoch10
Created February 23, 2025 14:45
Show Gist options
  • Save programminghoch10/5a3be64d3961a40c15f8d6734a3b4773 to your computer and use it in GitHub Desktop.
Save programminghoch10/5a3be64d3961a40c15f8d6734a3b4773 to your computer and use it in GitHub Desktop.
LATeX Minted Cleverref Line Numbers
% insert these two lines after your \usepackage{cleveref}
% then use \mintedlinelabel{labelname} inside the minted file using the "escapeinside" minted option
% then \cref and deriviates should correctly reference as "line x"
\newcounter{line}
\newcommand{\mintedlinelabel}[1]{\setcounter{line}{\value{FancyVerbLine}}\addtocounter{line}{-1}\refstepcounter{line}\label{#1}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment