I'm using the Frontier template to insert figures, but I keep coming up with errors. I do upload caption and subcaption packages. only one of the figures can show up and no matter how I adjust the size of them, I still fail to inset them.
The errors include:
Not in outer par mode. Illegal measure of unit (this appears at first \begin(subfigure)
Missing number, treated as zero. Illegal measure of unit ( this appears at all other \begin(subfigure)
The following is my code:
\documentclass[utf8]{frontiersHLTH} % for Health articles
\usepackage{url,hyperref,lineno,microtype,caption,subcaption}
\usepackage[onehalfspacing]{setspace}
\usepackage{fixltx2e}
\usepackage{amsmath}
\usepackage{tabularx, booktabs, ragged2e}
\usepackage{adjustbox}
\usepackage{threeparttable}
\usepackage{graphicx}
\usepackage{array}
\linenumbers
\begin{document}
\begin{figure}
\centering
\begin{subfigure}[hbt!]{0.33\textwidth}
\centering
\includegraphics[width=0.2\textwidth]{figure2 11.jpg}
\caption{11}
\end{subfigure}
\hfill
\begin{subfigure}[hbt!]{0.33\textwidth}
\centering
\includegraphics[width=0.2\textwidth]{figure2 12.jpg}
\caption{12}
\end{subfigure}
\hfill
\begin{subfigure}[hbt!]{0.33\textwidth}
\centering
\includegraphics[width=0.2\textwidth]{figure2 13.jpg}
\caption{13}
\end{subfigure}
\hfill
\begin{subfigure}[hbt!]{0.3\textwidth}
\centering
\includegraphics[width=0.2\textwidth]{figure2 21.jpg}
\caption{21}
\end{subfigure}
\begin{subfigure}[hbt!]{0.3\textwidth}
\centering
\includegraphics[width=0.2\textwidth]{figure2 22.jpg}
\caption{22}
\end{subfigure}
\begin{subfigure}[hbt!]{0.3\textwidth}
\centering
\includegraphics[width=0.2\textwidth]{figure2 23.jpg}
\caption{23}
\end{subfigure}
\caption{Caption}
\label{fig:my_label}
\end{figure}
\end{document}
I'd really appreciate if anyone can help me fix this problem! Thanks!!
Best Answer
Your code contains various inaccuracies which, taken together, result in the unwanted layout. Take a look at the following modifications. Observe the uses of
%
after selected instances of\end{subfigure}
, the uses of\hfill
, and the purging of all\centering
instructions as they do nothing useful.Incidentally, when I try to recompile the code shown below on Overleaf, with the
frontiersHLTH
document class instead ofarticle
, I get an error message, about the filefrontiersHLTH.cls
not being found. That's why I usearticle
for the example at hand.