TransWikia.com

hline in tabular inside a figure

TeX - LaTeX Asked on June 5, 2021

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{12{ttsmall 3}
and45{ttsmall 6}
}


maketitle
begin{figure*}

centering
hspace{-22pt}
% setlength{extrarowheight}{1em}
setlengthtabcolsep{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.

2 Answers

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

setlengthtabcolsep{0pt}

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

Input
       &includegraphics[width=0.14textwidth,valign=c]{example-image-a}
       &includegraphics[width=0.14textwidth,valign=c]{example-image-a} 
       &includegraphics[width=0.14textwidth,valign=c]{example-image-a}
       &includegraphics[width=0.14textwidth,valign=c]{example-image-a}
       &includegraphics[width=0.14textwidth,valign=c]{example-image-a}
       &includegraphics[width=0.14textwidth,valign=c]{example-image-a}
 addlinespace
Output
       &includegraphics[width=0.14textwidth,valign=c]{example-image-a}
       &includegraphics[width=0.14textwidth,valign=c]{example-image-a} 
       &includegraphics[width=0.14textwidth,valign=c]{example-image-a}
       &includegraphics[width=0.14textwidth,valign=c]{example-image-a}
       &includegraphics[width=0.14textwidth,valign=c]{example-image-a}
       &includegraphics[width=0.14textwidth,valign=c]{example-image-a}

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

end{figure*}

end{document}

enter image description here

Correct answer by egreg on June 5, 2021

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*}
setlengthtabcolsep{0pt}
adjustboxset{width=0.14textwidth,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}

Answered by leandriis on June 5, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP