4

I would like to present two tables side by side, however the positioning is not as I would like:

Demo

How can I center the captions below the tables and center both tables on the page?

Compiling example:

\documentclass[12pt,a4paper]{report}

\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage[intlimits]{amsmath}
\usepackage{palatino}

\usepackage{booktabs}

\begin{document}

\blindtext

\newcommand{\ncomps}{\tilde{m}}
\newcommand{\niter}{n_{\text{iter}}}
\newcommand{\cstar}{c^\star}

\begin{table}[!htb]
\centering
\begin{minipage}[t]{.3\textwidth}
    \caption{\label{table:params_cstar}Parameters of $\cstar$}
    \begin{tabular}[t]{@{}lll@{}} \toprule

    SGD
        & $\niter$ & 25 \\
        & $\gamma$ & $10^{-3}$ \\

    RBF
        & $\ncomps$ & 4000 \\
        & $\alpha$ & $10^{-7}$ \\

    \bottomrule
    \end{tabular}
\end{minipage}%
\begin{minipage}[t]{0.7\textwidth}
    \caption{\label{table:dcnn_config_cstar}DCNN configuration for $\cstar$}
    \begin{tabular}[t]{@{}llll@{}} \toprule
    Layer & Filter & Pooling & NL \\ \midrule
    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}

The [t]'s make the tables align at the top, which works as desired.

2
  • 1
    Could you post a fully compilable (albeit minimal) code? Also, are you sure you want captions below tables? This is not the typographic tradition.
    – Bernard
    Jun 11, 2016 at 12:48
  • @Bernard I updated my question. And no, I'm not sure, I was just not aware of that :)
    – fabian789
    Jun 11, 2016 at 13:06

3 Answers 3

2

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} 

enter image description here

3
  • Looks stunning! Thanks. I read about the palatino issue but changing to mathpazo resulted in the "too many math fonts" error and because of deadline pressure I have postponed this problem!
    – fabian789
    Jun 11, 2016 at 14:04
  • Anyway, the most up-to-date solution consists in using newpx (newpxtext+newpxmath), but I couldn't test it as I have problems with them since one of the recent updates of MiKTeX.
    – Bernard
    Jun 11, 2016 at 14:10
  • I really like the widetilde BTW
    – fabian789
    Jun 11, 2016 at 14:11
3

Like this:

enter image description here

For above picture you need enlarge width of the first \minipage that the caption can be placed in one line only ... In complete code below I made some small changes in comparison to your MWE. For the first table is used tabularx. With it I got better looks of tables and respective captions.

\documentclass[12pt,a4paper]{report}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage[intlimits]{amsmath}
\usepackage{palatino}

\usepackage{booktabs,tabularx}

\newcommand{\ncomps}{\tilde{m}}
\newcommand{\niter}{n_{\text{iter}}}
\newcommand{\cstar}{c^\star}

\begin{document}
\blindtext
    \begin{table}[!htb]
\centering
\begin{minipage}[b]{.33\textwidth}
    \caption{\label{table:params_cstar}Parameters of $\cstar$}
    \begin{tabularx}{\linewidth}[t]{XXX} 
\toprule
SGD & $\niter$  & 25        \\
    & $\gamma$  & $10^{-3}$ \\
\addlinespace
RBF & $\ncomps$ & 4000      \\
    & $\alpha$  & $10^{-7}$ \\
    \bottomrule
    \end{tabularx}
\end{minipage}\hfill
\begin{minipage}[b]{0.65\textwidth}
    \caption{\label{table:dcnn_config_cstar}DCNN configuration for $\cstar$}
    \begin{tabular}[t]{@{}llll@{}} \toprule
    Layer & Filter & Pooling & NL \\ \midrule
    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}

Addendum: It is not clear to me, why \hfill doesn't push the second table to the right border of text. So, as a solution can serve the following solution:

\documentclass[12pt,a4paper]{report}

\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage[intlimits]{amsmath}
\usepackage{palatino}

\usepackage{booktabs,tabularx}

\newcommand{\ncomps}{\tilde{m}}
\newcommand{\niter}{n_{\text{iter}}}
\newcommand{\cstar}{c^\star}

\begin{document}
\blindtext

    \begin{table}[htb]
\begin{tabular*}{\textwidth}{@{}p{0.33\textwidth}@{}>{\raggedleft\arraybackslash}p{0.67\textwidth}@{}}
    \caption{Parameters of $\cstar$}
    \label{table:params_cstar}
    \begin{tabularx}{\linewidth}[t]{XXX}
\toprule
SGD & $\niter$  & 25        \\
    & $\gamma$  & $10^{-3}$ \\
\addlinespace
RBF & $\ncomps$ & 4000      \\
    & $\alpha$  & $10^{-7}$ \\
    \bottomrule
    \end{tabularx}
&
    \caption{DCNN configuration for $\cstar$}
    \label{table:dcnn_config_cstar}
    \begin{tabular}[t]{@{}llll@{}} \toprule
    Layer & Filter & Pooling & NL \\ \midrule
    1 & Haar & -- & \textit{abs} \\
    2 & Haar & Subsampling by Factor 2 & \textit{abs} \\
    3 & Haar & Subsampling by Factor 2 & \textit{abs} \\
    \bottomrule
    \end{tabular}
\end{tabular*}
    \end{table}
\end{document}

In it instead of two minipages is used \begin{tabular*}{\textwidth} with two columns. The second is right aligned. The influence of \tabcolsep is eliminated by use of @{}.

enter image description here

2
  • Thanks for the replay, but it looks like the two tables together are not centered on the page. Any ideas on how to achieve this?
    – fabian789
    Jun 11, 2016 at 13:37
  • @fabian789, do you mean that right table is not push to right text border? I do not know, what this is not happen. The \hfill should do this ... Instead \hfill try to use \hspace{0.04\textwidth}. I will invetigated why the MWE doesn't give expected result.
    – Zarko
    Jun 11, 2016 at 13:58
0

A low tech answer, using the OP's code:

\documentclass[12pt,a4paper]{report}

\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage[intlimits]{amsmath}
\usepackage{palatino}

\usepackage{booktabs}

\begin{document}

\blindtext

\newcommand{\ncomps}{\tilde{m}}
\newcommand{\niter}{n_{\text{iter}}}
\newcommand{\cstar}{c^\star}

\begin{table}[!htb]
\hskip-.25in
\begin{minipage}[b]{.5\textwidth}
    \caption{\label{table:params_cstar}Parameters of $\cstar$~\hskip.8in}
    \begin{tabular}[t]{@{}lll@{}} \toprule

    SGD\phantom{NB}
        & $\niter$\phantom{NB} & 25 \phantom{NB}\\
        & $\gamma$ & $10^{-3}$ \\

    RBF
        & $\ncomps$ & 4000 \\
        & $\alpha$ & $10^{-7}$ \\

    \bottomrule
    \end{tabular}
\end{minipage}%
\begin{minipage}[b]{0.5\textwidth}
    \caption{\label{table:dcnn_config_cstar}DCNN configuration for $\cstar$}
    \begin{tabular}[t]{@{}llll@{}} \toprule
    Layer & Filter & Pooling & NL \\ \midrule
    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}

Produces:

enter image description here

You must log in to answer this question.

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