如何在 tabularx 环境中进行多行?

如何在 tabularx 环境中进行多行?

在我的代码中,我试图根据其描述在第一列第二行分配四个短语......

在此处输入图片描述

\documentclass[13pt]{book}

\usepackage{tabularx,booktabs}
\usepackage{multirow}
\begin{document}

\begin{table}
\centering
\caption{Table of Variables}
\begin{tabularx}{\textwidth}{c>{\raggedright}X}
\toprule
\textbf{Variables} & \textbf{Description:} \tabularnewline

\midrule
return on equity (ROE)
& Return on equity can can be found and should be picked from the annual report or quarter report of these 13 commercial banks(See Appendix 2)\tabularnewline

\midrule
Tier 1 capital                      \\
Capital buffer                      \\
Risk-weighted assets                \\
Loan-to-deposit ratio   \\
& Bank-specific factors can be found and should be picked from the annual report or quarter report of these 15 commercial banks(See Appendix 2)
\tabularnewline


\midrule
Ownership
& Using dummy variable to denote ownership. State-owned banks (including BOC, ICBC, CCB, ABC) are equal to 1, the others are equal to 0 \tabularnewline

   \midrule
GDP
& China NBS Quarterly Data\\
 available from 1992-2016 Q1 \tabularnewline

\midrule
Central bank interest rate
&
OECD Data \\
 Short-term interest rates quarterly data\\
Long-term interest rate will be used if available\\
 available from 1997 Q3 - 2015 Q1 \tabularnewline

\bottomrule
\end{tabularx}
\end{table}
\end{document}

答案1

[t]在这种情况下,您只需使用op-aligned设置该单元格中的内容即可tabular

在此处输入图片描述

\documentclass{book}

\usepackage{tabularx,booktabs}

\begin{document}

\begin{table}
  \centering
  \caption{Table of Variables}
  \begin{tabularx}{\textwidth}{ c >{\raggedright\arraybackslash}X }
    \toprule
    \textbf{Variables} & \textbf{Description:} \\
    \midrule
    return on equity (ROE) & Return on equity can can be found and should be picked 
                             from the annual report or quarter report of these~13 
                             commercial banks (See Appendix~2) \\
    \midrule
    \begin{tabular}[t]{ @{}c@{} }
      Tier 1 capital        \\
      Capital buffer        \\
      Risk-weighted assets  \\
      Loan-to-deposit ratio
    \end{tabular}
      & Bank-specific factors can be found and should be picked from the annual 
        report or quarter report of these~15 commercial banks (See Appendix~2) \\
    \midrule
    Ownership & Using dummy variable to denote ownership. State-owned banks (including 
                BOC, ICBC, CCB, ABC) are equal to~1, the others are equal to~0 \\
    \midrule
    GDP & China NBS Quarterly Data \\
        &  available from 1992-2016 Q1 \\
    \midrule
    Central bank interest rate & OECD Data \\
     & Short-term interest rates quarterly data \\
     & Long-term interest rate will be used if available \\
     & available from 1997 Q3 - 2015 Q1 \\
    \bottomrule
  \end{tabularx}
\end{table}

\end{document}

makecell提供类似的解决方案。

答案2

以下是使用 的解决方案makecell:此包定义了两个主要命令,允许换行和对其内容进行通用格式化,\makecell以及thead。我还加载了caption,以便在标题和表格之间留出合适的垂直间距,并将文档的字体大小更改为 12 pt(13pt标准类不存在)。

\documentclass[12pt]{book}

\usepackage{tabularx,booktabs}
\usepackage{makecell, caption}
\renewcommand\theadfont{\normalsize\bfseries}

\begin{document}

\begin{table}
\centering
\caption{Table of Variables}
\begin{tabularx}{\textwidth}{c>{\raggedright}X}
\toprule
\thead{Variables} & \thead{Description} \tabularnewline

\midrule
return on equity (ROE)
& Return on equity can can be found and should be picked from the annual report or quarter report of these 13 commercial banks(See Appendix 2)\tabularnewline

\midrule
\makecell[t]{Tier 1 capital \\
Capital buffer \\
Risk-weighted assets \\
Loan-to-deposit ratio}
& Bank-specific factors can be found and should be picked from the annual report or quarter report of these 15 commercial banks(See Appendix 2)
\tabularnewline
\midrule
Ownership
& Using dummy variable to denote ownership. State-owned banks (including BOC, ICBC, CCB, ABC) are equal to 1, the others are equal to 0 \tabularnewline

   \midrule
GDP
& China NBS Quarterly Data\\
 available from 1992-2016 Q1 \tabularnewline

\midrule
Central bank interest rate
&
OECD Data \\
 Short-term interest rates quarterly data\\
Long-term interest rate will be used if available\\
 available from 1997 Q3 - 2015 Q1 \tabularnewline

\bottomrule
\end{tabularx}
\end{table}

\end{document} 

在此处输入图片描述

相关内容