3

How can I create the following table in latex? I am not sure what concept is used to create this table. Are these two independent sub-tables combined in one? Any pointers or suggestions are appreciated.

enter image description here

1
  • See wikibooks on latex, tables for the basics en.wikibooks.org/wiki/LaTeX/Tables. // There are several options, e.g. using one table with 5 columns, or a minipage with 2 tables and 2 columns each. For the special layout check package booktabs ctan.org/pkg/booktabs. See alse the Related links to the right.
    – MS-SPO
    Jan 21, 2023 at 5:26

2 Answers 2

4

It's not difficult to reproduce the picture; the key is to have two top aligned tabular environments.

\documentclass{article}
\usepackage{booktabs}

\begin{document}

\begin{table}[htp]
\centering

\begin{tabular}[t]{lr}
\textbf{Metric} & \textbf{Percent} \\
\toprule
\textbf{Gender} \\
Male & 54 \\
Female & 46 \\
\midrule
\textbf{Education} \\
B.S. or above & 49 \\
Some college & 39 \\
H.S. or below & 13 \\
\midrule
\textbf{Age} \\
18-29 years & 34 \\
30-49 years & 55 \\
50-64 years & 9 \\
65+ years & 1 \\
\midrule
\end{tabular}
\begin{tabular}[t]{lr}
\textbf{Metric} & \textbf{Percent} \\
\toprule
\textbf{Ethnicity} \\
Caucasian & 78 \\
African Am. & 10 \\
Asian & 1 \\
Hispanic & 7 \\
\midrule
\textbf{Smartphone} \\
\textbf{Use} \\
9+ & 10 \\
6-9 & 13 \\
3-6 & 38 \\
0-3 & 39 \\
No smartphone & $<$1 \\
\bottomrule
\end{tabular}

\caption{Whatever}

\end{table}

\end{document}

enter image description here

An improved version with less rules and en-dashes instead of hyphens.

\documentclass{article}
\usepackage{booktabs}

\begin{document}

\begin{table}[htp]
\centering

\begin{tabular}{@{}c@{}}
\toprule
\begin{tabular}[t]{@{}lr@{}}
Metric & Percent \\
\midrule
\textit{Gender} \\
Male & 54 \\
Female & 46 \\
\addlinespace
\textit{Education} \\
B.S. or above & 49 \\
Some college & 39 \\
H.S. or below & 13 \\
\addlinespace
\textit{Age} \\
18--29 years & 34 \\
30--49 years & 55 \\
50--64 years & 9 \\
65+ years & 1 \\
\end{tabular}\qquad
\begin{tabular}[t]{@{}lr@{}}
Metric & Percent \\
\midrule
\textit{Ethnicity} \\
Caucasian & 78 \\
African Am. & 10 \\
Asian & 1 \\
Hispanic & 7 \\
\addlinespace
\textit{Smartphone use} \\
9+ & 10 \\
6--9 & 13 \\
3--6 & 38 \\
0--3 & 39 \\
No smartphone & $<$1 \\
\end{tabular} \\
\bottomrule
\end{tabular}

\caption{Whatever}

\end{table}

\end{document}

enter image description here

3

a simple example - do try and show your effort next time since typing in all the details in the table contents is tiresome

\documentclass[12pt,letterpaper]{article}    
\usepackage[left=20mm,top=30mm,bottom=30mm,right=20mm]{geometry}
\usepackage{booktabs} % format SI units

\begin{document}


    \begin{table}
        \centering
        \caption{Example of two independent sub-tables with booktabs package}
        \begin{tabular}{lr}
%           \toprule
            \textbf{Metric} & \textbf{Percent} \\
            \toprule
            \textbf{Gender} & \\
            1 & 2 \\
            \midrule
            \textbf{Education} & \\
            3 & 4 \\
            \bottomrule
        \end{tabular}
        \quad
        \begin{tabular}{lr}
%           \toprule
            \textbf{Metric} & \textbf{Percent} \\
            \toprule
            \textbf{Ethnicity} & \\
            5 & 6 \\
            \midrule
            \textbf{Smartphone} & \\
            7 & 8 \\
            \bottomrule
        \end{tabular}
    \end{table}
        
\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 .