如何设置列表的标签?

如何设置列表的标签?

你好,我是 Latex 的新手,我正在使用 Board 上的这段代码,一切正常,但我不知道如何使用这段代码设置列表的标签

\usepackage[many,minted]{tcolorbox}

\newcommand{\mynewminted}[3]{%
  \newminted[#1]{#2}{#3}%
  \tcbset{myminted/#1/.style={minted language=#2,minted options={#3}}}}

\mynewminted{myc}{c}{tabsize=2,fontsize=\footnotesize,linenos, numbersep=3mm}

\newtcblisting[auto counter,number within=section,
  list inside=mypyg]{listingsbox}[3][]{%
  listing only,
  title={Listing \thetcbcounter: #3},
  list entry={\protect\numberline{\thetcbcounter}#3},
  enhanced,
  left=6mm,
  overlay={\begin{tcbclipinterior}\fill[black!15] (frame.south west)
            rectangle ([xshift=6mm]frame.north west);\end{tcbclipinterior}},
  colframe=black!35,
  drop fuzzy shadow,
  myminted/#2,#1}


\begin{listingsbox}{myc}{test} 

Examplecode

\end{listingsbox}

答案1

如果我理解正确的话,您希望将\label列表\ref放在某个地方。如果是这样,请添加标签,如下所示:

\begin{listingsbox}{myc,label=mint}{test}

并在其他地方使用\ref{mint}

\documentclass{article}
\usepackage[many,minted]{tcolorbox}

\newcommand{\mynewminted}[3]{%
  \newminted[#1]{#2}{#3}%
  \tcbset{myminted/#1/.style={minted language=#2,minted options={#3}}}}

\mynewminted{myc}{c}{tabsize=2,fontsize=\footnotesize,linenos, numbersep=3mm}

\newtcblisting[auto counter,number within=section,
  list inside=mypyg]{listingsbox}[3][]{%
  listing only,
  title={Listing \thetcbcounter: #3},
  list entry={\protect\numberline{\thetcbcounter}#3},
  enhanced,
  left=6mm,
  overlay={\begin{tcbclipinterior}\fill[black!15] (frame.south west)
            rectangle ([xshift=6mm]frame.north west);\end{tcbclipinterior}},
  colframe=black!35,
  drop fuzzy shadow,
  myminted/#2,#1}

\begin{document}
\begin{listingsbox}{myc,label=mint}{test}

Examplecode

\end{listingsbox}

From listing~\ref{mint}, we see a code.
\end{document}

在此处输入图片描述

相关内容