将表格放入多列中

将表格放入多列中

我试图将数据表分成两列,这样它们就不会占用太多页面。我的表格如下所示:

\documentclass[a4paper, 12pt]{article}

\usepackage{ifpdf}
\usepackage[latin1]{inputenc}
\usepackage[margin=1.5cm, left=1.5cm, top = 2cm, bottom=2cm]{geometry}
\usepackage{amsmath, mathtools}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{epigraph}
\usepackage{wasysym}
\usepackage[none]{hyphenat}
\usepackage[super]{nth}
\usepackage{subfig}
\usepackage{textcomp}
\usepackage[usenames]{xcolor}
\usepackage{hyperref}
\usepackage{cite}
\usepackage{comment}
\usepackage{setspace}
\usepackage{float}
\usepackage{dcolumn}
\usepackage{caption}
\usepackage{multicol}

\usepackage{siunitx}
\usepackage{dcolumn,booktabs}
\newcolumntype{d}[1]{D{.}{.}{#1}}

\captionsetup{font={footnotesize, it},labelfont=footnotesize, width=.5\textwidth}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}} % handy shortcut macro
\begin{document}
\begin{table}[h!]
    \centering
    \addtolength{\tabcolsep}{-0.3pt}
    \sisetup{group-digits=integer}
    \begin{tabular}{
            @{}
            l
            S[table-format=+1.6]
            S[table-format=5]
            S[table-format=4.4]       
            @{}
        }
        \hline
        Combo   &   {$|r|>0.5$} &   {$n$}   &   {$r^2n > 1000$}\\
        \hline
        (U-V)   &   0.558545    &   11640   &   3631.36 \\
        (U-R)   &   0.567270    &   11632   &   3743.12 \\
        (U-I)   &   0.579188    &   11626   &   3900.04 \\
        (U-J)   &   0.536106    &   3709    &   1066 \\
        (U-K)   &   0.535644    &   3730    &   1070.19 \\
        (B-V)   &   0.580019    &   11884   &   3998.04 \\
        (B-R)   &   0.574867    &   11763   &   3887.34 \\
        (B-I)   &   0.591288    &   11749   &   4107.7 \\
        (V-U)   &   -0.558545   &   11640   &   3631.36 \\
        (V-B)   &   -0.580019   &   11884   &   3998.04 \\
        (R-U)   &   -0.567270   &   11632   &   3743.12 \\
        (R-B)   &   -0.574867   &   11763   &   3887.34 \\
        (R-W2)  &   -0.535443   &   4022    &   1153.1 \\
        (I-U)   &   -0.579188   &   11626   &   3900.04 \\
        (I-B)   &   -0.591288   &   11749   &   4107.7 \\
        (I-W2)  &   -0.574056   &   4020    &   1324.75 \\
        (J-U)   &   -0.536106   &   3709    &   1066 \\
        (K-U)   &   -0.535644   &   3730    &   1070.19 \\
        (W2-R)  &   0.535443    &   4022    &   1153.1 \\
        (W2-I)  &   0.574056    &   4020    &   1324.75 \\
        \\
        \hline
    \end{tabular}
    \caption[Mg\textsc{ii} colours OLS results against $log(z)$]{OLS results for photometric colours from the Mg\textsc{ii} dataset when plotted against $log(z)$.}
    \label{table: mg sub}
