图表列表 - 子图表编号前没有“图表”,但在图表前

图表列表 - 子图表编号前没有“图表”,但在图表前

在我的图表列表中,我不希望子图前面出现“图”字。此外,我希望在图表列表中将子图的编号放在括号中(即“(a)”而不是“a”),并且直接放在图表列表中“SuperTest”图的“S”下。

提前非常感谢您!

这是我的 MWE:

\documentclass[11pt]{article}
\usepackage{blindtext,tabularx,graphicx}

\usepackage[margin=1in]{geometry}
\usepackage[list=true]{subcaption}
\usepackage[labelfont=bf,labelsep=period]{caption}

\usepackage{tocloft}
\captionsetup[subfigure]{skip=8pt,position=bottom,font=bf}
\captionsetup[table]{font=bf}
\captionsetup[figure]{labelfont=bf}

%%%%%%%%%%%% ToC, LoF, LoT ADJUSTMENTS %%%%%%%%%%%%%%%%%%%%
% Formatting ToC
% Adjust spacing between number and title in ToC

% Adjust dots in ToC, LoF, LoT
\renewcommand\cftdotsep{1}
\makeatletter
\renewcommand{\@dotsep}{1}
\makeatother

\setlength{\cftfigindent}{0pt}  % remove indentation from figures in lof
\setlength{\cfttabindent}{0pt}  % remove indentation from tables in lot

% Formatting LoF
\setcounter{lofdepth}{2}
\cftpagenumbersoff{subfigure}

\makeatletter
\renewcommand\cftfigfont{\bfseries}
\makeatother

\makeatletter
\newcommand\cftsubtabdotsep{\cftdotsep}
\newcommand\cftsubfigfont{\normalfont}
\newcommand\cftsubfigpresnum{}
\newcommand\cftsubfigaftersnum{}
\newcommand\cftsubfigaftersnumb{}
\newcommand\cftsubfigleader{\hfill}
\newcommand\cftsubfigpagefont{\normalfont}
\newcommand\cftsubfigafterpnum{}
\providecommand{\toclevel@subfigure}{1}
\renewcommand*\l@subfigure[2]{%
  \ifnum \c@lofdepth > \toclevel@subfigure
    \vskip \cftbeforesubfigskip
    {\leftskip \cftsubfigindent\relax
     \rightskip \@tocrmarg
     \parfillskip -\rightskip
     \parindent \cftsubfigindent\relax\@afterindenttrue
     \interlinepenalty\@M
     \leavevmode
     \@tempdima \cftsubfignumwidth\relax
     \let\@cftbsnum \cftsubfigpresnum
     \let\@cftasnum \cftsubfigaftersnum
     \let\@cftasnumb \cftsubfigaftersnumb
     \advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
     {\cftsubfigfont #1}\nobreak
     \cftsubfigfillnum{#2}}%
  \fi
  }%
\newlength\cftbeforesubfigskip
  \setlength\cftbeforesubfigskip{\z@ \@plus.2\p@}
\newlength\cftsubfigindent
  \setlength\cftsubfigindent{3.8em}
\newlength\cftsubfignumwidth
  \setlength\cftsubfignumwidth{2.5em}
\renewcommand{\cftsubfigfillnum}[1]{%
  {\cftsubfigleader\hfill}\par
}
\makeatother

% Formatting LoT
\setcounter{lotdepth}{1}
\makeatletter
\renewcommand\cfttabfont{\bfseries}
\makeatother


\begin{document}

\tableofcontents
\clearpage
{%
\let\oldnumberline\numberline%
\renewcommand{\numberline}{\figurename~\oldnumberline}%
\listoffigures%
}
%\listoffigures
\addcontentsline{toc}{section}{List of Figures}
\clearpage
{%
\let\oldnumberline\numberline%
\renewcommand{\numberline}{\tablename~\oldnumberline}%
\listoftables
}
\addcontentsline{toc}{section}{List of Tables}

\clearpage

\section{Nice0}
\begin{figure}[htb] \label{figure:Test}
    \centering
    \includegraphics[width=\textwidth]{example-image}
    \captionsetup[subfigure]{skip=8pt,position=bottom}
    \parbox{0.5\textwidth}{\subcaption[Test]{Test}}\hfill
    \parbox{0.5\textwidth}{\subcaption[Test2]{Test2}}
    \caption[SuperTest]{{\bf Test} \\Histogram of (a) Test and (b) most common Test sample.}
\end{figure}

\clearpage

\section{Nice1}

\begin{table}[htbp]\label{table:Test}
\caption[Test]{Test} \blindtext
\begin{center}
\begin{tabular}{|l||c|c|} \hline\hline
Ice Cream Store & Location & How to Get There \\ \hline
Toscanini’s & Central Square & Just walk! \\
Herrell’s & Harvard Square & Red Line \\
J.P. Licks & Davis Square & Red Line \\
Ben \& Jerry’s & Newbury Street & Green Line \\ \hline\hline
\end{tabular}
\end{center}
\end{table}

\end{document}

答案1

对于子图字母周围的括号,你可以使用以下方法定义自己的列表格式

\DeclareCaptionListFormat{myListFormat}{(#2)}

并用它来定义子标题包,例如

\usepackage[list=true, listformat=myListFormat]{subcaption}

如果你不想在子图前面加上“Figure”前缀,你应该替换该部分

\let\oldnumberline\numberline%
\renewcommand{\numberline}{\figurename~\oldnumberline}%

您的代码

\renewcommand{\cftfigpresnum}{Figure~}
\setlength{\cftfignumwidth}{5em}

我添加了您的代码的完整工作修改示例。

\documentclass[11pt]{article}

\usepackage{blindtext,tabularx,graphicx}
\usepackage[margin=1in]{geometry}
\usepackage[labelfont=bf,labelsep=period]{caption}

\DeclareCaptionListFormat{myListFormat}{(#2)}

\usepackage[list=true, listformat=myListFormat]{subcaption}

\usepackage{tocloft}
\captionsetup[subfigure]{skip=8pt,position=bottom,font=bf}
\captionsetup[table]{font=bf}
\captionsetup[figure]{labelfont=bf}

%%%%%%%%%%%% ToC, LoF, LoT ADJUSTMENTS %%%%%%%%%%%%%%%%%%%%
% Formatting ToC
% Adjust spacing between number and title in ToC

% Adjust dots in ToC, LoF, LoT
\renewcommand\cftdotsep{1}
\makeatletter
\renewcommand{\@dotsep}{1}
\makeatother

\setlength{\cftfigindent}{0pt}  % remove indentation from figures in lof
\setlength{\cfttabindent}{0pt}  % remove indentation from tables in lot

% Formatting LoF
\setcounter{lofdepth}{2}
\cftpagenumbersoff{subfigure}

\makeatletter
\renewcommand\cftfigfont{\bfseries}
\makeatother

\makeatletter
\newcommand\cftsubtabdotsep{\cftdotsep}
\newcommand\cftsubfigfont{\normalfont}
\newcommand\cftsubfigpresnum{}
\newcommand\cftsubfigaftersnum{}
\newcommand\cftsubfigaftersnumb{}
\newcommand\cftsubfigleader{\hfill}
\newcommand\cftsubfigpagefont{\normalfont}
\newcommand\cftsubfigafterpnum{}
\providecommand{\toclevel@subfigure}{1}
\renewcommand*\l@subfigure[2]{%
  \ifnum \c@lofdepth > \toclevel@subfigure
    \vskip \cftbeforesubfigskip
    {\leftskip \cftsubfigindent\relax
     \rightskip \@tocrmarg
     \parfillskip -\rightskip
     \parindent \cftsubfigindent\relax\@afterindenttrue
     \interlinepenalty\@M
     \leavevmode
     \@tempdima \cftsubfignumwidth\relax
     \let\@cftbsnum \cftsubfigpresnum
     \let\@cftasnum \cftsubfigaftersnum
     \let\@cftasnumb \cftsubfigaftersnumb
     \advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
     {\cftsubfigfont #1}\nobreak
     \cftsubfigfillnum{#2}}%
  \fi
  }%
\newlength\cftbeforesubfigskip
  \setlength\cftbeforesubfigskip{\z@ \@plus.2\p@}
\newlength\cftsubfigindent
  \setlength\cftsubfigindent{3.8em}
\newlength\cftsubfignumwidth
  \setlength\cftsubfignumwidth{2.5em}
\renewcommand{\cftsubfigfillnum}[1]{%
  {\cftsubfigleader\hfill}\par
}
\makeatother

% Formatting LoT
\setcounter{lotdepth}{1}
\makeatletter
\renewcommand\cfttabfont{\bfseries}
\makeatother


\begin{document}

\tableofcontents
\clearpage
{%
\renewcommand{\cftfigpresnum}{Figure~}
\setlength{\cftfignumwidth}{5em}
\listoffigures%
}
%\listoffigures
\addcontentsline{toc}{section}{List of Figures}
\clearpage
{%
\let\oldnumberline\numberline%
\renewcommand{\numberline}{\tablename~\oldnumberline}%
\listoftables
}
\addcontentsline{toc}{section}{List of Tables}

\clearpage

\section{Nice0}
\begin{figure}[htb] \label{figure:Test}
    \centering
    \includegraphics[width=\textwidth]{example-image}
    \captionsetup[subfigure]{skip=8pt,position=bottom}
    \parbox{0.5\textwidth}{\subcaption[Test]{Test}}\hfill
    \parbox{0.5\textwidth}{\subcaption[Test2]{Test2}}
    \caption[SuperTest]{{\bf Test} \\Histogram of (a) Test and (b) most common Test sample.}
\end{figure}

\clearpage

\section{Nice1}

\begin{table}[htbp]\label{table:Test}
\caption[Test]{Test} \blindtext
\begin{center}
\begin{tabular}{|l||c|c|} \hline\hline
Ice Cream Store & Location & How to Get There \\ \hline
Toscanini’s & Central Square & Just walk! \\
Herrell’s & Harvard Square & Red Line \\
J.P. Licks & Davis Square & Red Line \\
Ben \& Jerry’s & Newbury Street & Green Line \\ \hline\hline
\end{tabular}
\end{center}
\end{table}

\end{document}

相关内容