4

MWE %

\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}
2
  • The problem is fit to height=45.0mm. The option fit to height performs several boxing steps before typesetting the best result; in each of those steps the subfigure counter gets stepped and that produces the undesired numbering. Commented Sep 24, 2015 at 14:16
  • How on Earth is a user supposed to figure that out?
    – keith77777
    Commented Sep 24, 2015 at 14:28

1 Answer 1

5

The problem is the fit to height=45.0mm option used in the tcolorbox. The option fit to height performs several boxing steps before typesetting the best result; in each of those steps the subfigure counter gets stepped and that produces the undesired numbering. Remove this option.

There are some other issues with your code: for example, this

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

would be better done using the features provided by the caption package, defining a new caption format (refer to the package documentation for details). Instead of \center, use \centering.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .