为什么子图编号不是“a”和“b”?

为什么子图编号不是“a”和“b”?

分子量 %

\documentclass{book} %
%
\usepackage[fleqn]{amsmath} %
\usepackage{amsthm,amssymb} %
\usepackage[explicit]{titlesec} %
\usepackage{titletoc} % more advanced but essential here
\usepackage[english]{babel} %
\usepackage{txfonts} % essential
\usepackage{xcolor}
\usepackage{colortbl} % canged to just colortbl
\usepackage{caption} %
\usepackage{subcaption}
\usepackage[verbose]{geometry} % problem persists when dvips, pdftex taken out
\usepackage[a4,frame,center]{crop} % a4=210mm x 297mm
\usepackage[most]{tcolorbox}
\usepackage{bookmark} % faster updated bookmarks
%\usepackage{hyperref}
%
% - START DECLARATIONS
%
\setlength{\unitlength}{1mm} % 1mm=2.834646pt; 1pt=0.3515mm
%
% - horizontally
\paperwidth=170mm
\paperheight=240mm
\setlength{\textwidth}{132mm} % width of text [133mm]

\definecolor{ThemeColour}{rgb}{0.45,0.00,0.45} % ThemeColour maroon
\definecolor{DarkGrey}{rgb}{0.92,0.92,0.92}
\definecolor{DarkRed}{rgb}{0.45,0.00,0.00} % #880000
\definecolor{LightCream}{rgb}{1.00,1.00,0.90} %

\newcommand\Hrule{\noindent\color{ThemeColour}{\rule{\linewidth}{3pt}}} %
\newcommand\hseprule{\color{DarkRed}{\rule{\linewidth}{0.7pt}}} %

\titleformat{\chapter}[display]
{\color{ThemeColour}\bfseries\itshape\fontsize{30}{30}\selectfont} %
{\Hrule\vspace*{6pt}\\ {\color{black}\,\chaptername\hspace{8pt}\normalfont\fontsize{42}{45}\selectfont{\thechapter}}} %
{0pt}{\bfseries\normalfont\fontsize{15}{18}\selectfont{#1} \\ \vspace*{-9pt}\Hrule}[\vspace{18pt}] %

\titlespacing{\chapter}{0pt}{12pt}{6pt}[0pt] %
\renewcommand{\thechapter}{\arabic{chapter}} % make-up of the numbering

% Section box here

\newtcolorbox{sectionbox}[2][]{boxsep=4.2pt,boxrule=1.2pt,arc=3pt,outer arc=3.2pt,width=\linewidth,
coltitle=white,colbacktitle=ThemeColour,after=\hfill,colframe=black,colback=DarkGrey,title={#2},fonttitle=\bfseries,#1}

\titleformat{\section} %
  {\normalfont\bfseries\itshape\fontsize{12}{14}\selectfont}
  {}{0pt}
{\begin{sectionbox}
{\fontsize{14}{16}\selectfont{Section\hspace{5.6pt}\thetitle}}{#1}
\end{sectionbox}}

\titlespacing{\section}{0pt}{10pt}{6pt}[0pt] % 0, 10, 6, 0
\renewcommand{\thesection}{\arabic{section}} % make-up of number
%
\def\figtab{\kern 0.8pt} % layout of fig/table numbering - good 22_02_2014

\captionsetup[figure]{labelfont=normal,labelsep=space,textfont=normal}
\captionsetup[subfigure]{labelfont=normal,labelsep=space,font=normal,singlelinecheck=on}

\addto\captionsenglish{ % this seems to work
\renewcommand{\figurename}{Fig\hspace{0.7pt}.} %
\renewcommand{\thefigure}{\thechapter{\figtab.\figtab}\arabic{figure}} % good
\renewcommand{\thesubfigure}{[\hspace{0.6pt}\alph{subfigure}\hspace{0.6pt}]} % ACTIVE, deliberate [ ] introduced, ( ) already present
}
%
\begin{document}

\pagestyle{plain}

\chapter{Introduction to number}

\vspace{4pt}
\section{Section one - formatting and tcolorbox set up on lines 49 to 57}

\section{Section two - "(m)" and "(n)" sub-fig labels are main problem}

\begin{figure}[htp]\center %
\begin{tcolorbox}
[width=98.0mm,fit to height=45.0mm,colframe=DarkRed,colback=LightCream,top=3pt,bottom=4.2pt, left=4pt, right=4pt,arc=2pt,boxrule=1.2pt]
  \begin{subfigure}{45mm} %
        \centering
    \includegraphics[scale=0.40]{example-image-a} %
    \caption{\;label "m" should be "a"}
        \label{fig:inequalityregion}
  \end{subfigure}\hspace{6pt}
  \begin{subfigure}{45mm}
        \centering
        \includegraphics[scale=0.40]{example-image-b}
        \caption{\;label "n" should be "b"}
        \label{fig:inequalityproof}
    \end{subfigure}
\end{tcolorbox}
\caption{\hspace{5.6pt}Sub-figure labels should be (a) and (b) - not (m) and (n)}
        \label{fig:multiplyingbyone}
\end{figure}

\end{document}

答案1

问题在于fit to height=45.0mm中使用的选项tcolorbox。该选项fit to height在排版出最佳结果之前会执行几个装箱步骤;在每个步骤中,计数器subfigure都会逐步增加,从而产生不想要的编号。删除此选项。

您的代码还存在一些其他问题:例如,

\renewcommand{\thesubfigure}{[\hspace{0.6pt}\alph{subfigure}\hspace{0.6pt}]} 

最好使用caption软件包提供的功能,定义一种新的标题格式(有关详细信息,请参阅软件包文档)。不要\center使用 ,而要使用\centering

相关内容