1

I am writing a document (single column) but at some point I want to display two tables side by side and I do not know how to accomplish it. I provide below a minimum working code with the two tables I want side by side. After the tables are displayed I would like to keep writing regularly in a single column format. Any help is appreciated.

\documentclass[12pt, tikz]{article}
\usepackage{answers}
\usepackage{setspace}
\usepackage{graphicx}
\usepackage{slashbox}
\usepackage{enumitem}
\usepackage[colorlinks]{hyperref}
\usepackage{multicol}
\usepackage{booktabs}
\usepackage{amsmath}
\usepackage{mathrsfs}
\usepackage[table,x11names]{xcolor}
\usepackage[margin=1in]{geometry}
\usepackage{float}
\usepackage{amsmath,amsthm,amssymb}
\usepackage[utf8]{inputenc}
\usepackage {tikz}
\usepackage{multicol}
\usetikzlibrary{trees}
\usepackage{tikz-timing}[2014/10/29]
\usetikztiminglibrary[rising arrows]{clockarrows}
\usetikzlibrary {positioning}
\usepackage{xcolor}
\definecolor {processblue}{cmyk}{0.96,0,0,0}
\usepackage{caption}
\usepackage{array}
\newcolumntype{?}{!{\vrule width 2pt}}
\usepackage[spanish, es-tabla]{babel}
\makeatletter
\renewcommand{\@seccntformat}[1]{}
\makeatother
\setlength\parindent{24pt}
\usepackage{forest}
\usetikzlibrary{arrows.meta}

 
\begin{document}
 

\begin{table}
\centering
\begin{tabular}{|c|c|c|c|c|}
\cline{2-5} 
\multicolumn{1}{c|}{}
 & \textbf{Temperatura}  & \textbf{Humedad} & \textbf{Viento} & \textbf{Vuelo} \\
\hline
5 & Cool & Normal & Weak & Yes\\
\hline
6 & Cool & Normal & Strong & No\\
\hline
1 & 1 & 1 & 1 & 1 \\
\hline
1 & 1 & 1 & 1 & 1 \\
\hline
\end{tabular}
\label{tab1}
\end{table}


\begin{table}
\centering
\begin{tabular}{|c|c|c|c|c|}
\cline{2-5} 
\multicolumn{1}{c|}{}
 & \textbf{Temperatura}  & \textbf{Humedad} & \textbf{Viento} & \textbf{Vuelo} \\
\hline
5 & Cool & Normal & Weak & Yes\\
\hline
6 & Cool & Normal & Strong & No\\
\hline
2 & 2 & 2 & 2 & 2 \\
\hline
2 & 2 & 2 & 2 & 2 \\
\hline
\end{tabular}
\label{tab2}
\end{table}

\end{document}
3
  • Add \footnotesize to line 41, comment the lines 57-61 (start the lines with % ) and change Temperature by Temp. in both tabulars. Suggestion: search also the manual of the booktabs package.
    – Fran
    May 9, 2021 at 15:58
  • Will each table get an individual caption (e.g. Table 1... and Table 2...) or do you want a shared caption with or without subcaptions?
    – leandriis
    May 9, 2021 at 16:20
  • No worries about caption, don't need any May 9, 2021 at 16:24

2 Answers 2

1

Here are three different versions of your table. In order to fit them side by side, I adjusted the font sizes as well as the value of \tabcolsep:

enter image description here

\documentclass[12pt]{article}
\usepackage{booktabs}
\usepackage[margin=1in]{geometry}

\usepackage{array}




\usepackage{lipsum} % For dummy text. Do not use in real document.
 
\begin{document}
\lipsum
 

\begin{table}[htbp]
\small
\setlength{\tabcolsep}{3pt}
\begin{tabular}{|c|c|c|c|c|}
\cline{2-5} 
\multicolumn{1}{c|}{}
 & \textbf{Temperatura}  & \textbf{Humedad} & \textbf{Viento} & \textbf{Vuelo} \\
\hline
5 & Cool & Normal & Weak & Yes\\
\hline
6 & Cool & Normal & Strong & No\\
\hline
1 & 1 & 1 & 1 & 1 \\
\hline
1 & 1 & 1 & 1 & 1 \\
\hline
\end{tabular}
\hfill
\begin{tabular}{|c|c|c|c|c|}
\cline{2-5} 
\multicolumn{1}{c|}{}
 & \textbf{Temperatura}  & \textbf{Humedad} & \textbf{Viento} & \textbf{Vuelo} \\
