\includestandalone and subcaption package

Create issue
Issue #38 closed
maybeec created an issue

I am trying to import a standalone tikz picture like this:

main.tex:

\documentclass[12pt,a4paper]{book}

\usepackage{caption}
\usepackage{subcaption}
\usepackage{standalone}

\begin{document}

\begin{figure}
    \begin{subfigure}
        \includestandalone[mode=build]{inc-tikz}
    \end{subfigure}
\end{figure}

\end{document}

inc-tikz.tex

\documentclass{standalone}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
    \node {whatever};
\end{tikzpicture}

\end{document}

and get the following errors, which I also get in my original document:

! Missing number, treated as zero.
<to be read again> 
                   \let 
l.11        \includestandalone
                         [mode=build]{inc-tikz}

! Illegal unit of measure (pt inserted).
<to be read again> 
                   \let 
l.11        \includestandalone
                         [mode=build]{inc-tikz}

Are standalone package and subcaption package not compatible or do I miss anything?

Comments (3)

  1. Martin Scharrer repo owner

    The error is because you didn't added the mandatory argument to {subfigure}. It therefore takes \includestandalone as length which causes an error.

    Correct usage is:

    \documentclass[12pt,a4paper]{book}
    
    \usepackage{caption}
    \usepackage{subcaption}
    \usepackage{standalone}
    
    \begin{document}
    
    \begin{figure}
        \begin{subfigure}{.5\textwidth}
            \includestandalone[mode=build]{inc-tikz}
        \end{subfigure}
    \end{figure}
    
    \end{document}
    
  2. Log in to comment