这个问题已经索要包裹listings
,但我正在使用minted
并想要实现同样的事情。
我的文档如下所示:
\documentclass{article}
\usepackage{minted}
\begin{document}
\begin{minted}[breaklines=true,linenos]{javascript}
/* My Code: */
console.log("Hello");
console.log("World");
console.log("FooBar");
console.log("BarFoo");
console.log("FooFoo");
\end{minted}
\end{document}
这给了我以下输出:
但是我想要得到以下结果:
1 | /* My Code: */
...|
128| console.log("Hello");
...|
188| console.log("World");
189| console.log("FooBar");
...|
201| console.log("BarFoo");
202| console.log("FooFoo");
如何才能做到这一点?
答案1
\documentclass{article}
\usepackage{minted}
\begin{document}
\renewcommand\theFancyVerbLine{%
\ifnum\value{FancyVerbLine}=2
\setcounter{FancyVerbLine}{127}\ldots
\else\ifnum\value{FancyVerbLine}=129
\setcounter{FancyVerbLine}{187}\ldots
\else\ifnum\value{FancyVerbLine}=190
\setcounter{FancyVerbLine}{200}\ldots
\else
\arabic{FancyVerbLine}%
\fi
\fi
\fi
}
\begin{minted}[breaklines=true,linenos]{javascript}
/* My Code: */
console.log("Hello");
console.log("World");
console.log("FooBar");
console.log("BarFoo");
console.log("FooFoo");
\end{minted}
\end{document}