包含文本和数字的表格

包含文本和数字的表格

我正在制作一个带有文本的表格,但无法以正确的形式呈现它。

下面给出了一个最小的工作示例。

      \documentclass[12pt, a4paper, twoside]{article}
      \usepackage{titlesec}
      \usepackage[T1]{fontenc}
      \usepackage{times}
      \usepackage[latin9]{inputenc}
      \usepackage[english]{babel}
      \usepackage{float}
      \usepackage{url}
      \usepackage{setspace}
      \onehalfspacing
      \usepackage{titlesec}
      \usepackage{caption}% <-- added
      \usepackage{tabulary}
      \usepackage[para]{threeparttable}
      \usepackage{array,booktabs,longtable,tabularx}
      \newcolumntype{L}{>{\raggedright\arraybackslash}X}% <-- added
      \usepackage{caption}% <-- added
      \setlength{\LTcapwidth}{7in}
      \usepackage{ltablex}% <-- added
      \usepackage{siunitx}% <-- added
      \usepackage[flushleft]{threeparttablex}
      \usepackage{pdflscape}
      \usepackage{amssymb}
      \usepackage{multirow}
      \begin{document}
      Some text in the main section 
      \begin{table}[htbp]
        \centering
        \caption{Asset Details}
          \begin{tabulary}{\columnwidth}{p{6cm}p{2cm}
          \toprule
          \textbf{Item} & \textbf{Factor} \\
          \midrule
          \multicolumn{2}{c}{\textbf{Details }} \\
          \midrule
          \textbf{A. Level 1 } &  \\
          \midrule
          All the assets held by the bank  & \multirow{4}[2]{*}{100\%} \\
          Some of important assets held by the bank.  &  \\
          Some other text will be added here. This text can be long as well.  &  \\
          More Text &  \\
          \midrule
          \multicolumn{1}{l}{\textbf{Level 2}} &  \\
          \midrule
          \textbf{Level 2A assets} &  \\
          \midrule
          Some 2A Assets  & \multirow{3}[2]{*}{85\%} \\
          Bank Debt &  \\
          \textit{\textbf{Some more text }} &  \\
          \midrule
          \textbf{Level 2B assets (maximum of 15\% of HQLA)} &  \\
          \midrule
          \textit{\textbf{Assets of High Quality}} & 75\% \\
          Assets of Lower Quality  & 50\% \\
          Assets of Lower Quality  & 50\% \\
          \bottomrule
          \end{tabulary}%
        \label{tab:asset}%
      \end{table}%
     \end{document} 

实际的表格应该是这样的。所需表任何帮助将不胜感激。

答案1

也许这看起来就像你想要的?

\documentclass[12pt, a4paper, twoside]{article}
\usepackage{titlesec}
\usepackage[T1]{fontenc}
\usepackage{times}
\usepackage[latin9]{inputenc}
\usepackage[english]{babel}
\usepackage{float}
\usepackage{url}
\usepackage{setspace}
\onehalfspacing
\usepackage{titlesec}
\usepackage{caption}% <-- added
\usepackage{tabulary}
\usepackage[para]{threeparttable}
\usepackage{array,booktabs,longtable,tabularx}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}% <-- added
\usepackage{caption}% <-- added
\setlength{\LTcapwidth}{7in}
\usepackage{ltablex}% <-- added
\usepackage{siunitx}% <-- added
\usepackage[flushleft]{threeparttablex}
\usepackage{pdflscape}
\usepackage{amssymb}
\usepackage{multirow}
\setlength\defaultaddspace{2ex}
\begin{document}
Some text in the main section
\begin{table}[htbp]
  \centering
  \caption{Asset Details}
  \begin{tabulary}{\linewidth}{Jc}
    \toprule
    \textbf{Item} & \textbf{Factor} \\
    \multicolumn{2}{c}{\textbf{Details }} \\
    \midrule
    \textbf{A. Level 1 } & \\
    \midrule
    All the assets held by the bank & \multirow{4}[2]{*}{100\,\%} \\
    \addlinespace
    Some of important assets held by the bank. \\
    \addlinespace
    Some other text will be added here. This text can be long as well. \\
    \addlinespace
    More Text \\
    \midrule
    \multicolumn{1}{l}{\textbf{Level 2}} \\
    \addlinespace[0.5ex]
    \textbf{Level 2A assets} & \\
    \midrule
    Some 2A Assets & \multirow{3}[2]{*}{85\,\%} \\
    \addlinespace
    Bank Debt \\
    \addlinespace
    \textit{\textbf{Some more text }} \\
    \midrule
    \textbf{Level 2B assets (maximum of 15\,\% of HQLA)} & \\
    \midrule
    \textit{\textbf{Assets of High Quality}} & 75\,\% \\
    \addlinespace
    Assets of Lower Quality & 50\,\% \\
    \addlinespace
    Assets of Lower Quality & 50\,\% \\
    \bottomrule
  \end{tabulary}%
  \label{tab:asset}%
\end{table}%

\end{document} 

在此处输入图片描述

除了注释之外:该软件包times已完全弃用。请使用 newtxtextnewtxmath代替。

答案2

您的代码中至少有 3 个错误:

  • 您需要multirow通过 加载序言中的包\usepackage{multirow}

  • 代码片段

    \begin{tabulary}{\columnwith}{p{6cm}p{2cm}
    

    应该

    \begin{tabulary}{\columnwidth}{p{6cm}p{2cm}}
    

    请注意“columnwidth”的拼写以及结束花括号的添加。

  • 代替

    \end document
    

    你必须写

    \end{document}
    

如果你应用这些修复,代码将会编译。当然,我不知道表的内容是否正确。

相关内容