2

I have two independent (not subfigs and related) tables that should appear aligned together vertically in a double-column layout format paper. I used one table wrapper and then minipage for each tabular (according to cannot use \caption under minipage and many other solutions), but the caption still appears for the last table. Here's the code:

\documentclass[11pt,a4paper]{article}
\usepackage{times}
\usepackage{latexsym}
\usepackage{amsmath}
\usepackage{algpseudocode}
\usepackage{graphicx}
\usepackage{multirow}
\usepackage{tabularx}
\usepackage{hhline}
\usepackage{arydshln}
\usepackage{url}
\usepackage{enumitem}
\usepackage{booktabs}
\usepackage{xcolor}
\usepackage{setspace}
\usepackage{hyperref}
\usepackage{titlesec}
\usepackage{capt-of}
\usepackage{varwidth}
\usepackage{wrapfig}
\usepackage{ctable}
\usepackage{adjustbox}
\usepackage{float}
\restylefloat{table}
\usepackage{subfiles}
\usepackage{amssymb}
\usepackage{enumitem}
\usepackage{colortbl}
\usepackage{multirow}
\usepackage{array}
\usepackage{cleveref}
\usepackage{titlesec}
\usepackage{subfig}
\usepackage{lipsum}

\begin{document}
\begin{table*}[!htb]
\begin{minipage}{.55\textwidth}
    \centering
    \small

    \def\arraystretch{1.0}\tabcolsep=3pt    
    \begin{tabular}{lcccccccc}
      \toprule
        & \multicolumn{2}{c}{\textbf{AAA1}} & \multicolumn{2}{c}{\textbf{AAA2}} & \multicolumn{2}{c}{\textbf{AAA3}} &  \multicolumn{2}{c}{\textbf{AAA4}}\\
        A1                     & A2              & A3  & A4              &A5           & A6           & A7      & A8 & A9 \\ \toprule
           \textsc{BLAAAAA}  &     -   & - &            -      &       -      &        -     &    - & -  &  - \\ 
           \textsc{BLAAAAA}  &     -   & - &            -      &       -      &        -     &    - & -  &  - \\ 
        
           \textsc{BLAAAAA}  &     -   & - &            -      &       -      &        -     &    - & -  &  - \\ 
          \midrule
           \textsc{BLAAAAA}  &     -   & - &            -      &       -      &        -     &    - & -  &  - \\ 
           \textsc{BLAAAAA}  &     -   & - &            -      &       -      &        -     &    - & -  &  - \\ 
           \textsc{BLAAAAA}  &     -   & - &            -      &       -      &        -     &    - & -  &  - \\ 
           \textsc{BLAAAAA}  &     -   & - &            -      &       -      &        -     &    - & -  &  - \\ 
           \textsc{BLAAAAA}  &     -   & - &            -      &       -      &        -     &    - & -  &  - \\ 
        \bottomrule
    \end{tabular} 
    \caption{Capt1}
    \label{tab:1}
