在列表列表中的列表编号后添加点

在列表列表中的列表编号后添加点

您好,有人知道如何在列表的列表编号后添加前导点吗?

我正在使用listings包和\lstlistoflistings命令。

我使用tocloft包在图表列表中执行此操作但我认为使用此包无法完成。

下面是我希望出现的点的示例: 清单示例

我还可以提供 MWE:

\documentclass[12pt, a4paper, polish]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[T1]{polski}

% Listing package and customization
\usepackage{listings}
\usepackage{inconsolata}
\usepackage{xcolor}
\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{background}{RGB}{40,42,54}
\definecolor{foreground}{RGB}{248,248,242}
\lstdefinestyle{syntaxStyle}{
    commentstyle=\color{codegreen},
    keywordstyle=\color{magenta},
    numberstyle=\tiny\color{codegray},
    stringstyle=\color{codepurple},
    basicstyle=\ttfamily\footnotesize,
    breakatwhitespace=false,         
    breaklines=true,                 
    columns=flexible,
    captionpos=t,                    
    keepspaces=true,                 
    numbers=left,                    
    numbersep=5pt,                  
    showspaces=false,                
    showstringspaces=false,
    showtabs=true,                  
    tabsize=2,
    xleftmargin=.15\textwidth,
    xrightmargin=.15\textwidth,
    aboveskip=.7cm,
    belowskip=.7cm
}

\lstset{
  frame=lines,
  style=syntaxStyle
}

\begin{document}

% Test Listings
\begin{lstlisting}[language = Java, caption={This is some title}]
// This is test of listing
}
\end{lstlisting}
\begin{lstlisting}[language = Java, caption={This is some title}]
// This is test of listing
}
\end{lstlisting}
\begin{lstlisting}[language = Java, caption={This is some title}]
// This is test of listing
}
\end{lstlisting}

% List of listings
Here's list of listings
\lstlistoflistings
\end{document}

答案1

我向命令添加了一个补丁,将列表添加到列表列表中。

\usepackage{xpatch}
\makeatletter
\xpatchcmd\lst@MakeCaption{\protect\numberline{\thelstlisting}\lst@@caption}{\protect\numberline{\thelstlisting.}\lst@@caption}{}{}
\makeatother

b

\documentclass[12pt, a4paper, polish]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[T1]{polski}

% Listing package and customization
\usepackage{listings}
\usepackage{inconsolata}
\usepackage{xcolor}
\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{background}{RGB}{40,42,54}
\definecolor{foreground}{RGB}{248,248,242}
\lstdefinestyle{syntaxStyle}{
    commentstyle=\color{codegreen},
    keywordstyle=\color{magenta},
    numberstyle=\tiny\color{codegray},
    stringstyle=\color{codepurple},
    basicstyle=\ttfamily\footnotesize,
    breakatwhitespace=false,         
    breaklines=true,                 
    columns=flexible,
    captionpos=t,                    
    keepspaces=true,                 
    numbers=left,                    
    numbersep=5pt,                  
    showspaces=false,                
    showstringspaces=false,
    showtabs=true,                  
    tabsize=2,
    xleftmargin=.15\textwidth,
    xrightmargin=.15\textwidth,
    aboveskip=.7cm,
    belowskip=.7cm
}

\lstset{
    frame=lines,
    style=syntaxStyle
}


% <<<<<<<<<<<< added
\usepackage{xpatch}
\makeatletter
\xpatchcmd\lst@MakeCaption{\protect\numberline{\thelstlisting}\lst@@caption}{\protect\numberline{\thelstlisting.}\lst@@caption}{}{}
\makeatother
% <<<<<<<<<<<<<<<<<

\begin{document}
    
% Test Listings
\begin{lstlisting}[language = Java, caption={This is some title}]
// This is test of listing
}
\end{lstlisting}
\begin{lstlisting}[language = Java, caption={This is some title}]
// This is test of listing
}
\end{lstlisting}
\begin{lstlisting}[language = Java, caption={This is some title}]
// This is test of listing
}
\end{lstlisting}

% List of listings
Here's list of listings
\lstlistoflistings
\end{document}

相关内容