[Tex/LaTex] Create Figure with subfigures from .svg files

graphicsoverleafsubfloatssvg

I am trying to create a number of figures in Overleaf which consist of several subpictures. To get highly resoluted pictures, I have saved them in .svg format. I have read different posts and learned that the svg package utilizes the subfigure (or subfig?) package to achieve this. I have tried to create my images in different ways, nothing really works. I have also read that there are workarounds using inkscape, but those seem outdated.. What code can I use in LaTeX to achieve what I want?

One of the versions I have tried is the following:

\documentclass{article}
\usepackage{svg}
\usepackage{subfigure}

\begin{document}
\begin{figure}[H]
    \begin{subfigure}[t]{1\textwidth}
       \includesvg[width=\linewidth]{sul_trends.svg}
       \label{fig:a}
    \end{subfigure}
\end{figure}

But it produces an error: Missing number, treated as zero. <to be read again> } l.322 \begin{subfigure}[t]{1\textwidth}

Best Answer

Since svg loads subfig, which is in turn incompatible with subcaption,there's not left: Use \subfloat inside of a figure environment.

The subfigure package is obsolete and shouldn't be used any longer!

\documentclass{article}
\usepackage{graphicx}
\usepackage{svg}
\usepackage{subfig}

\begin{document}

\begin{figure}%
\centering
\subfloat[First.]{\includegraphics[scale=0.05]{sampleimage.jpg}}\qquad
\subfloat[Second.]{\includegraphics[scale=0.05]{sampleimage.jpg}}\qquad
\subfloat[Third.]{\includegraphics[width=0.25\textwidth]{sampleimage.jpg}}\qquad
\caption{Three sub-floats.}
\label{fig:a}
\end{figure}

\end{document}

enter image description here

Related Question