First: you have included floatrow
twice.
You can use ffigbox
inside a figure
environment:
\documentclass[a4paper,12pt]{scrartcl}
\usepackage{tikz,floatrow,hyperref}
\usepackage[hypcap=true]{caption}
\usepackage[hypcap=true]{subcaption}
\usepackage[all]{hypcap} %link to top of figure
% caption format
\captionsetup{format=hang,labelsep=space,indention=-2cm,labelfont=bf,width=.9\textwidth,skip=.5\baselineskip}
\captionsetup[sub]{labelfont=bf,labelsep=period,subrefformat=simple,labelformat=simple}
%center both ?
\floatsetup[figure]{objectset=centering}
\floatsetup[subfigure]{objectset=centering}
\begin{document}
\begin{figure}
\begin{tikzpicture}
\draw[fill=blue] (0,0) rectangle (4,4);
\end{tikzpicture}
\caption{First}
\end{figure}
\ffigbox[\FBwidth]{%
\begin{subfloatrow}
\ffigbox[0.5\textwidth]{%
\begin{tikzpicture}
\draw[fill=blue] (0,0) rectangle (4,4);
\end{tikzpicture}}{\caption{First}}
\ffigbox[0.5\textwidth]{%
\begin{tikzpicture}
\draw[fill=blue] (0,0) rectangle (5,5);
\end{tikzpicture}}{\caption{Second}}%
\end{subfloatrow}%
}{\caption{Describing both subfigures}}
\end{document}
Allergy notice: some parts of the above code might be nuts (or needless)
To answer your questions in comments (from the floatrow
package manual):
Another command which creates figures - \ffigbox
- puts caption below contents. The default width of caption equals to the width of text. [...] a float box, created by the
\ffigbox
command looks similar to the plain figure environment. But if you set, for example, the option [\FBwidth]
[...] you’ll get a caption width equal to the width of picture [...]
There are similar boxes where the caption is placed elsewhere (eg: \fcapside
places it beside the figure). As far as I know \floatsetup[subfigure]{objectset=centering}
doesn't effect the subfigure
environment of the subcaption
package but these boxes.
If you hate this stack you can hope that is only my overcomplicated solution and there are better ones. Or you may want to try xpatch
(or etoolbox
) to do the "global" subcaption centering stuff (instead of using floatrow
for that) as a "hail mary"...
\usepackage{xpatch}
\makeatletter
% \subcaption@minipage is the last macro call in \subfigure (and \begin{subfigure})
\xapptocmd{\subcaption@minipage}{\centering}{}{}
\makeatother
You don't need caption
or subcaption
, if you don't want any special label for the graphics.
\documentclass[final]{IEEEtran}
\usepackage{kantlipsum} %<- For dummy text
\usepackage{mwe} %<- For dummy images
\title{The research}
\author{The researcher}
\begin{document}
\maketitle
\begin{abstract}
\kant[1]
\end{abstract}
\kant[1-4]
\begin{figure}
\centering
\raisebox{-.5\height}{%
\includegraphics[height=4cm,width=3cm]{example-image-a}%
}\qquad
\raisebox{-.5\height}{%
\includegraphics[height=2cm,width=3cm]{example-image-b}%
}
\caption{The proper caption}
\label{figab}
\end{figure}
\end{document}
I imposed height and width to the images in order to emulate your real situation, where the two pictures have different heights.
With \raisebox{-.5\height}
we shift vertically the reference point (usually at the bottom) for each picture, so they come out automatically center aligned. With \qquad
I add some separation; leave it out (changing it into a %
) if you don't want any space.
Best Answer
The techniques explained at the linked answer work with
subfigure
package also.You can also use
adjustbox
package.Here the content will be resized only if it exceeds
1.2\linewidth
.adjustbox
also provides many other goodies. For details, refer to its documentation.PS.
subfigure
is deprecated and it is better to change over tosubcation
orsubfig
.