Suppose I have two tables that don't have many columns (3, for example). How can I position them side by side?
[Tex/LaTex] How to have two tables side by side
positioningtables
Related Solutions
You need to remember that as soon as you leave an empty line, TeX will create a new paragraph and any following material will be typeset below. i have removed these and the tables typeset properly in landscape.
\documentclass{article}
\usepackage{pdflscape}
\begin{document}
\begin{landscape}
\begin{tabular}{lcccc}
Context & Italian & Bormino & Both & N/A \\\hline
\\
Mother & 24.3\% & 59.5\% & 16.2\% & 0\% \\
Parents to age 10 & 27.0\% & 59.5\% & 13.5\% & 0\% \\
Father & 29.7\% & 56.8\% & 10.8\% & 2.7\% \\
Grandfather & 24.3\% & 55.9\% & 10.8\% & 13.5\% \\
Grandmother & 24.3\% & 54.1\% & 13.5\% & 8.1\% \\
Brothers & 21.6\% & 46.0\% & 10.8\% & 21.6\% \\
Swearing & 27.0\% & 40.5\% & 16.2\% & 16.2\% \\
Sisters & 8.1\% & 35.1\% & 8.1\% & 48.7\% \\
Relatives & 24.3\% & 32.4\% & 43.2\% & 0\% \\
Neighbors & 24.3\% & 27.0\% & 46.0\% & 2.7\% \\
Partner & 32.4\% & 24.3\% & 27.0\% & 16.2\% \\
Son & 16.2\% & 21.6\% & 16.2\% & 46.0\% \\
Localities & 29.7\% & 21.6\% & 48.7\% & 0\% \\
At Work & 32.4\% & 21.6\% & 43.2\% & 2.7\% \\
Colleagues & 29.7\% & 18.9\% & 48.7\% & 2.7\% \\
Schoolmates & 43.2\% & 16.2\% & 32.4\% & 8.1\% \\
Thinking & 43.2\% & 16.2\% & 35.1\% & 5.4\% \\
Daughter & 13.5\% & 13.5\% & 8.1\% & 64.9\% \\
Officials & 67.6\% & 13.5\% & 18.9\% & 0\% \\
Praying & 40.5\% & 10.8\% & 16.2\% & 32.4\% \\
Counting/Mental math & 62.2\% & 8.1\% & 29.7\% & 0\% \\
Teachers & 73.0\% & 8.1\% & 5.4\% & 13.5\% \\
\end{tabular}
\begin{tabular}{lcccc}
Context & Italian & Bormino & Both & N/A \\\hline
\\
Teachers & 73.0\% & 8.1\% & 5.4\% & 13.5\% \\
Officials & 67.6\% & 13.5\% & 18.9\% & 0\% \\
Counting/Mental math & 62.2\% & 8.1\% & 29.7\% & 0\% \\
Thinking & 43.2\% & 16.2\% & 35.1\% & 5.4\% \\
Schoolmates & 43.2\% & 16.2\% & 32.4\% & 8.1\% \\
Praying & 40.5\% & 10.8\% & 16.2\% & 32.4\% \\
Partner & 32.4\% & 24.3\% & 27.0\% & 16.2\% \\
At Work & 32.4\% & 21.6\% & 43.2\% & 2.7\% \\
Colleagues & 29.7\% & 18.9\% & 48.7\% & 2.7\% \\
Localities & 29.7\% & 21.6\% & 48.7\% & 0\% \\
Father & 29.7\% & 56.8\% & 10.8\% & 2.7\% \\
Swearing & 27.0\% & 40.5\% & 16.2\% & 16.2\% \\
Parents to age 10 & 27.0\% & 59.5\% & 13.5\% & 0\% \\
Neighbors & 24.3\% & 27.0\% & 46.0\% & 2.7\% \\
Relatives & 24.3\% & 32.4\% & 43.2\% & 0\% \\
Mother & 24.3\% & 59.5\% & 16.2\% & 0\% \\
Grandmother & 24.3\% & 54.1\% & 13.5\% & 8.1\% \\
Grandfather & 24.3\% & 55.9\% & 10.8\% & 13.5\% \\
Brothers & 21.6\% & 46.0\% & 10.8\% & 21.6\% \\
Son & 16.2\% & 21.6\% & 16.2\% & 46.0\% \\
Daughter & 13.5\% & 13.5\% & 8.1\% & 64.9\% \\
Sisters & 8.1\% & 35.1\% & 8.1\% & 48.7\% \\
\end{tabular}
\end{landscape}
\end{document}
To space them a bit apart, you can use hspace{<dimen>}
. For example to leave a 1em space use,
\end{tabular}\hspace{1em}
\begin{tabular}{lcccc}
Almost the same as Zarko's solution. I slightly enlarged the left-hand minipage, and suppressed both {}
on both sides of the tables, but used a cropped \cmidrule
instead of \midrule
. Also, palatino
is obsolete, as it modifies only the text font, andd cmmaths
are still used, which is ugly with palatino text. So I replaced it with mathpazo
(cf. the l2tabu
guide, ยง 2.3.4) Last change: \widetilde{m}
looks better than \tilde{m}
in my opinion (tilde is too small):
\documentclass[12pt,a4paper]{report}
\usepackage[english]{babel}
\usepackage[showframe]{geometry} \usepackage{blindtext}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage[intlimits]{amsmath}
%\usepackage{palatino}
\usepackage{mathpazo} \usepackage{booktabs}
\begin{document}
\blindtext
\newcommand{\ncomps}{\widetilde{m}}
\newcommand{\niter}{n_{\text{iter}}}
\newcommand{\cstar}{c^\star}
\begin{table}[!htb]
\begin{minipage}[t]{.33\textwidth}
\centering
\caption{\label{table:params_cstar}Parameters of $\cstar$}
\begin{tabular}[t]{lll} \toprule
SGD
& $\niter$ & 25 \\
& $\gamma$ & $10^{-3}$ \\
\addlinespace%
RBF
& $\ncomps$ & 4000 \\
& $\alpha$ & $10^{-7}$ \\
\bottomrule
\end{tabular}
\end{minipage}%
\begin{minipage}[t]{0.67\textwidth}
\centering
\caption{\label{table:dcnn_config_cstar}DCNN configuration for $\cstar$}
\begin{tabular}[t]{llll} \toprule
Layer & Filter & Pooling & NL \\ \cmidrule[\lightrulewidth](lr){1-4}
1 & Haar & -- & \textit{abs} \\
2 & Haar & Subsampling by Factor 2 & \textit{abs} \\
3 & Haar & Subsampling by Factor 2 & \textit{abs} \\
\bottomrule
\end{tabular}
\end{minipage}
\end{table}
\end{document}
Best Answer
Just put two
tabular
environments side by side. Add spacing as desired.If you want to use
subfig
because you want them to have separate captions, then that is simple as well.If you want two tables that are independent, and thus don't want to use
\subfloat
, you can use\parbox
.This is basically the same as before just that I've centered each
tabular
in a\parbox
with an included caption and wrapped the whole thing in atable
.