4

Is there a way to use the svg package when the subcaption package is included as well? The svg package uses the subfig package, which apparently leads to conflict. But it seems to be common sense that the subcaption package is prefered over the subfig package.

2

In this answer the solution is to suppress the load of the subfig package by this

\expandafter\def\csname ver@subfig.sty\endcsname{}

command. Unfortunately, this works for me only until TeX Live 2015.

3

I sent an email to the current maintainer of the svg package, and he replied with the following solution:

\RequirePackage{scrlfile}
\PreventPackageFromLoading{subfig}
\documentclass{article}
\usepackage{subcaption}
\usepackage{svg}
\usepackage{hyperref}
\begin{document}
test
\end{document}

Works like charm on MiKTeX on windows, I haven't tried another OS or TeX distribution. A new version of the svg package is likely to be released very soon, in which this issue will be fixed.

  • This works for me with TeX Live 2016/Debian. Thank you. – Roos Nov 11 '16 at 9:17
2

Extremely crude workaround:

Copy the svg.sty file to your project folder and simply comment out or remove the following line (line #40):

\@ifpackageloaded{subfig}{}{\RequirePackage{subfig}}%

So far, this doesn't produce any errors and correctly compiles svg files. Also works when I \includesvg the svg image files inside a subcaption environment.

0

After about 1 hour of work around I found the solution in the official documentation

Package subcaption : https://mirror.hmc.edu/ctan/macros/latex/contrib/caption/subcaption.pdf

Please note: This package is incompatible with the subfigure and subfig packages.

The following latex code for subfigures. But before that you need to include

\usepackage{subcaption} 

\begin{figure}
    \begin{minipage}[b]{.5\linewidth}
        \centering
        \includegraphics[]{fig-1.pdf}
        \subcaption{A subfigure}\label{fig:1a}
    \end{minipage}%
    \begin{minipage}[b]{.5\linewidth}
        \centering
            \includegraphics[]{fig-2.pdf}
        \subcaption{Another subfigure}\label{fig:1b}
    \end{minipage}
    \caption{A figure}\label{fig:1}
\end{figure}

If you happened to include some package like the following

\usepackage{subfigure}
\usepackage{subfig}

All you need is to comment the above; subfigure and subfig are not compatible with subcaption. Removing them will solve your problem.

   %\usepackage{subfigure}
    %\usepackage{subfig}
  • Can you add a complete answer which shown as have you solved the problem? – Sebastiano Feb 22 at 8:13
  • @Sebastiano, the problem is that you cannot have subcaption package together with subfigure and subfig . If you want to use subcaption package, you need to remove the other two. This will solve the problem. – Bernard Nongpoh Feb 22 at 8:17

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.