%% subcaptionlite.tex -- documentation for the subcaptionlite package
%%
%% Copyright (c) 2026 Munehiro Yamamoto <munepixyz@gmail.com>
%% License: LPPL 1.3c or later
%%
%% Build: pdflatex subcaptionlite.tex (twice)
\documentclass{article}
\usepackage[margin=28mm]{geometry}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{subcaptionlite}
\usepackage[colorlinks, allcolors=blue!50!black]{hyperref}
\usepackage[capitalise]{cleveref}
\newcommand*\sclversion{v1.0 (2026/10/26)}
\newcommand*\cs[1]{\texttt{\char`\\#1}}
\newcommand*\pkg[1]{\textsf{#1}}
\newcommand*\env[1]{\texttt{#1}}
\newcommand*\meta[1]{\textnormal{$\langle$\textit{#1}$\rangle$}}

\title{The \pkg{subcaptionlite} package\\
  \large Subfigures and subtables without the caption package}
\author{Munehiro Yamamoto\\
  \url{https://github.com/munepi/subcaptionlite}}
\date{\sclversion}

\begin{document}
\maketitle

\section{Introduction}

The \pkg{subcaption} package needs the \pkg{caption} package, which
redefines \cs{@makecaption} of the class.  Thus it cannot be used with
a class that has its own design of captions: loading it changes the
captions of the whole document.

The \pkg{subcaptionlite} package provides the \env{subfigure} and
\env{subtable} environments, \cs{subcaption}, \cs{subcaptionbox} and
\cs{subref} with the same syntax as \pkg{subcaption}, without touching
\cs{@makecaption} of the class.  \Cref{fig:example,tab:example} are
made with it.

\begin{figure}[htbp]
  \centering
  \begin{subfigure}{.3\linewidth}
    \centering\includegraphics[width=.9\linewidth]{example-image-a}
    \caption{The subfigure environment}\label{fig:example-a}
  \end{subfigure}\hfill
  \subcaptionbox{\cs{subcaptionbox} with a width\label{fig:example-b}}%
    [.3\linewidth]{\includegraphics[width=.9\linewidth]{example-image-b}}\hfill
  \subcaptionbox{\cs{subcaptionbox} without a width\label{fig:example-c}}{%
    \includegraphics[width=.25\linewidth]{example-image-c}}
  \caption{Three subfigures}\label{fig:example}
\end{figure}

\begin{table}[htbp]
  \centering
  \caption{Two subtables}\label{tab:example}
  \begin{subtable}[t]{.3\linewidth}
    \centering
    \caption{The first}\label{tab:example-a}
    \begin{tabular}{lr}\hline Item & Value\\\hline A & 1\\ B & 2\\\hline\end{tabular}
  \end{subtable}\hspace{2em}
  \begin{subtable}[t]{.3\linewidth}
    \centering
    \caption{The second}\label{tab:example-b}
    \begin{tabular}{lr}\hline Item & Value\\\hline C & 3\\ D & 4\\\hline\end{tabular}
  \end{subtable}
\end{table}

\paragraph{Supported formats/engines}
pdf\LaTeX, Xe\LaTeX, Lua\LaTeX{} (with or without Lua\TeX-ja),
p\LaTeX{} and up\LaTeX{} (with dvipdfmx).  The package requires
\LaTeX2e{} 2020-10-01 or later and loads \pkg{etoolbox}.

\section{Usage}

\begin{verbatim}
\usepackage{subcaptionlite}

\begin{figure}
  \centering
  \begin{subfigure}{.3\linewidth}
    \centering\includegraphics[width=.9\linewidth]{example-image-a}
    \caption{The subfigure environment}\label{fig:example-a}
  \end{subfigure}\hfill
  \subcaptionbox{\cs{subcaptionbox} with a width\label{fig:example-b}}%
    [.3\linewidth]{\includegraphics[width=.9\linewidth]{example-image-b}}\hfill
  \subcaptionbox{\cs{subcaptionbox} without a width\label{fig:example-c}}{%
    \includegraphics[width=.25\linewidth]{example-image-c}}
  \caption{Three subfigures}\label{fig:example}
\end{figure}

\begin{table}
  \centering
  \caption{Two subtables}\label{tab:example}
  \begin{subtable}[t]{.3\linewidth}
    \centering
    \caption{The first}\label{tab:example-a}
    \begin{tabular}{lr} ... \end{tabular}
  \end{subtable}\hspace{2em}
  \begin{subtable}[t]{.3\linewidth}
    \centering
    \caption{The second}\label{tab:example-b}
    \begin{tabular}{lr} ... \end{tabular}
  \end{subtable}
\end{table}
\end{verbatim}

\begin{description}
\item[\texttt{\char`\\begin\{subfigure\}[\meta{pos}]\{\meta{width}\}}, \texttt{\char`\\begin\{subtable\}[\meta{pos}]\{\meta{width}\}}]
  A \env{minipage} of \meta{width} (\meta{pos}: \texttt{b} by default,
  as in \pkg{subcaption}),
  inside which \cs{caption} and \cs{caption*} mean \cs{subcaption} and
  \cs{subcaption*}.  The subcaption is put where \cs{caption} is given:
  above the contents in \cref{tab:example}, where \texttt{[t]} aligns
  the subtables at the top.
\item[\texttt{\char`\\subcaption\{\meta{text}\}}, \texttt{\char`\\subcaption*\{\meta{text}\}}]
  A numbered or unnumbered subcaption, e.g.\ in a \env{minipage}.  It
  is centered and set in \cs{small}.  It is numbered with the counter
  of the float it is in: \texttt{subfigure} in a \env{figure},
  \texttt{subtable} in a \env{table}.
\item[\texttt{\char`\\subcaptionbox\{\meta{caption}\}[\meta{width}]\{\meta{contents}\}}]
  Puts \meta{contents} centered in a \env{minipage} of \meta{width},
  followed by \cs{subcaption}\texttt{\{\meta{caption}\}}.  Without
  \meta{width}, the natural width of \meta{contents} is used; with
  \meta{width}, \cs{linewidth} in \meta{contents} is \meta{width}.  If
  \meta{contents} is wider than \meta{width}, the \env{minipage} keeps
  \meta{width}.  Boxes are aligned at the bottom, and the subcaption
  is always below the contents.
