并排的桌子

并排的桌子

我正在写一个文档(单列),但有时我想并排显示两个表格,但我不知道如何实现。下面我提供了一个最低限度的工作代码,其中包含我想要并排显示的两个表格。表格显示后,我希望继续以单列格式定期书写。任何帮助都非常感谢。

\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}

答案1

这是表格的三个不同版本。为了使它们并排显示,我调整了字体大小以及 的值\tabcolsep

在此处输入图片描述

\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}

答案2

我提出一个基于floatrowmakecell包的解决方案:

\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}

在此处输入图片描述

相关内容