minted
minted copied to clipboard
enhancement required : at least 3 types of highlightlines is required
Greetings , when I am using tcolorbox with minted , I found out that I could not highlight lines for 2 types of color .
What I want to implement is like the picture shown below :
It would be great if your minted packages can support at least 3 types of highlightlines color style .
Here is my code for the codefences :
\usemintedstyle{nord} % Code block highlighting style (see https://pygments.org/styles/)
\colorlet{colorCodefenceBodyDraw}{Gray} % Border color of the code block
\colorlet{colorCodefenceBodyFill}{Black!75!DarkBlue} % Background color of the code block
\colorlet{colorCodefenceNmbrText}{white!25!LightSteelBlue} % Line number text color
\colorlet{colorCodefenceNmbrFill}{colorCodefenceBodyFill} % Line number background color
\colorlet{colorCodefenceTitlText}{colorCodefenceNmbrText} % Title text color (same as line number text)
\colorlet{colorCodefenceTitlDraw}{Cerulean!50!white} % Border color of the title label
\colorlet{colorCodefenceTitlFill}{colorCodefenceBodyFill} % Background color of the title label
% Code block line number format
\renewcommand{\theFancyVerbLine}{%
\ttfamily\textcolor{colorCodefenceNmbrText}{\footnotesize%
\oldstylenums{%
\hfill\arabic{FancyVerbLine}%
}%
}%
}
\DeclareTCBListing{codefence}{ o O{latex} E{HAD}{{}{}{}} }{%
enhanced,
colback =colorCodefenceBodyFill,
colframe=colorCodefenceBodyDraw,
boxrule=.4pt,
boxsep=2pt,
arc=5pt,
left=20pt,
overlay={
\begin{tcbclipinterior}
\tikzset{
boxes/.style={
draw=colorCodefenceTitlDraw,
fill=colorCodefenceTitlFill,
text=colorCodefenceTitlText,
line width=.4pt,
font=\ttfamily\small,
rounded corners=3pt,
outer sep=2pt
}
}
\node(ext) [anchor=north east,boxes] at (frame.north east) {#2};
\IfNoValueF{#1}{
\node(title) [anchor=east,boxes] at (ext.west) {#1};
}
\end{tcbclipinterior}
},
listing only,
listing engine=minted,
minted language = #2,
minted options = { % minted settings
escapeinside= 脎吡,
linenos=true,
numbersep=7.5pt,
highlightlines={#3},
highlightcolor=DarkSlateBlue,
% mathescape%
encoding=utf8
}
}
And here is my " usepackages " :
% Chinese support
\usepackage[
10pt,fontset=fandol
]{ctex} % Chinese typesetting support
% Programming-related
\usepackage{etoolbox} % Patch utilities
\usepackage{xparse} % Robust argument parsing
\usepackage{calc} % Arithmetic expression support
\usepackage{keyval} % Key–value parsing
% Page layout
\usepackage[
landscape,
a4paper,
% margin=1in
]{geometry} % Page margins, size, and layout settings
% Mathematics
\usepackage{amsmath} % Math environments and alignment
\usepackage{amssymb} % Mathematical symbols
\usepackage{amsfonts} % Math fonts like \mathbf \mathsf \mathit
% Color control
\usepackage[
dvipsnames,
svgnames,
table % Enable cell coloring in tables
]{xcolor} % Color extensions
% Code styling
\usepackage[
all
]{tcolorbox} % Fancy text and code boxes
Here is a small demo :
\begin{codefence}[test.hs][haskell]H{3-4}
module Main where
import Lib
import Control.Lens
main :: IO ()
main = someFunc
lst = [x| x <- ['a'..'z']]
-- 注意左侧行号
\end{codefence}
Similar:
- #193