\documentclass{article}
\usepackage{subcaption}
\usepackage[demo]{graphicx}
\usepackage{tabularx}
\begin{document}
\begin{table*}[h]
\renewcommand{\arraystretch}{1.2}
\begin{subtable}{0.22\textwidth}
\centering
\begin{tabular}{c}
\includegraphics[width=0.5\textwidth]{A.jpg}
\end{tabular}
\end{subtable}%
\begin{subtable}{0.75\textwidth}
\begin{tabular}{rp{27em}}
\textbf{SRC}: & caption1 \\
\textbf{Prototypa}: & caption2 \\
\textbf{MODEL2}: & caption3 \\
\textbf{MODEL3}: & caption4 \\
\textbf{MODEL4}: & caption5 \\
\end{tabular}
\end{subtable}
\caption{ Examples how the model behaves.}
\end{table*}
\end{document}
1 Answer
I don't think you need to use the subcaption
package at all for what you want to do. Instead, just put everything into a tabular
. I've used the technique described in this answer to centre the images and the labels vertically. I've made a counter to number the rows automatically. You'll need to reset the counter using \setcounter{imgcnt}{0}
before each table that you want to have counted. This can be made more automatic by hooking into the tabular
environment, but not if you have tabulars inside other tabulars as you have here. I've also simplified these tables from your examples, because it was unclear what you were trying to do with them.
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{linguex}
\usepackage{array}
\usepackage{etoolbox}
\newcounter{imgcnt}
\renewcommand{\theimgcnt}{\arabic{imgcnt})}
\newcommand{\tcount}{\stepcounter{imgcnt}\theimgcnt}
% Technique for centring image from https://tex.stackexchange.com/a/69747/2693
\newcommand{\tabincgr}[2][]{\ensuremath{\vcenter{\hbox{\includegraphics[#1]{#2}}}}}
\begin{document}
\begin{table*}
\renewcommand{\arraystretch}{1.2}
\begin{tabular}{m{.05\linewidth}p{.2\linewidth}p{.75\linewidth}}
\tcount &
\tabincgr[width=0.75\linewidth]{a.jpg}
&
\begin{tabular}{rp{27em}}
line 1\\
line 2\\
line 3\\
line 4
\end{tabular}
\\
\\
\tcount &
\tabincgr[width=0.5\linewidth]{b.jpg}
&
\begin{tabular}{rp{27em}}
line 1\\
line 2 \\
line 3\\
line 4
\end{tabular}
\\
\\
\tcount &
\tabincgr[width=0.75\linewidth]{c.jpg}
&
\begin{tabular}{rp{27em}}
line 1\\
line 2\\
line 3 \\
line 4
\end{tabular}
\end{tabular}
\caption{ Examples how the model behaves.}\label{tab:results:examples}
\end{table*}
\end{document}
-
thanks so much for your help. i was looking for something that's in the same line as the image and not at the bottom.– bluesCommented Mar 4, 2019 at 0:27
-
1@blues Then my comment is even more pertinent: how could anyone tell from your question what output you want? I suspect you don't need to use
\subcaption
at all then. Do you just need a number? Please edit your question to explain how you want the output to look. Commented Mar 4, 2019 at 1:13 -
so i was able to fix that but the problem is there's unwanted white space between the image and the caption column. how to get rid of that?– bluesCommented Mar 4, 2019 at 19:49
-
1@blues I must say you're really not helping here much. You've edited your question but the code is no longer compilable, and you still haven't explained what you actually want. I don't think you should be using
subcaption
at all for what you want. The spacing between the number and the image in my solution is determined by them{.05}
column specification. You can make thatm{1em}@{}
to make it smaller and remove the intercolumn space. Commented Mar 4, 2019 at 19:55 -
thanks so much for your solution first of all. I was trying to check if it was possible to remove the whitespace between the image and captions in the code posted.– bluesCommented Mar 4, 2019 at 20:05
{}
icon, or use Control-K. It's also helpful to add a bit of explanation of your problem in the question itself instead of just relying on the question title to convey your problem.subcaption
here. You can do this all with atabular
. But you still haven't explained what you want the output to look like.