-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
firstnumber=\ref*{marker} not working #330
Comments
It's always recommended to provide a small but complete example so others can just copy and test, rather than code snippets only. Several steps are needed:
Full example. I deliberately make the value of label different from 1, so it's easier to check if \begin{filecontents}[noheader,force]{foo.js}
function foo() {
} |\mintlabel{marker-from-foo-js}|
\end{filecontents}
\documentclass{article}
\usepackage{minted}
\usepackage{refcount}
\newcommand\mintlabel[1]{%
\label{\detokenize{#1}}%
}
\begin{document}
Use the value of label \verb|marker-from-foo-js| in setting \verb|firstnumber=<number>|
\begin{minted}[autogobble, firstnumber=\getrefnumber{marker-from-foo-js}, linenos]{javascript}
function foo() {
}
\end{minted}
Typeset \verb|foo.js| which defines label \verb|marker-from-foo-js|
\inputminted[escapeinside=||, linenos]{javascript}{foo.js}
\end{document} |
Yes, |
Hi, is it possible to have the similar function for \inputminted[escapeinside=||, linenos, highlightlines={\getrefnumber{marker-in-foo-js}}]{javascript}{foo.js} This doesn't work for me. |
Not possible until you apply some patch, for example one of the two redefinitions below. Note the original definitions live in \makeatletter
% either expand value of `highlightlines` by \edef. This is more useful than the second one.
% before: \define@key{FV}{highlightlines}{\def\FV@HighlightLinesList{#1}}
\define@key{FV}{highlightlines}{\edef\FV@HighlightLinesList{#1}}
% or remove the \detokenize which disables expansion for #1. Is this \detokenize ever required?
\def\FV@HighlightLinesParse@Single#1{%
% before: \expandafter\let\csname FV@HighlightLine:\detokenize{#1}\endcsname\relax
\expandafter\let\csname FV@HighlightLine:#1\endcsname\relax}
\makeatother |
Just found this was once asked and answered (by myself) two years ago (Jun 2020) on tex-sx: https://tex.stackexchange.com/a/549882 . |
Wish the firstnumber to use value like \ref*{line-in-a-file}:
foo.js:
The text was updated successfully, but these errors were encountered: