圖列表 - 子圖編號之前沒有“圖”,但在圖前面

圖列表 - 子圖編號之前沒有“圖”,但在圖前面

在我的圖形清單中,我不希望在子圖形前面出現“圖形”一詞。此外,我希望在我的圖形列表中將子圖的編號放在括號中(因此“(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)}

並使用它來定義 subcaption 包,例如

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

當您不希望子圖前面有“圖”前綴時,您應該替換該部分

\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}

相關內容