将两个表格并排居中

将两个表格并排居中

我想并排显示两个表格,但是定位并不像我想要的那样:

演示

如何让标题居中于表格下方将两个表格置于页面中央吗?

编译示例:

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

' [t]s 使表格在顶部对齐,如所愿。

答案1

几乎与 Zarko 的解决方案相同。我稍微放大了左侧的迷你页面,并抑制了{}表格两侧的两者,但使用了裁剪\cmidrule而不是\midrule。此外,palatino已经过时,因为它只修改了文本字体,并且cmmaths仍在使用,这对于 palatino 文本来说很难看。所以我用它替换了它mathpazo(参见l2tabu指南,§ 2.3.4)最后的更改:\widetilde{m}看起来比\tilde{m}我认为的要好(波浪线太小):

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

在此处输入图片描述

答案2

像这样:

在此处输入图片描述

对于上图,您需要扩大第一张图的宽度\minipage,以便标题只能放在一行中...在下面的完整代码中,我与您的 MWE 相比做了一些小改动。对于第一张图,使用了表格tabularx。有了它,我得到了更好的表格和相应的标题外观。

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

附录: 我不明白,为什么\hfill不将第二个表格推到文本的右边框。因此,作为解决方案,可以提供以下解决方案:

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

其中,minipages使用代替\begin{tabular*}{\textwidth}两列。第二列右对齐。\tabcolsep使用 消除的影响@{}

在此处输入图片描述

答案3

一个低技术含量的答案,使用 OP 的代码:

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

生成:

在此处输入图片描述

相关内容