0

I am making a table with text but not able to produce it in the right form.

A minimal working example is given below.

      \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} 

The actual table should look like this. Desired TableAny help will be appreciated.

  • What are you trying to obtain? – Bernard Nov 15 '16 at 12:43
  • 1
    @AhmedArif: 'working' means the document can be processes without errors by LaTeX. Your document can't. For example the \begin{tabulary}{\columnwith}{p{6cm}p{2cm} line has two errors. \columnwith must be \columnwidth and there is a missing }. Also you use `multirow` without loading the package. Please check the document before posting it. And then you don't tell us what the right form is. How should we know? – Pieter van Oostrum Nov 15 '16 at 12:45
  • @Bernard and Piet Van Oostrum, I have edited the codes and added the desired form of the Table. – Ahmed Arif Nov 15 '16 at 13:50
  • @PietvanOostrum I have also added the relevant package. – Ahmed Arif Nov 15 '16 at 13:55
3

Maybe this looks like what you want?

\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} 

enter image description here

Comment aside: package times is totally deprecated. Use newtxtext and newtxmath instead.

  • Did you apply fixes beyond the ones I suggested in my answer? Just curious. – Mico Nov 15 '16 at 14:51
  • 1
    @Mico: I suppose so since I copied the OP's code (fixed, he said) and some others – a missing closing brace in the table preamble, which I finally replaced, as you can see (no tabulary column type in the preamble!) – Bernard Nov 15 '16 at 15:06
  • Thanks. I hadn't noticed you're no longer using tabulary... – Mico Nov 15 '16 at 15:07
  • ào: ?? I'm using it on the contrary (J type). I meant the O.P. declared a tabulary environment but did not use any of its column types. But maybe did I misuse it? I'm not very familiar with this package. – Bernard Nov 15 '16 at 15:12
1

There are (at least) three errors in your code:

  • You need to load the multirow package in the preamble, via \usepackage{multirow}.

  • The code snippet

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

    should be

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

    Note the spelling of "columnwidth" and the addition of a closing curly brace.

  • Instead of

    \end document
    

    you must write

    \end{document}
    

If you apply these fixes, the code will compile. Of course, I don't know if the table's contents are correct or not.

  • after applying the fixed, it still does not work. – Ahmed Arif Nov 15 '16 at 13:56
  • 1
    @AhmedArif - In that case, there's something about your code you haven't revealed yet. For sure, if apply the fixes, the code -- as posted by you -- does compile. Please be more specific; a comment such as "it still does not work" is not particularly helpful. – Mico Nov 15 '16 at 14:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.