\end{minipage}
\begin{minipage}{.45\textwidth}
% \subfloat[First caption]{
    \centering
    \small
    \def\arraystretch{1.0}\tabcolsep=3pt    
    \begin{tabular}{@{}lrrr@{}}
        \toprule
        A1            & A2 & A3 & A4 \\ \midrule
        BLAAAAA     & -   & -    & -     \\
        BLAAAAA     & -   & -    & -     \\
        BLAAAAA     & -   & -    & -     \\
        BLAAAAA     & -   & -    & -     \\
        BLAAAAA     & -   & -    & -     \\
        BLAAAAA     & -   & -    & -     \\
        \bottomrule
    \end{tabular}
    % \end{table}
    \caption{Capt2.} 
    \label{tab:2}
\end{minipage} 
\end{table*}
\end{document}

and the results (only capt2 should be there):

enter image description here

How can I see the captions of the two tables, and also align them visually? Here's what I want:

enter image description here

7
  • 1
    Welcome to TeX.SX! What exactly does "align them visually" mean here? Do you want to top of bottom align the tables and their captions? Do you want to align tables and captions individually? A sketch or the expected output would be helpful here.
    – leandriis
    Commented Jan 21, 2021 at 18:27
  • 1
    Apart from that, I am unfortunately not able to reproduce the issue of disappearing captions with the code you provided so far. (I tried it in combination with \documentclass{twocolumn]{article} and ended up with two captions, just as expected.) Therefore, please prepare a minimal working example (MWE) in order to allow others to reproduce the issue you describe.
    – leandriis
    Commented Jan 21, 2021 at 18:27
  • 1
    Hey, yes. the captions should be at the same line. I use \documentclass[11pt,a4paper]{article}.
    – anno
    Commented Jan 21, 2021 at 18:38
  • 1
    \documentclass[11pt,a4paper]{article} alone results in a single column document. In your question you mention using a "double column" layout. Please clarify that.
    – leandriis
    Commented Jan 21, 2021 at 18:39
  • 1
    Please supply a MWE (from \documentclass... to \end{document}) that we can compile and which shows your problem. Is it a one or two column document? Both captions should appear. I'm confused as at one point you only wanted cap2 but then you wanted both cap1 and cap2. Commented Jan 21, 2021 at 19:04

2 Answers 2

3

Edit: The first proposed solution is now adapted to the new information added to your question:

enter image description here

Above result are produced with your code (first example) and by use of the tabularx package (second example). Both gives expected result, so it is not clear what is your problem. For further help please provide an MWE which reproduce your problem.

\documentclass[11pt,a4paper, twocolumn]{article}
\usepackage{booktabs, tabularx}
\newcolumntype{C}{>{\centering\arraybackslash}X}

\usepackage{lipsum }
\begin{document}
% your code with use of dummy tables
\begin{table*}
\begin{minipage}[b]{.55\textwidth}
    \centering
\begin{tabular}{ccc}
\toprule
text    &   text    &   text    \\
\midrule
text text text    & text text text & text text text   \\
text text text    & text text text & text text text   \\
\bottomrule
\end{tabular}
    \caption{capt 1}
    \label{tab1}
\end{minipage}%
\begin{minipage}[b]{.45\textwidth}
    \centering
\begin{tabular}{cc}
\toprule
text    &   text    \\
\midrule
text text text & text text text   \\
\bottomrule    
\end{tabular}
    \caption{capt 2}
    \label{tab2}
\end{minipage}

% solution with `tabularx and use the same dummy tables as before
\vspace{3\baselineskip}
    \begin{tabularx}{\linewidth}{>{\hsize=1.1\hsize}C
                                 >{\hsize=0.9\hsize}C}
\begin{tabular}[b]{ccc}
\toprule
text    &   text    &   text    \\
\midrule
text text text    & text text text & text text text   \\
text text text & text text text   \\
\bottomrule
\end{tabular}   &   \begin{tabular}[b]{cc}
                    \toprule
                    text    &   text    \\
                    \midrule
                    text text text & text text text   \\
                    \bottomrule
                    \end{tabular}   \\[-3ex]
\caption{First table}
                &   \caption{Second table}
    \end{tabularx}
\end{table*}
\end{document}
2

Table captions are usually put on top of tables whereas figure captions are put below the graphics. What do you think of this (having had to invent what your code might look like)?

% tablesprob.tex  SE 579912
\documentclass[twocolumn]{article}
\usepackage{lipsum}

\begin{document}

\begin{table*}%[!htb]
\begin{minipage}{.55\textwidth}
    \centering
    \small
    \caption{capt1}
    \begin{tabular}{|c|} \hline
    An entry \\ \hline
    \end{tabular}
%    \caption{capt1}
    \label{tab1}        
\end{minipage}
\begin{minipage}{.45\textwidth}
    \centering
    \small    
    \caption{capt2}
    \begin{tabular}{|l|r|} \hline
    left & right \\ % \hline
    LEFT & RIGHT \\ \hline
    \end{tabular}
%    \caption{capt2}
    \label{tab2}        
\end{minipage}
\end{table*}

Two tables, \ref{tab1} and \ref{tab2}.

\lipsum[1-10]

\end{document}

enter image description here

You must log in to answer this question.

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