\end{table}
\begin{table}
    \centering
    \addtolength{\tabcolsep}{-0.3pt}
    \sisetup{group-digits=integer}
    \begin{tabular}{
            @{}
            l
            S[table-format=+1.6]
            S[table-format=5]
            S[table-format=4.4]       
            @{}
        }
        \hline
        Combo   &   {$|r|>0.5$} &   {$n$}   &   {$r^2n > 1000$}\\
        \hline
        (U+B)   &   0.597204    &   11663   &   4159.64 \\
        (U+V)   &   0.553139    &   11640   &   3561.4 \\
        (U+R)   &   0.542890    &   11632   &   3428.29 \\
        (U+I)   &   0.538584    &   11626   &   3372.38 \\
        (U+J)   &   0.534619    &   3709    &   1060.1 \\
        (U+K)   &   0.524521    &   3730    &   1026.21 \\
        (U+W1)  &   0.568288    &   3946    &   1274.36 \\
        (U+W2)  &   0.590900    &   3974    &   1387.57 \\
        (U+W3)  &   0.610303    &   3588    &   1336.42 \\
        (U+W4)  &   0.531177    &   4088    &   1153.43 \\
        (B+U)   &   0.597204    &   11663   &   4159.64 \\
        (B+V)   &   0.503560    &   11884   &   3013.46 \\
        (B+W1)  &   0.523232    &   4001    &   1095.36 \\
        (B+W2)  &   0.556555    &   4029    &   1248 \\
        (B+W3)  &   0.574910    &   3628    &   1199.13 \\
        (V+U)   &   0.553139    &   11640   &   3561.4 \\
        (V+B)   &   0.503560    &   11884   &   3013.46 \\
        (R+U)   &   0.542890    &   11632   &   3428.29 \\
        (I+U)   &   0.538584    &   11626   &   3372.38 \\
        (J+U)   &   0.534619    &   3709    &   1060.1 \\
        (K+U)   &   0.524521    &   3730    &   1026.21 \\
        (W1+U)  &   0.568288    &   3946    &   1274.36 \\
        (W1+B)  &   0.523232    &   4001    &   1095.36 \\
        (W2+U)  &   0.590900    &   3974    &   1387.57 \\
        (W2+B)  &   0.556555    &   4029    &   1248 \\
        (W2+W3) &   0.500704    &   5436    &   1362.83 \\
        (W3+U)  &   0.610303    &   3588    &   1336.42 \\
        (W3+B)  &   0.574910    &   3628    &   1199.13 \\
        (W3+W2) &   0.500704    &   5436    &   1362.83 \\
        (W4+U)  &   0.531177    &   4088    &   1153.43 \\
        \\
        \hline
    \end{tabular}
    \caption[Mg\textsc{ii} additive combinations OLS results against $log(z)$]{OLS results for additive combinations from the Mg\textsc{ii} dataset when plotted against $log(z)$.}
    \label{table: mg add}
\end{table}
\end{document}

当我将表格显示在一列中时,它们看起来很好,但如果我将它们包装在

\begin{multicols}{2}
%my table code here
\end{multicols}

我的表格消失了。我做错了什么?

答案1

记录multicol明确指出,不允许 table这样做,否则它们将会消失。figure

示例文档

相反,你可以使用center并排版标题

 \captionof{table}[short caption]{long caption}

示例输出

\documentclass[a4paper, 12pt]{article}

\usepackage{ifpdf}
\usepackage[latin1]{inputenc}
\usepackage[margin=1.5cm, left=1.5cm, top = 2cm, bottom=2cm]{geometry}
\usepackage{amsmath, mathtools}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{epigraph}
\usepackage{wasysym}
\usepackage[none]{hyphenat}
\usepackage[super]{nth}
\usepackage{subfig}
\usepackage{textcomp}
\usepackage[usenames]{xcolor}
\usepackage{hyperref}
\usepackage{cite}
\usepackage{comment}
\usepackage{setspace}
\usepackage{float}
\usepackage{dcolumn}
\usepackage{caption}
\usepackage{multicol}

