I want to create a page in overleaf contains 4 sub-sub-figures, each figure has a sub-sub-caption ?
each two sub-sub-figures have its own sub-caption, as illustrated in the bellow picture:
Create a picture composed of 4 sub-sub-figures with 4 sub-sub-captions and 2 sub-captions
captionssubcaptionsubfloats
Related Solutions
You can set the length \belowcaptionskip
(default value 0pt) as you need it. Either do this locally inside the concerned figure environment as shown below or globally in the preamble.
\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[font=small,labelfont=bf,tableposition=top]{caption}
\usepackage[font=footnotesize]{subcaption}
\begin{document}
\begin{figure}[!ht]
\setlength{\belowcaptionskip}{5pt}
\centering
\begin{subfigure}[b]{0.75\textwidth}
\rule{\linewidth}{0.5\linewidth}
\caption{First sub-figure}\label{fig:first}
\end{subfigure}
\begin{subfigure}[b]{0.75\textwidth}
\rule{\linewidth}{0.5\linewidth}
\caption{Second sub-figure}\label{fig:second}
\end{subfigure}
\caption{Two dummy sub-figures}\label{dummy}
\end{figure}
\end{document}
The caption manual has the details.
The following should be right up your allow. It's achieved with the aid of subcaption
and some manual float management:
\documentclass{article}
\usepackage{verbatimbox}
\usepackage[T1]{fontenc}
\usepackage{fancyvrb,listings,caption}
\usepackage[labelformat=simple]{subcaption}
\usepackage[scaled=.73]{beramono}
\fvset{baselinestretch=0.94}
\parindent=0pt
\parskip = 6pt
\makeatletter
\AtBeginDocument{\DeclareCaptionSubType{lstlisting}
\renewcommand{\p@sublstlisting}{\thelstlisting}
\renewcommand{\thesublstlisting}{(\alph{sublstlisting})}
}
\makeatother
% "define" Scala
\lstdefinelanguage{scala}{
morekeywords={abstract,case,catch,class,def,%
do,else,extends,false,final,finally,%
for,if,implicit,import,match,mixin,%
new,null,object,override,package,%
private,protected,requires,return,sealed,%
super,this,throw,trait,true,try,%
type,val,var,while,with,yield,then}, % we use `then` in the pseudocode
otherkeywords={=>,<-,<\%,<:,>:,\#,@},
sensitive=true,
morecomment=[l]{//},
morecomment=[n]{/*}{*/},
morestring=[b]",
morestring=[b]',
morestring=[b]"""
}
% activate the language and predefine settings
\lstset{
basicstyle=\linespread{0.94}\ttfamily,%
language=scala,%
commentstyle=\itshape,%
keywordstyle=\bfseries,%
fancyvrb=true,%
mathescape=true,% for pseudocode
captionpos=b, % captions at the bottom
}
\newsavebox{\verbsavebox}
\begin{document}
In Fig.~\ref{fig:label} versus Listings~\ref{lst:label1} and \ref{lst:label2}.
\begin{figure}
Empty
\caption{fig}\label{fig:label}
\end{figure}
\begin{figure} % [htp]
% Let's make this an lstlisting, not a figure...
\makeatletter\def\@captype{lstlisting}\makeatother
\begin{lrbox}{\verbsavebox}
\begin{lstlisting}[xrightmargin=.6667\linewidth]
trait Sys[S <: Sys[S]] {
type ID <: Ident[S#Tx]
type Tx
}
trait Muta[S <: Sys[S]] {
def id: S#ID
// well defined:
def dispose(tx: S#Tx) =
id.dispose(tx)
}
trait Ident[Tx] {
def dispose(tx: Tx): Unit
}
\end{lstlisting}
\end{lrbox}
\subcaptionbox{list1\label{lst:label1}}{\usebox{\verbsavebox}}\hfill%
\begin{lrbox}{\verbsavebox}
\begin{lstlisting}[xrightmargin=.6667\linewidth]
trait Sys {
type ID <: Ident[Tx]
type Tx
}
trait Muta[S <: Sys] {
def id: S#ID
// incompatible type:
def dispose(tx: S#Tx) =
id.dispose(tx)
}
\end{lstlisting}
\end{lrbox}
\subcaptionbox{list2\label{lst:label2}}{\usebox{\verbsavebox}}\hfill%
\begin{lrbox}{\verbsavebox}
\begin{lstlisting}[xrightmargin=.6667\linewidth]
trait Sys {
type ID <: Ident[Tx]
type Tx
}
trait Muta[S <: Sys] {
// evidence required:
val s: S
def id: s.ID
// well defined:
def dispose(tx: s.Tx) =
id.dispose(tx)
}
\end{lstlisting}
\end{lrbox}
\subcaptionbox{list3\label{lst:label3}}{\usebox{\verbsavebox}}
\caption{Total caption\label{lst:total}}
\end{figure}
\end{document}
Each of the listings are set in a box \verbsavebox
of width .3333\linewidth
(by setting xrightmargin=.6667\linewidth
). These boxes, once set, are added using \subcaptionbox{<caption>}{\usebox{\verbsavebox}}
, where <caption>
includes both the caption and the \label
.
Immediately inside the figure
environment, we strategically update the \@captype
to be lstlisting
. This fools TeX to think that it's dealing with a float called lstlisting
when you call \caption
. This is necessary since the \subcaption
s are set before the main \caption
, which requires \p@lstlisting
(the parent counter associated with the subcounter sublstlisting
) to be set correctly. This is all related to the functionality of the subcaption
package.
The subcaptions are defined \AtBeginDocument
, which is to coincide with the float definitions of listings
, which is done at the same time. subcaption
requires a float to exist before it allows one to define subcaptions for it.
Best Answer
There are a lot of ways to achieve this. This is a example using
subfig
package: