1

I'm having trouble reducing the size between the subcaptions and their figures when adding the figures through tikz. I tried a negative \vspace as well as setting (or changing?) the \captionsetup{skip=...} according to this answer but nothing seems to work. Any help is very appreciated :)

enter image description here

\documentclass{scrreprt}
\usepackage{subfig}
\usepackage{graphicx}
\usepackage{tikz}
\newcommand{\subaxeswest}[5]{
\hspace{-25pt}
\subfloat[#5]{%
\begin{tikzpicture}
    \node (image) at (0,0) [inner sep=6pt]{\includegraphics[width=#1\textwidth]{#2}};
    \draw [->] (image.south west) -- ++(0.5,0) node[right]{\footnotesize #3};
    \draw [->] (image.south west) -- ++(0,0.5) node[above]{\footnotesize #4};
\end{tikzpicture}
\captionsetup{skip=-10pt} % this doesn't have any effect at all??
\vspace{-10pt}            % this neither
}}
\begin{document}
    \begin{figure}[h!]
        \centering
        \subaxeswest{0.45}{example-image-a}{y}{x}{caption one}
        \quad
        \subaxeswest{0.45}{example-image-b}{y}{z}{caption two}
        \caption{Foo}
    \end{figure}
\end{document}
2

In your preamble, you have to use captionsetup command for subfloat.

\documentclass{scrreprt}
\usepackage{subfig}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{positioning,calc}
\newcommand{\subaxeswest}[5]{
\hspace{-25pt}
\captionsetup[subfloat]{captionskip=-15pt}
\subfloat[#5]{%
\begin{tikzpicture}
    \node (image) at (0,0) [inner sep=6pt]{\includegraphics[width=#1\textwidth]{#2}};
      \draw [->] (image.south west) --++ (0.5,0) node[right]{\footnotesize #3};
    \draw [->] (image.south west) --++ (0,0.5) node[above]{\footnotesize #4};
\end{tikzpicture}
}}
\begin{document}
    \begin{figure}[h!]
        \centering
        \subaxeswest{0.45}{example-image-a}{y}{x}{caption one}
        \quad
        \subaxeswest{0.45}{example-image-b}{y}{z}{caption two}
         \caption{Foo}
    \end{figure}

     \begin{figure}[h!]
     \subfloat[First sub-figure\label{subfig-1:dummy}]{%
       \includegraphics[width=0.45\textwidth]{example-image-a}
     }
     \quad
     \subfloat[First sub-figure\label{subfig-2:dummy}]{%
       \includegraphics[width=0.45\textwidth]{example-image-b}
     }
     \caption{Baz}
     \label{fig:dummy}
   \end{figure}
\end{document}

enter image description here

  • I don't want it for all the pictures, just the ones with the extra axes. – Superuser27 Mar 20 at 23:05
  • @Superuser27, If I understand your question correctly, I have edit my answer. – ferahfeza Mar 21 at 9:40
  • Mmh no, the axes are fine where I have them, but I have some pictures with and some without axes. I want only the ones with axes to have the captions closer to the pictures. With your first solution all subfigures' captions are moved, how can I move only the ones with axes? – Superuser27 Mar 21 at 11:43
  • 1
    @Superuser27, I think, I understood right now :-) – ferahfeza Mar 21 at 12:01

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.