I want to have the captions of my subfigures showing not only the current subfigure counter, but also the current figure number. So, for example, subfigure 1a
would have caption 1.a - Caption
. I managed to do that by changing the \thesubfigure
command, but then I ran into two problems (MWE follows):
If I put the figure caption below the figures (which I want to do), the figure counter is not yet updated when the subfigure captions are compiled. Changing the counter manually does not work, because in that case the Figure caption will have the wrong number. (And I don't want to change it twice every time)
When I reference a subfigure, the figure counter is repeated twice.
Regarding the second issue, I found this question and I imagine I could change something like the \p@subfigure
to show only \thesubfigure
, but that would give me a reference \thefigure.\thesubfigure
, while I would like to reference the subfigures as 1a
instead of 1.a
.
About the first issue, the closest I could find to a solution was this question, but I don't want to add every number manually, as I have many figures like this in my document. I know this has to do with what is explained here, but if I put the figure \caption
before the subfigures, the caption position moves to the top.
As an extra, any tips on how to change the labelsep
of subfigures caption to -
would be appreciated.
INFO: The way I'm adding the subfigure captions to each tikzpicture
was inspired by this question.
\documentclass{article}
\usepackage{fullpage}
\usepackage{amsbsy, amscd, amsfonts, amssymb, amstext, amsmath, mathtools, amsthm}
\usepackage{float, tikz, hyperref}
\usepackage{caption, subcaption}
\renewcommand{\thesubfigure}{\thefigure.\alph{subfigure}}
\captionsetup[subfigure]{labelfont=bf,labelformat=simple, labelsep=space}
\begin{document}
\begin{figure}[H]
\centering
\begin{tikzpicture}
\shade[ball color = gray!40, opacity = 0.4] (0,0) circle (2cm);
\draw (0,0) circle (2cm);
\node (c) at (-90:2) {};
\node[text width=6cm,align=center,anchor=north] at ([yshift=-5mm]c.south) {\captionof{subfigure}{Sphere \label{subfig1}}};
\end{tikzpicture}
%
\begin{tikzpicture}
\draw[black!80,thick,dashed] (2,2) circle (2cm);
\begin{scope}[shift={(2,2)}]
\node (c) at (-90:2) {};
\end{scope}
\node[text width=6cm,align=center,anchor=north] at ([yshift=-5mm]c.south) {\captionof{subfigure}{Above view \label{subfig2}}};
\end{tikzpicture}
\caption{A sphere in $\mathbb{R}^3$}
\label{fig}
\end{figure}
Reference: \ref{subfig1} . It should show 1a.
\end{document}