\item[\texttt{\char`\\subref\{\meta{label}\}}, \texttt{\char`\\subref*\{\meta{label}\}}]
  Only the label of the subfigure or subtable, e.g.\ ``\subref{fig:example-a}''
  (\cs{subref*}: without a link with \pkg{hyperref}).  After a numbered
  subcaption, \cs{label}\texttt{\{\meta{label}\}} also writes the label
  \texttt{sub@\meta{label}}, as the \pkg{subcaption} package does.
\item[\texttt{\char`\\captionsetup[\meta{type}]\{\meta{options}\}}]
  Accepted and ignored, so that the settings for the \pkg{caption}
  package can be left in the document.
\end{description}

\paragraph{Numbering and references}
The counter \texttt{subfigure} is reset by \texttt{figure}, and
\texttt{subtable} by \texttt{table}.  \cs{thesubfigure} is
\texttt{(\cs{alph}\{subfigure\})} and \cs{p@subfigure} is \cs{thefigure}
(likewise for \texttt{subtable}), so that \cs{ref} gives
``\ref{fig:example-a}'' and ``\ref{tab:example-b}'', and \cs{Cref} of
\pkg{cleveref} gives ``\Cref{fig:example-b}'' and
``\Cref{tab:example-a}''.  With \pkg{hyperref}, each subfigure and
subtable has its own anchor (\cs{theHsubfigure}, \cs{theHsubtable}).

The \cs{caption} of the float may come after the subcaptions (as in
\cref{fig:example}) or before them (as in \cref{tab:example}).  When a
subcaption comes first, it steps the counter of the float in advance
and the \cs{caption} that follows does not step it again, as the
\pkg{subcaption} package does; without this, the subfigures would get
the number of the previous figure.  A float with subcaptions and no
\cs{caption} is numbered as well.

\section{Customization}

The following macros can be redefined in the class or in a local style
(\cs{makeatletter} is needed in the preamble of a document).

\begin{center}
\begin{tabular}{lp{.55\linewidth}}
  \hline
  Macro & Default\\
  \hline
  \cs{subcaption@font} & \cs{small}\\
  \cs{subcaption@sep}  & the space between the label and the text:
    \verb|\hspace{.5zw}| with p\TeX, \verb|.5\zw| with Lua\TeX-ja (or a
    class that defines \cs{zw}), \verb|.5em| otherwise\\
  \cs{subcaption@skip} & the space between the subfigure and its
    subcaption: \verb|\vskip.25\baselineskip|\\
  \hline
\end{tabular}
\end{center}

\noindent
The engine is checked when the subcaption is typeset, so Lua\TeX-ja may
be loaded after \pkg{subcaptionlite}.  The labels themselves are
\cs{thesubfigure} and \cs{thesubtable}.  For example,
\begin{verbatim}
\makeatletter
\renewcommand*\subcaption@font{\footnotesize\sffamily}
\renewcommand*\subcaption@sep{\enspace}
\makeatother
\renewcommand\thesubfigure{\alph{subfigure})}
\end{verbatim}

\section{Errors and limitations}

\begin{description}
\item[\texttt{\char`\\subcaption outside float}] \cs{subcaption} (or
  \cs{subcaptionbox}) is used outside a float.
\item[\texttt{Float type `\meta{type}' has no subcaptions}] \cs{subcaption}
  (or \cs{subcaptionbox}) is used in a float other than \env{figure}
  and \env{table}, e.g.\ one defined by \pkg{newfloat}.
\end{description}
\noindent
After either error, the subcaption is typeset without a number.

\begin{itemize}
\item Subcaptions are for figures and tables only.
\item \pkg{subcaptionlite} cannot be used together with the
  \pkg{caption} or \pkg{subcaption} package.
\end{itemize}

\section{Tests}

\verb|make test| compiles the test files (but \texttt{test-errors.tex})
twice with pdf\LaTeX,
Xe\LaTeX, Lua\LaTeX, p\LaTeX{} and up\LaTeX{} (+ dvipdfmx) and checks
the log.  The helpers in \texttt{test-common.tex} check the label that
\cs{label} would write, the references, the counters, the widths of
the boxes, the anchors of \pkg{hyperref}, and that \cs{@makecaption} of
the class is unchanged; the log must have \texttt{SCL-RESULT OK} and no
error or warning.  For \texttt{test-errors.tex}, the log must have the
expected error message.

\begin{center}
\begin{tabular}{lp{.6\linewidth}}
  \hline
  Test & What it covers\\
  \hline
  \texttt{test-basic.tex}    & \env{subfigure}, \env{subtable},
                               \cs{subcaption}, \cs{subcaptionbox}, the
                               caption of the float below/above the
                               subcaptions or none, \env{figure*},
                               \cs{ref}, \cs{subref}, the label
                               separator\\
  \texttt{test-hyperref.tex} & \texttt{test-basic.tex} with
                               \pkg{hyperref} (loaded after and before
                               the package) and \pkg{cleveref}\\
  \texttt{test-japanese.tex} & Japanese classes (ltjsarticle, jsarticle,
                               ujarticle), Lua\TeX-ja loaded after the
                               package\\
  \texttt{test-errors.tex}   & the error messages\\
  \hline
\end{tabular}
\end{center}

\section{History}

\begin{description}
\item[v1.0 (2026/10/26)] First public release.  Support every engine;
  add the \env{subtable} environment, subcaptions in tables and
  \cs{subref}; the default position of \env{subfigure} is \texttt{b},
  as in \pkg{subcaption}; fix the figure number when the caption of the figure
  comes before the subcaptions, and after a figure whose subfigures
  follow its caption.
\end{description}

\section{License}

This package is licensed under the conditions of the \LaTeX{} Project
Public License, either version~1.3c of this license or any later
version.

\medskip
\noindent
Copyright \copyright{} 2026 Munehiro Yamamoto

\end{document}
