2

I'm trying to add a line (\hline or \hdashline) in between two rows in a 4 rows tabular, contained in a figure:

\documentclass[10pt,twocolumn,letterpaper]{article}

\usepackage{times}
\usepackage{epsfig}
\usepackage{graphicx}
\usepackage{capt-of}
\usepackage{varwidth}
\usepackage{floatrow}
\usepackage{float}
\usepackage{array}
\usepackage[export]{adjustbox}
\usepackage{subcaption}
\usepackage{cuted}
\usepackage[font=small,labelfont=bf,tableposition=top]{caption}
\usepackage{arydshln}

\begin{document}

%%%%%%%%% TITLE
\title{Title}

\author{1\\2\\{\tt\small 3}
\and4\\5\\{\tt\small 6}
}


\maketitle
\begin{figure*}

\centering
\hspace{-22pt}
% \setlength{\extrarowheight}{1em}
\setlength\tabcolsep{1.5pt}
\begin{tabular}{>{\footnotesize}p{1.2cm}cccccc}

Input          &\includegraphics[scale=0.2,valign=c]{example-image-a}    &\includegraphics[scale=0.2,valign=c]{example-image-a} 
&\includegraphics[scale=0.2,valign=c]{example-image-a}    &\includegraphics[scale=0.2,valign=c]{example-image-a}
&\includegraphics[scale=0.2,valign=c]{example-image-a}    &\includegraphics[scale=0.2,valign=c]{example-image-a}
\\
Output          &\includegraphics[scale=0.2,valign=c]{example-image-a}    &\includegraphics[scale=0.2,valign=c]{example-image-a} 
&\includegraphics[scale=0.2,valign=c]{example-image-a}    &\includegraphics[scale=0.2,valign=c]{example-image-a}
&\includegraphics[scale=0.2,valign=c]{example-image-a}    &\includegraphics[scale=0.2,valign=c]{example-image-a} \\ \hdashline
\rule{0pt}{10ex}
Input          &\includegraphics[scale=0.2,valign=c]{example-image-a}    &\includegraphics[scale=0.2,valign=c]{example-image-a} 
&\includegraphics[scale=0.2,valign=c]{example-image-a}    &\includegraphics[scale=0.2,valign=c]{example-image-a}
&\includegraphics[scale=0.2,valign=c]{example-image-a}    &\includegraphics[scale=0.2,valign=c]{example-image-a}
\\
Output          &\includegraphics[scale=0.2,valign=c]{example-image-a}    &\includegraphics[scale=0.2,valign=c]{example-image-a} 
&\includegraphics[scale=0.2,valign=c]{example-image-a}    &\includegraphics[scale=0.2,valign=c]{example-image-a}
&\includegraphics[scale=0.2,valign=c]{example-image-a}    &\includegraphics[scale=0.2,valign=c]{example-image-a}

\end{tabular}

\caption{More results} \label{figure:more results}

\end{figure*}

\end{document}


enter image description here

Is there a way to have the line in the middle of the gap? and not sticking to the top? Trying replacing \rule with \vspace, but it moved only the text (first column) without the figures. Thanks.

8
  • Please extend your sniplet to a full example, your choice of class and packages might be important
    – daleif
    Feb 12, 2021 at 10:14
  • 3
    Unrelated, don't use the center env to center inside a figure env, it introduces extra vertical spacing on top of what the figure env already provides. Normally we write \centering instead of \begin{center} and we drop \end{center}
    – daleif
    Feb 12, 2021 at 10:15
  • Edited, thanks.
    – DsCpp
    Feb 12, 2021 at 11:10
  • Unrelated 2: \tt and friends has been outdated since 1993! I also would not use the times or epsfig packages anymore
    – daleif
    Feb 12, 2021 at 11:11
  • 1
    You could load the booktabs package and try \addlinespace[1em] \hdashline \addlinespace[1em] that seems to work
    – daleif
    Feb 12, 2021 at 11:14

2 Answers 2

3

I suggest using the booktabs feature \addlinespace.

Also tabular* so you don't have to bother with spaces; it just needs an educated guess for the width of the pictures.

Using scale is not the best way, because it depends on the original size of the pictures and guessing the right factor is generally more difficult.

In the code I commented out some obsolete packages and the ones that are not needed for the example.

\documentclass[10pt,twocolumn,letterpaper]{article}

%\usepackage{mathptmx} % times is obsolete
\usepackage{newtxtext,newtxmath} % better
%\usepackage{epsfig} % obsolete
\usepackage{graphicx}
%\usepackage{capt-of}
%\usepackage{varwidth}
%\usepackage{floatrow}
%\usepackage{float}
\usepackage{array}
\usepackage[export]{adjustbox}
\usepackage[font=small,labelfont=bf,tableposition=top]{caption}
\usepackage{subcaption}
%\usepackage{cuted}
\usepackage{arydshln}
\usepackage{booktabs}