\hline
5 & Cool & Normal & Weak & Yes\\
\hline
6 & Cool & Normal & Strong & No\\
\hline
2 & 2 & 2 & 2 & 2 \\
\hline
2 & 2 & 2 & 2 & 2 \\
\hline
\end{tabular}
\end{table}

\begin{table}[htbp]
\setlength{\tabcolsep}{5pt}
\begin{tabular}{|c|c|c|c|c|}
\cline{2-5} 
\multicolumn{1}{c|}{}
 & \textbf{Temp.}  & \textbf{Humedad} & \textbf{Viento} & \textbf{Vuelo} \\
\hline
5 & Cool & Normal & Weak & Yes\\
\hline
6 & Cool & Normal & Strong & No\\
\hline
1 & 1 & 1 & 1 & 1 \\
\hline
1 & 1 & 1 & 1 & 1 \\
\hline
\end{tabular}
\hfill
\begin{tabular}{|c|c|c|c|c|}
\cline{2-5} 
\multicolumn{1}{c|}{}
 & \textbf{Temp.}  & \textbf{Humedad} & \textbf{Viento} & \textbf{Vuelo} \\
\hline
5 & Cool & Normal & Weak & Yes\\
\hline
6 & Cool & Normal & Strong & No\\
\hline
2 & 2 & 2 & 2 & 2 \\
\hline
2 & 2 & 2 & 2 & 2 \\
\hline
\end{tabular}
\end{table}


\begin{table}[htbp]
\setlength{\tabcolsep}{4pt}
\begin{tabular}{ccccc}
\toprule 
 & Temperatura  & Humedad & Viento & Vuelo \\
\midrule
5 & Cool & Normal & Weak & Yes\\
6 & Cool & Normal & Strong & No\\
1 & 1 & 1 & 1 & 1 \\
1 & 1 & 1 & 1 & 1 \\
\bottomrule
\end{tabular}
\hfill
\begin{tabular}{ccccc}
\toprule
 & Temperatura  & Humedad & Viento & Vuelo \\
\midrule
5 & Cool & Normal & Weak & Yes\\
6 & Cool & Normal & Strong & No\\
2 & 2 & 2 & 2 & 2 \\
2 & 2 & 2 & 2 & 2 \\
\bottomrule
\end{tabular}
\end{table}

\lipsum

\end{document}
1

I propose a solution based on the floatrow and makecell packages:

\documentclass[12pt]{article}
\usepackage[spanish, es-tabla]{babel}
\usepackage{setspace}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{mathrsfs}
\usepackage[table,x11names]{xcolor}
\usepackage[margin=1in]{geometry}
%\usepackage{float}
\usepackage{amsmath,amsthm,amssymb}
\usepackage{multicol}
\usepackage{caption}
\usepackage{floatrow, makecell}
\renewcommand{\theadfont}{\small\bfseries}
\usepackage{array}
\newcolumntype{?}{!{\vrule width 2pt}}
\usepackage[colorlinks]{hyperref}
\setlength\parindent{24pt}

\begin{document}

\begin{table}
\setlength{\tabcolsep}{3pt}
\begin{floatrow}
\centering
\ttabbox{\caption{First table}\label{tab1}}
{\begin{tabular}{|c|c|c|c|c|}
\cline{2-5}
\multicolumn{1}{c|}{}
 & \thead{Temperatura} & \thead{Humedad} & \thead{Viento} & \thead{Vuelo} \\
\hline
5 & Cool & Normal & Weak & Yes\\
\hline
6 & Cool & Normal & Strong & No\\
\hline
1 & 1 & 1 & 1 & 1 \\
\hline
1 & 1 & 1 & 1 & 1 \\
\hline
\end{tabular}}
%
\ttabbox{\caption{Second table}\label{tab2}}
{\begin{tabular}{|c|c|c|c|c|}
\cline{2-5}
\multicolumn{1}{c|}{}
 & \thead{Temperatura} & \thead{Humedad} & \thead{Viento} & \thead{Vuelo} \\
\hline
5 & Cool & Normal & Weak & Yes\\
\hline
6 & Cool & Normal & Strong & No\\
\hline
2 & 2 & 2 & 2 & 2 \\
\hline
2 & 2 & 2 & 2 & 2 \\
\hline
\end{tabular}}
\end{floatrow}
\end{table}

\end{document}

enter image description here

You must log in to answer this question.

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