1

I'm trying to generate a figure that is 19.05cm wide (according to submission specifications). I'm defining the width of the standalone document using the varwidth. I'm also using the subcaption package. When I include the varwidth option, subcaptions of the figures are not centered and they lose some of the format (for instance, (a) becomes a:).

Any ideas on how to solve this problem? I haven't figured out another way to generate a standalone document that is 19.05cm wide and contains my figures in the right size.

\documentclass[preview, varwidth=19.05cm]{standalone}

\usepackage[utf8]{inputenc}
\usepackage{amsmath, amssymb}
\usepackage{graphicx}
\usepackage{subcaption}

% Matplotlib2TikZ
\usepackage{pgfplots}
\pgfplotsset{compat=1.14}

\begin{document}
\begin{figure}
    \captionsetup[subfigure]{justification=centering}
    \centering

    \begin{subfigure}[t]{8.8cm}
        \centering
        \input{Fig2a.tex}\label{Fig2a}
        \caption{Task A: Ground truth}
    \end{subfigure}
    ~
    \begin{subfigure}[t]{8.8cm}
        \centering
        \input{Fig2b.tex}
        \caption{Task B: Ground truth}
        \label{Fig2b}
    \end{subfigure}

    \begin{subfigure}[t]{8.8cm}    
        \input{Fig2c.tex}
        \vspace{-0.5em}
        \caption{Task A: Real-time annotations}
        \label{Fig2c}
    \end{subfigure}
    ~
    \begin{subfigure}[t]{8.8cm}
        \input{Fig2d.tex}
        \vspace{-0.5em}
        \caption{Task B: Real-time annotations}
        \label{Fig2d}
    \end{subfigure}
\end{figure}
\end{document}

I am including the output image. I'm generating all the figures using PGF plots, and the sizes are:

height=\textwidth,
width=0.45\textwidth,

Finally, I have included the \fboxs in order to debug (make sure that my subfigures contain the figures I'm calling, according to this post).

output

  • 1
    Welcome to TeX.SX!. To make your code to a minimal working example (MWE) it would be useful to look at the part about Images, since we don't have the inputed tex-files and it's just about the inserted imagesize. – dexteritas Jul 28 '17 at 18:57
  • Well the varwidth option adds a varwidth environment (from the , you guessed it, varwidth package) which is actually a minipage with a variable width. The length given by varwidth=... is the maximum width. – Martin Scharrer Dec 1 '17 at 8:15
  • Also note, that floating environments like figure or table are not really targeted by standalone. It is rather meant for the diagramms which are inside such environments. – Martin Scharrer Dec 1 '17 at 8:16
2

I figured out a way after posting the question. Instead of using varwidth, I do not use the option and instead create a minipage with the necessary width:

\documentclass[preview]{standalone}

\usepackage[utf8]{inputenc}
\usepackage{amsmath, amssymb}
\usepackage{graphicx}
\usepackage{subcaption}

% Matplotlib2TikZ
\usepackage{pgfplots}
\pgfplotsset{compat=1.14}

\begin{document}
\begin{minipage}{19.05cm}
\begin{figure}
    \begin{subfigure}[t]{8.8cm}
    \centering
    \input{Fig2a.tex}\label{Fig2a}
    \caption{Task A: Ground truth}
\end{subfigure}
~
\begin{subfigure}[t]{8.8cm}
    \centering
    \input{Fig2b.tex}
    \caption{Task B: Ground truth}
    \label{Fig2b}
\end{subfigure}

\begin{subfigure}[t]{8.8cm}    
    \input{Fig2c.tex}
    \vspace{-0.5em}
    \caption{Task A: Real-time annotations}
    \label{Fig2c}
\end{subfigure}
~
\begin{subfigure}[t]{8.8cm}
    \input{Fig2d.tex}
    \vspace{-0.5em}
    \caption{Task B: Real-time annotations}
 \label{Fig2d}
\end{subfigure}

\end{figure}
\end{minipage}
\end{document}

This generates an image with correct subcaptions: correct subcaptions

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.