Quantcast
Channel: Highlight labeled lines of code with minted - TeX - LaTeX Stack Exchange
Viewing all articles
Browse latest Browse all 2

Answer by muzimuzhi Z for Highlight labeled lines of code with minted

$
0
0

Both \ref and \pageref are not fully expandable, but refcount package provides a \getrefnumber{<label name>} which fully expands to the linked counter value of that <label name>. Hence your requirement can be implemented by:

\documentclass{article}\usepackage{minted}\usepackage{refcount}\makeatletter% expand value of key "highlightlines"\define@key{FV}{highlightlines}{\edef\FV@HighlightLinesList{#1}}\makeatother\begin{document}\begin{minted}[    linenos=true,     escapeinside=!!,     highlightlines={\getrefnumber{myline}, \getrefnumber{yourline}}  ]{c++}    i = i + 1 ;      j = j + 1 ; !\label{myline}!    k = k + 1 ;    l = l + 1 ; !\label{yourline}!\end{minted}The important lines is line \ref{myline} and line \ref{yourline}.\end{document}

enter image description here


Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>