\begin{document}

\begin{figure*}
\centering

\setlength\tabcolsep{0pt}

\begin{tabular*}{\textwidth}{
  @{\extracolsep{\fill}}
  >{\footnotesize}{l} 
  cccccc
}

Input
       &\includegraphics[width=0.14\textwidth,valign=c]{example-image-a}
       &\includegraphics[width=0.14\textwidth,valign=c]{example-image-a} 
       &\includegraphics[width=0.14\textwidth,valign=c]{example-image-a}
       &\includegraphics[width=0.14\textwidth,valign=c]{example-image-a}
       &\includegraphics[width=0.14\textwidth,valign=c]{example-image-a}
       &\includegraphics[width=0.14\textwidth,valign=c]{example-image-a}
\\ \addlinespace
Output
       &\includegraphics[width=0.14\textwidth,valign=c]{example-image-a}
       &\includegraphics[width=0.14\textwidth,valign=c]{example-image-a} 
       &\includegraphics[width=0.14\textwidth,valign=c]{example-image-a}
       &\includegraphics[width=0.14\textwidth,valign=c]{example-image-a}
       &\includegraphics[width=0.14\textwidth,valign=c]{example-image-a}
       &\includegraphics[width=0.14\textwidth,valign=c]{example-image-a}
\\
 \addlinespace
 \hdashline
 \addlinespace
Input
       &\includegraphics[width=0.14\textwidth,valign=c]{example-image-a}
       &\includegraphics[width=0.14\textwidth,valign=c]{example-image-a} 
       &\includegraphics[width=0.14\textwidth,valign=c]{example-image-a}
       &\includegraphics[width=0.14\textwidth,valign=c]{example-image-a}
       &\includegraphics[width=0.14\textwidth,valign=c]{example-image-a}
       &\includegraphics[width=0.14\textwidth,valign=c]{example-image-a}
\\ \addlinespace
Output
       &\includegraphics[width=0.14\textwidth,valign=c]{example-image-a}
       &\includegraphics[width=0.14\textwidth,valign=c]{example-image-a} 
       &\includegraphics[width=0.14\textwidth,valign=c]{example-image-a}
       &\includegraphics[width=0.14\textwidth,valign=c]{example-image-a}
       &\includegraphics[width=0.14\textwidth,valign=c]{example-image-a}
       &\includegraphics[width=0.14\textwidth,valign=c]{example-image-a}
\end{tabular*}
\caption{More results} \label{figure:more results}

\end{figure*}

\end{document}

enter image description here

1
  • Learned a lot today, thanks.
    – DsCpp
    Feb 12, 2021 at 13:59
1

As a supplement to egreg's anwer, here is a variant that uses \adjustboxset in combination with \adjustimage to avoid repeated optional arguments of the \includegraphics commands. To add some vertical white space between adjacent rows of images as well as around the horizontal dashed line, I used the cellspace package. The amount of whice space can be adjusted by changing the values of \cellspacetoplimit and \cellspacebottomlimit:

enter image description here

\documentclass[10pt,twocolumn,letterpaper]{article}
\usepackage{graphicx}
\usepackage[export]{adjustbox}

\usepackage[font=small,labelfont=bf,tableposition=top]{caption}

\usepackage[column=0]{cellspace}
\setlength{\cellspacetoplimit}{4pt}
\setlength{\cellspacebottomlimit}{\cellspacetoplimit}

\usepackage{array}
\usepackage{arydshln}

\begin{document}

\begin{figure*}
\setlength\tabcolsep{0pt}
\adjustboxset{width=0.14\textwidth,valign=c}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} >{\footnotesize}{l}*{6}{0c}}
Input
       & \adjustimage{}{example-image-a}
       & \adjustimage{}{example-image-a} 
       & \adjustimage{}{example-image-a}
       & \adjustimage{}{example-image-a}
       & \adjustimage{}{example-image-a}
       & \adjustimage{}{example-image-a}
\\ 
Output
       & \adjustimage{}{example-image-a}
       & \adjustimage{}{example-image-a} 
       & \adjustimage{}{example-image-a}
       & \adjustimage{}{example-image-a}
       & \adjustimage{}{example-image-a}
       & \adjustimage{}{example-image-a}
\\
 \hdashline
Input
       & \adjustimage{}{example-image-a}
       & \adjustimage{}{example-image-a} 
       & \adjustimage{}{example-image-a}
       & \adjustimage{}{example-image-a}
       & \adjustimage{}{example-image-a}
       & \adjustimage{}{example-image-a}
\\
Output
       & \adjustimage{}{example-image-a}
       & \adjustimage{}{example-image-a} 
       & \adjustimage{}{example-image-a}
       & \adjustimage{}{example-image-a}
       & \adjustimage{}{example-image-a}
       & \adjustimage{}{example-image-a}
\end{tabular*}
\caption{More results} \label{figure:more results}
\end{figure*}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .