I wanted to know if there were any methods that would allow me to reference lines in source code that was imported with the \inputminted macro from the minted package?
My assumption is that this is not possible given that it is an external file?
I am trying to avoid copying the contents of the file manually as I don't want to accidentally forget to update the code in my .tex file. So if anyone has any suggestions, I would love to hear them!
Thanks.
MWE:
\documentclass{report}
\usepackage{minted}
\setminted{
linenos
}
\begin{document}
% Report contents
In \hyperref[code.m:30]{Line 30} we can find \dots
% Appendix
\inputminted{MATLAB}{code.m}
% The following LaTeX code is only for illustration purposes
\label{code.m:30}
\end{document}

-inside label (e.g.\label{this-line}). In particular I get! Missing \endcsname inserted.andLaTeX Warning: Hyper reference \this-line' on page 1 undefined on input line 17`. – miticollo Mar 13 '23 at 10:07