2

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}

2
  • 1
    subfigure is a deprecated package. Use the subfig or subcaption packages. The \label without caption is also not useful – user31729 Jun 6 '16 at 11:21
  • 2
    Just noticed: svg loads subfig, so subcaption does fail then! – user31729 Jun 6 '16 at 11:40
2

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

13
  • Hey, thanks for your answer! It looks nice, but when I try to use a .svg file as filename I get the error 'LaTeX Error: Unknown graphics extension: .svg.', even though the svg package is loaded..any idea why? – sequence_hard Jun 6 '16 at 12:00
  • I used \includegraphics instead of \includesvg because I was too lazy to generate some .svg files – user31729 Jun 6 '16 at 12:01
  • 2
    @sequence_hard \includesvg from the svg package requires inkscape, which unfortunately isn't available on Overleaf's servers at present. Sorry about that! As an alternative, you can export the .svg to .pdf (which would still be high-res) on your own machine, and then upload the .pdf to your Overleaf project. – imnothere Jun 6 '16 at 12:24
  • 1
    Ah, so that's the problem! Then I will convert everything and make subfigures from pdf. Thank you! – sequence_hard Jun 6 '16 at 12:26
  • 1
    @sequence_hard: Yes, in this case you can use subcaptions package as well – user31729 Jun 6 '16 at 13:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.