列表添加问题

列表添加问题

我有一个目录和图片列表。现在想添加listoflisting(在图片列表的下一页)。从内容的角度来看,目录和图片列表是合适的。但listoflisting只有标题而没有内容。我应该添加什么命令才能自动显示所有使用的列表listoflisting?我已阅读帖子(除了“图片列表”和“表格列表”之外,在 stackoverflow Latex 上制作一个“列表列表”。但它不起作用。 还添加了\usepackage{newfloat}& 。\usepackage{listings}

\documentclass{article}
\usepackage{blindtext}
\usepackage{titlesec}
\title{Sections}
\begin{document}
\maketitle
\tableofcontents
\section{Introduction}
This is the first section.
\blindtext
\section{Section main}
This is the main section.

\listoffigures
\begin{figure}
\centering
THIS IS A FIGURE
\caption{A long figure caption so we can see how it looks in the LoF.
         Is this really long enough?}
\end{figure}

\begin{tcolorbox}
\begin{lstlisting} [ label = {Listing1}, abovecaptionskip=10pt]
Integer a b c,
int a=5
Int b=4
\end{lstlisting}
\end{tcolorbox}
 \captionof{lstlisting}[Listing]{constants variables}
 \captionsetup{format=plain}

List of list here.
\blindtext
\end{document}

答案1

正确定义新的浮点类型。

我还建议使用tcolorbox功能来简化输入。

\documentclass{article}
\usepackage{caption}
\usepackage{newfloat}

\usepackage[most]{tcolorbox}
\tcbuselibrary{listings}

\DeclareFloatingEnvironment[
  fileext=lol,
  listname={List of Listings},
  name=Listing,
  placement=tp,
]{listing}

\captionsetup[listing]{
  position=bottom,
}

\renewtcblisting{lstlisting}[1][]{listing only,listing options={#1}}

\begin{document}

\tableofcontents
\listoffigures
\listoflistings

\section{Introduction}
This is the first section.

\section{Section main}
This is the main section.

\begin{figure}[htp]
\centering

THIS IS A FIGURE
\caption{A long figure caption so we can see how it looks in the LoF.
         Is this really long enough?}

\end{figure}

\begin{listing}[htp]

\begin{lstlisting}
Integer a b c,
int a=5
Int b=4
\end{lstlisting}

\caption{constants variables}
\end{listing}

\end{document}

在此处输入图片描述

相关内容