只有两列的表格

只有两列的表格

我有一张只有 2 列的表格。我希望列宽等于文本宽度(因为我认为这样看起来更好?)。但是,到目前为止,它们看起来有点不对劲。有没有更好的方法可以在 Latex 中得到一个简单、美观的 2 列表格?

以下是我的表格的 3 个版本:

\documentclass[DIV12, a4paper, 12pt, listof=totocnumbered, bibliography=totoc]{book}
\usepackage{threeparttable}
\usepackage{longtable, booktabs, tabularx}
\usepackage{blindtext}

\begin{document}

\blindtext

\begin{table}[h]
  \centering
  \caption{Search terms and FEARS indices}
  \label{tab1:fears}
  \begin{threeparttable}
\begin{tabularx}{\textwidth}{X|X}
\toprule
  \textbf{Micro FEARS} & \textbf{Macro FEARS} \\
\hline
Job search & National debt  \\
Job openings & The depression  \\
New job & Great depression  \\
Job opportunities & The great depression  \\
Job application & Inflation  \\
Job bank & Inflation rate  \\
Unemployment benefits & Cost of living  \\
Unemployment rate & Recession \\
Unemployment office &   \\
Unemployment insurance & \\
Debt collection & \\
Bankruptcy & \\
Bankruptcy court & \\
Chapter 7 & \\
Filing bankruptcy & \\
Chapter 13 & \\
Credit debt & \\
Debt consolidation & \\
Credit card debt & \\
\bottomrule
\end{tabularx}
  \begin{tablenotes}[para,flushleft]
  \footnotesize
  \item\hspace{-2.5pt}\noindent\textit{Note:} This table presents Google search terms separated by microeconomic FEARS and macroeconomic FEARS. In total, we have 27 search terms, 19 for microeconomic FEARS and 8 for macroeconomic FEARS.
  \end{tablenotes}
  \end{threeparttable}
\end{table}

\blindtext

\begin{table}[h]
  \centering
  \caption{Search terms and FEARS indices}
  \label{tab1:fears}
  \begin{threeparttable}
\begin{tabular*}{\textwidth}{c @{\extracolsep{\fill}}c}
\toprule
  \textbf{Micro FEARS} & \textbf{Macro FEARS} \\
\hline
Job search & National debt  \\
Job openings & The depression  \\
New job & Great depression  \\
Job opportunities & The great depression  \\
Job application & Inflation  \\
Job bank & Inflation rate  \\
Unemployment benefits & Cost of living  \\
Unemployment rate & Recession \\
Unemployment office &   \\
Unemployment insurance & \\
Debt collection & \\
Bankruptcy & \\
Bankruptcy court & \\
Chapter 7 & \\
Filing bankruptcy & \\
Chapter 13 & \\
Credit debt & \\
Debt consolidation & \\
Credit card debt & \\
\bottomrule
\end{tabular*}
  \begin{tablenotes}[para,flushleft]
  \footnotesize
  \item\hspace{-2.5pt}\noindent\textit{Note:} This table presents Google search terms separated by microeconomic FEARS and macroeconomic FEARS. In total, we have 27 search terms, 19 for microeconomic FEARS and 8 for macroeconomic FEARS.
  \end{tablenotes}
  \end{threeparttable}
\end{table}

\blindtext

\begin{table}[h]
  \centering
  \caption{Search terms and FEARS indices}
  \label{tab1:fears}
  \begin{threeparttable}
\begin{tabularx}{\textwidth}{cc}
 \toprule
Micro FEARS & Macro FEARS  \\
\midrule
Job search & National debt  \\
Job openings & The depression  \\
New job & Great depression  \\
Job opportunities & The great depression  \\
Job application & Inflation  \\
Job bank & Inflation rate  \\
Unemployment benefits & Cost of living  \\
Unemployment rate & Recession \\
Unemployment office &   \\
Unemployment insurance & \\
Debt collection & \\
Bankruptcy & \\
Bankruptcy court & \\
Chapter 7 & \\
Filing bankruptcy & \\
Chapter 13 & \\
Credit debt & \\
Debt consolidation & \\
Credit card debt & \\
\bottomrule
  \end{tabularx}
  \begin{tablenotes}[para,flushleft]
  \footnotesize
  \item\hspace{-2.5pt}\noindent\textit{Note:} This table presents Google search terms separated by microeconomic FEARS and macroeconomic FEARS. In total, we have 27 search terms, 19 for microeconomic FEARS and 8 for macroeconomic FEARS.
  \end{tablenotes}
  \end{threeparttable}
\end{table}

\end{document}

在此处输入图片描述

答案1

对我来说,这看起来不错

设计

\begin{table}[h]
    \abovetopsep=1ex % skip before toprule
    \centering
    \caption{Search terms and FEARS indices}
    \label{tab1:fears}
    \begin{threeparttable}
        \begin{tabularx}{0.75\linewidth}{%
            @{}>{\hsize=1.2\hsize}X
            >{\hsize=0.8\hsize}X@{}
            }
            \toprule
            \textbf{Micro FEARS}   & \textbf{Macro FEARS} \\
            \midrule % use \midrule instead of \hline
            Job search             & National debt        \\
            Job openings           & The depression       \\
            New job                & Great depression     \\
            Job opportunities      & The great depression \\
            Job application        & Inflation            \\
            Job bank               & Inflation rate       \\
            Unemployment benefits  & Cost of living       \\
            Unemployment rate      & Recession            \\
            Unemployment office    &                      \\
            Unemployment insurance &                      \\
            Debt collection        &                      \\
            Bankruptcy             &                      \\
            Bankruptcy court       &                      \\
            Chapter 7              &                      \\
            Filing bankruptcy      &                      \\
            Chapter 13             &                      \\
            Credit debt            &                      \\
            Debt consolidation     &                      \\
            Credit card debt       &                      \\
            \bottomrule
        \end{tabularx}
        \begin{tablenotes}[para,flushleft]
            \footnotesize
            \item\hspace{-2.5pt}\noindent\textit{Note:} This table presents Google search terms separated by microeconomic FEARS and macroeconomic FEARS. In total, we have 27 search terms, 19 for microeconomic FEARS and 8 for macroeconomic FEARS.
        \end{tablenotes}
    \end{threeparttable}
\end{table}

答案2

我希望列宽等于文本宽度(因为我认为这样看起来更好?)

完全不是。让表格比实际更宽并没有什么好处,反而会适得其反。在这种情况下,没有比这更好的办法了,\begin{tabular}{ll}但如果你坚持的话,这可能是我的方法:

  1. 使用tabulary而不是tabularx按内容比例设置第二列的宽度。

  2. \tabcolsep尽可能增加而不产生任何换行,将这些列的文本稍微居中。

结果可能是这样的:

姆韦

\documentclass{article}
\usepackage{booktabs, tabularx,tabulary}
\begin{document}

\begin{table}[h]
\tabcolsep3.5em
\belowcaptionskip1ex
\caption{Search terms and FEARS indices}
\begin{tabulary}{\textwidth}{LL}
\toprule
  \textbf{Micro FEARS} & \textbf{Macro FEARS} \\
\midrule
Job search & National debt  \\
Job openings & The depression  \\
New job & Great depression  \\
Job opportunities & The great depression  \\
Job application & Inflation  \\
Job bank & Inflation rate  \\
Unemployment benefits & Cost of living  \\
... & ... \\
\bottomrule
\end{tabulary}
\end{table}
\end{document}

相关内容