\usepackage{siunitx}
\usepackage{dcolumn,booktabs}
\newcolumntype{d}[1]{D{.}{.}{#1}}

\captionsetup{font={footnotesize, it},labelfont=footnotesize, width=.5\textwidth}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}} % handy shortcut macro
\begin{document}
\begin{multicols}{2}
\begin{center}
    \addtolength{\tabcolsep}{-0.3pt}
    \sisetup{group-digits=integer}
    \begin{tabular}{
            @{}
            l
            S[table-format=+1.6]
            S[table-format=5]
            S[table-format=4.4]
            @{}
        }
        \hline
        Combo   &   {$|r|>0.5$} &   {$n$}   &   {$r^2n > 1000$}\\
        \hline
        (U-V)   &   0.558545    &   11640   &   3631.36 \\
        (U-R)   &   0.567270    &   11632   &   3743.12 \\
        (U-I)   &   0.579188    &   11626   &   3900.04 \\
        (U-J)   &   0.536106    &   3709    &   1066 \\
        (U-K)   &   0.535644    &   3730    &   1070.19 \\
        (B-V)   &   0.580019    &   11884   &   3998.04 \\
        (B-R)   &   0.574867    &   11763   &   3887.34 \\
        (B-I)   &   0.591288    &   11749   &   4107.7 \\
        (V-U)   &   -0.558545   &   11640   &   3631.36 \\
        (V-B)   &   -0.580019   &   11884   &   3998.04 \\
        (R-U)   &   -0.567270   &   11632   &   3743.12 \\
        (R-B)   &   -0.574867   &   11763   &   3887.34 \\
        (R-W2)  &   -0.535443   &   4022    &   1153.1 \\
        (I-U)   &   -0.579188   &   11626   &   3900.04 \\
        (I-B)   &   -0.591288   &   11749   &   4107.7 \\
        (I-W2)  &   -0.574056   &   4020    &   1324.75 \\
        (J-U)   &   -0.536106   &   3709    &   1066 \\
        (K-U)   &   -0.535644   &   3730    &   1070.19 \\
        (W2-R)  &   0.535443    &   4022    &   1153.1 \\
        (W2-I)  &   0.574056    &   4020    &   1324.75 \\
        \\
        \hline
    \end{tabular}
    \captionof{table}[Mg\textsc{ii} colours OLS results against $log(z)$]{OLS results for photometric colours from the Mg\textsc{ii} dataset when plotted against $log(z)$.}
    \label{table: mg sub}
\end{center}
\begin{center}
    \addtolength{\tabcolsep}{-0.3pt}
    \sisetup{group-digits=integer}
    \begin{tabular}{
            @{}
            l
            S[table-format=+1.6]
            S[table-format=5]
            S[table-format=4.4]
            @{}
        }
        \hline
        Combo   &   {$|r|>0.5$} &   {$n$}   &   {$r^2n > 1000$}\\
        \hline
        (U+B)   &   0.597204    &   11663   &   4159.64 \\
        (U+V)   &   0.553139    &   11640   &   3561.4 \\
        (U+R)   &   0.542890    &   11632   &   3428.29 \\
        (U+I)   &   0.538584    &   11626   &   3372.38 \\
        (U+J)   &   0.534619    &   3709    &   1060.1 \\
        (U+K)   &   0.524521    &   3730    &   1026.21 \\
        (U+W1)  &   0.568288    &   3946    &   1274.36 \\
        (U+W2)  &   0.590900    &   3974    &   1387.57 \\
        (U+W3)  &   0.610303    &   3588    &   1336.42 \\
        (U+W4)  &   0.531177    &   4088    &   1153.43 \\
        (B+U)   &   0.597204    &   11663   &   4159.64 \\
        (B+V)   &   0.503560    &   11884   &   3013.46 \\
        (B+W1)  &   0.523232    &   4001    &   1095.36 \\
        (B+W2)  &   0.556555    &   4029    &   1248 \\
        (B+W3)  &   0.574910    &   3628    &   1199.13 \\
        (V+U)   &   0.553139    &   11640   &   3561.4 \\
        (V+B)   &   0.503560    &   11884   &   3013.46 \\
        (R+U)   &   0.542890    &   11632   &   3428.29 \\
        (I+U)   &   0.538584    &   11626   &   3372.38 \\
        (J+U)   &   0.534619    &   3709    &   1060.1 \\
        (K+U)   &   0.524521    &   3730    &   1026.21 \\
        (W1+U)  &   0.568288    &   3946    &   1274.36 \\
        (W1+B)  &   0.523232    &   4001    &   1095.36 \\
        (W2+U)  &   0.590900    &   3974    &   1387.57 \\
        (W2+B)  &   0.556555    &   4029    &   1248 \\
        (W2+W3) &   0.500704    &   5436    &   1362.83 \\
        (W3+U)  &   0.610303    &   3588    &   1336.42 \\
        (W3+B)  &   0.574910    &   3628    &   1199.13 \\
        (W3+W2) &   0.500704    &   5436    &   1362.83 \\
        (W4+U)  &   0.531177    &   4088    &   1153.43 \\
        \\
        \hline
    \end{tabular}
    \captionof{table}[Mg\textsc{ii} additive combinations OLS results against $log(z)$]{OLS results for additive combinations from the Mg\textsc{ii} dataset when plotted against $log(z)$.}
    \label{table: mg add}
\end{center}
\end{multicols}
\end{document}

相关内容