tcblistof 中的水平间距(来自 tcolorbox)

tcblistof 中的水平间距(来自 tcolorbox)

我在 2 位数章节中列出的超过 10 个框存在间距问题:

在此处输入图片描述

我需要调整哪些参数才能使用更宽的标签,即24.42和之间有更多空间An?列表创建为\tcblistof[\section*]{lis}{List of Listings}

[编辑] 添加一个独立的 LaTeX 文件:

\documentclass{book}
\usepackage[listings]{tcolorbox}
\usepackage{cleveref}

\newtcblisting[auto counter,
               number within=chapter,
               crefname={lis.}{lis.},
               Crefname={Listing}{Listings},
               list inside=lis,
              ]{labelboxcode}[4][]{%
    listing options={language=#2,#1},
    list text={#4},
    label=#3,
    listing only
}

\begin{document}
\setcounter{chapter}{23}
\setcounter{tcb@cnt@labelboxcode}{41}

\begin{labelboxcode}{Scala}{scala-listing}{A Scala program.}
def abs(x: Int) = if x > 0 then x else -x
\end{labelboxcode}

\tcblistof[\section*]{lis}{List of Listings}
\end{document}

答案1

b

在您的文档中尝试此代码。(在标题前添加了一个小空格)

\documentclass{book}
\usepackage[listings]{tcolorbox}
\usepackage{cleveref}

\newtcblisting[auto counter,
number within=chapter,
crefname={lis.}{lis.},
Crefname={Listing}{Listings},
list inside=lis,
]{labelboxcode}[4][]{%
    listing options={language=#2,#1},
    list text={\hspace*{1ex}#4}, %<<<<<<<<<<<<<<< changed
    label=#3,
    listing only
}

\begin{document}
\setcounter{chapter}{1}
\setcounter{tcb@cnt@labelboxcode}{0}

\begin{labelboxcode}{Scala}{scala-listing}{A Scala program I}
def abs(x: Int) = if x > 0
\end{labelboxcode}

\newpage
\setcounter{chapter}{1}
\setcounter{tcb@cnt@labelboxcode}{11}
\setcounter{page}{3}

\begin{labelboxcode}{Scala}{scala-listing}{A Scala program II}
def abs(x: Int) = if x > 0
\end{labelboxcode}

    \newpage
\setcounter{chapter}{1}
\setcounter{tcb@cnt@labelboxcode}{33}
\setcounter{page}{12}

\begin{labelboxcode}{Scala}{scala-listing}{A Scala program III}
def abs(x: Int) = if x > 0
\end{labelboxcode}

\newpage
\setcounter{chapter}{23}
\setcounter{tcb@cnt@labelboxcode}{0}
\setcounter{page}{103}

\begin{labelboxcode}{Scala}{scala-listing}{A Scala program IV}
def abs(x: Int) = if x > 0
\end{labelboxcode}

    \newpage
\setcounter{chapter}{23}
\setcounter{tcb@cnt@labelboxcode}{41}
\setcounter{page}{150}

\begin{labelboxcode}{Scala}{scala-listing}{A Scala program V}
def abs(x: Int) = if x > 0
\end{labelboxcode}

\newpage    
\tcblistof[\section*]{lis}{List of Listings}
\end{document}

相关内容