4

I have a single image below and I would like to put a subcaption for each of the image in it. Only for the first row. The way I am doing it is not good because you can see that the subcaption for each image is not aligned correctly.

I was hoping someone could suggest a solution. Below is my code and the resulting figure. To make it easier, it does not need to be in a subcaption.

    \begin{figure}
\captionsetup[subfigure]{labelformat=empty,position=top}
    \centering
    \subfloat[$\alpha=0$ \ \ \  $\alpha=1$ \ \ \ \ $\alpha=2$ \ \ \ $\alpha=3$ \ \ \ \ $\alpha=4$ \ \ \ \ $\alpha=5$ \ \ \ \ $\alpha=6$ \ \ \  $\alpha=7$ \ \ \ \ $\alpha=8$ \ \ \ \ $\alpha=9$ \ \ \ $\alpha=10$ \ ]{{\includegraphics[width=\textwidth]{latent/latent-interpolation.png} }}
    \\
    \caption{Interpolating between random pairs of latent vectors according to $v = v_1 + (v_2 - v_1) \times \alpha$.}
    \label{fig:interpolate-latent}
\end{figure}

enter image description here

EDIT: So i tried adding a table before the image but I have not been able to reduce to spacing. Adding a negative baseline skips does not work the way i would like it to

\begin{figure}[h]
\captionsetup[subfigure]{labelformat=empty,position=top}
    \centering
    {\scriptsize
    \begin{tabu} to \textwidth { XXXXXXXXXX }
    $x_1$ & $x_2$ & $x_3$ & $x_4$ & $x_5$ & $x_6$ & $x_7$ & $x_8$ & $x_9$ & $x_{10}$
    \end{tabu}
    } \vspace{-2\baselineskip}
    \subfloat[]{{\includegraphics[width=\textwidth]{latent/latent-interpolation.png} }}
    \\
    \caption{Interpolating between random pairs of latent vectors according to $v = v_1 + (v_2 - v_1) \times \alpha$.}
    \label{fig:interpolate-latent}
\end{figure}

enter image description here

  • 1
    do you need real subcaption, which can be referenced? or is simple text a=0 sufficient? centering is simple achievable, if you can broke your image in subimages. – Zarko Jan 12 '18 at 0:16
  • A simple text a=0 is sufficient. It does not need to be in a subcaption. I would prefer not to break my image into subimages because I have too many more of those images. – Kong Jan 12 '18 at 0:18
3

if all sub-images in your image have equal width and distances between them are also equal, than this might help:

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{tabularx}

\begin{document}
    \begin{figure}
    \setlength\tabcolsep{0pt}
\begin{tabularx}{\linewidth}{*{11}{>{\centering\arraybackslash\footnotesize $}X<{$}}}
\alpha=0 & \alpha=1 & \alpha=2 & \alpha=3 & \alpha=4 & \alpha=5 
         & \alpha=6 & \alpha=7 & \alpha=8 & \alpha=9 & \alpha=10    \\
\multicolumn{11}{c}{\includegraphics[width=\textwidth]{latent/latent-interpolation.png} }
\end{tabularx}
\caption{Interpolating between random pairs of latent vectors according to $v = v_1 + (v_2 - v_1) \times \alpha$.}
\label{fig:interpolate-latent}
    \end{figure}
\end{document}

since i haven't your image, i emulate it with demo option of package graphicx. so the final test, if this work for you i had left to you.

enter image description here

edit: from your comments i conclude, that you actually looking for this:

enter image description here

which is obtained by:

\documentclass{article}
\usepackage[margin=20mm]{geometry}% added, i don't now if it is needed
\usepackage[demo]{graphicx}
\usepackage{tabularx}
\usepackage{subfig}

\begin{document}
    \begin{figure}
\subfloat[ sub caption text]{% <--- need to be here
    \setlength\tabcolsep{0pt}% <--- need to be here
\begin{tabularx}{\linewidth}{*{11}{>{\centering\arraybackslash\footnotesize$}X<{$}}}
\alpha=0 & \alpha=1 & \alpha=2 & \alpha=3 & \alpha=4 & \alpha=5 
         & \alpha=6 & \alpha=7 & \alpha=8 & \alpha=9 & \alpha=10    \\
\multicolumn{11}{c}{\includegraphics[width=\textwidth]{latent/latent-interpolation.png} }
\end{tabularx}}

\subfloat[ sub caption text]{\includegraphics[width=\textwidth]{latent/latent-interpolation.png}}
\caption{Interpolating between random pairs of latent vectors according to $v = v_1 + (v_2 - v_1) \times \alpha$.}
\label{fig:interpolate-latent}
    \end{figure}
\end{document}
  • what if i need the sub caption for the image – Kong Jan 12 '18 at 0:56
  • i like your solution but i need my subfloat subcaption – Kong Jan 12 '18 at 1:07
  • 1
    well, first you say, that you don't need subcaptions. honestly, i don't see any reason for this. if you persist, you can replace in first table row with \subfloat[$\alpha=0$]{} in each column, however, then probably the text will be broken into two lines due to lack of available space. to make any serious test you need first extend your code sniped to complete small document. – Zarko Jan 12 '18 at 1:11
  • 1
    columns are already in math mode (see $ in column definition), so it is sufficient to wrote x_0. – Zarko Jan 12 '18 at 1:21
  • 1
    @kong, see edit of my answer. i add example of use subfloat as i understood from yours comments. – Zarko Jan 12 '18 at 1:30

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.