3

I have a problem a with alignment getting and the tabularx environment with a stretched table.

Currently, I have the following table:

\documentclass{article}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{ragged2e}
\newcolumntype{Y}{ >{\hsize=1.75\hsize}X}
\newcolumntype{Z}{ >{\hsize=.875\hsize\RaggedLeft}X}
\begin{document}
     \noindent
    \begin{tabularx}{.75\textwidth}{@{\,\,}Y *{6}{Z}@{\,\,}}{\columnwidth}{@{\extracolsep{\stretch{1}}}*{7}{r}@{}}
        \toprule   
        Category & Strategies & Institutional Index: \\ 
                                        & & Barclay's Event Driven Hedge Fund Index \\   
        \midrule   
        \multirow{2}{*}{ Momentum } & TSMOM(1,1) & 0.00   \\   
                                    & TSMOM(3,3) & 0.01   \\   
        \multirow{5}{*}{ Size } & Top Decile & 0.0440 \\
        & $9^{th}$ Decile & 0.0520 \\
        & Bottom Decile & 0.1480\\
        & $2^{nd}$ Decile & 0.0455\\
        & Top Minus Bottom & 0.3340\\
        \multirow{7}{*}{ Value } & Top Decile & 0.0615   \\
        & Bottom Decile & 0.1710 \\
        & Top Minus Lowest (Decile) & 0.4175 \\
        & Top $30^{th}$ Percentile & 0.0730 \\
        & Mid $40^{th}$ Percentile & 0.0575 \\
        & Bottom $30^{th}$ Percentile & 0.1015 \\
        & Highest Minus Lowest ($30^{th}$ Percentile) & 0.4425 \\
        \bottomrule                              
    \end{tabularx}
\end{document}

The table looks as follows:

enter image description here When I try to compile the above code, it gives me an error saying "missing number treated as 0". Could someone give me a solution so as to help with the alignment in tabularx ?

I have looked up other threads but was not able to find as I just get this error. I am still a bit new to latex and am using lyx.

Thank you

  • 1
    Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – Seamus Feb 22 '16 at 8:32
  • I just attached picture and added the accompanying compilable code – PutsandCalls Feb 22 '16 at 8:37
  • 1
    Don't post the code that does compile: post the code that gives the error you're seeing! :) – Mark Feb 22 '16 at 8:41
  • 1
    just edited, sorry about that. I will keep it in mind in future posts ! – PutsandCalls Feb 22 '16 at 8:44
1

Some additional formatting-related comments:

  • Use \textsuperscript, not math mode, to raise the strings "th" and "nd" to superscript positions. (Aside: Better still, don't raise these strings to superscript positions at all...)

  • Use whitespace between groups of rows to provide visual clues as to which categories apply to which strategies.

  • Let LaTeX do the tedious work of aligning numbers on their decimal markers: load the siunitx package and use that package's S column type for the third column.

enter image description here

\documentclass{article}
\usepackage{tabularx,booktabs,ragged2e,siunitx}
\newcolumntype{L}{ >{\RaggedRight}X }
\begin{document}
\noindent
\begin{tabularx}{\textwidth}{@{} l L S[table-format=1.4] @{}}
    \toprule
    Category & Strategies & {Institutional Index:} \\
    & & {Barclays' Event Driven} \\
    & & {Hedge Fund Index} \\
    \midrule
    Momentum  & TSMOM(1,1) & 0.00  \\
         & TSMOM(3,3) & 0.01  \\ \addlinespace
    Size & Top Decile & 0.0440 \\
         & 9\textsuperscript{th} Decile & 0.0520 \\
         & Bottom Decile & 0.1480\\
         & 2\textsuperscript{nd} Decile & 0.0455\\
         & Top minus Bottom & 0.3340\\ \addlinespace
    Value& Top Decile & 0.0615   \\
         & Bottom Decile & 0.1710 \\
         & Top minus Lowest (Decile) & 0.4175 \\
         & Top 30\textsuperscript{th} Percentile & 0.0730 \\
         & Mid 40\textsuperscript{th} Percentile & 0.0575 \\
         & Bottom 30\textsuperscript{th} Percentile & 0.1015 \\
         & Highest minus Lowest 30\textsuperscript{th} Percentile & 0.4425 \\
    \bottomrule
\end{tabularx}
\end{document}
| improve this answer | |
  • Thank you for the advice, It looks a lot more neat now ! – PutsandCalls Feb 22 '16 at 10:28
2
\documentclass{article}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{ragged2e}
\newcolumntype{Y}{ >{\Centering}X}
\begin{document}
\noindent
\begin{tabularx}{\textwidth}{@{} r l @{} Y @{}}
    \toprule   
    Category & Strategies & Institutional Index: \\ 
    & & Barclay's Event Driven Hedge Fund Index \\   
    \midrule   
    \multirow{2}{*}{ Momentum } & TSMOM(1,1) & 0.00\phantom{00}   \\   
    & TSMOM(3,3) & 0.01\phantom{00}   \\   
    \multirow{5}{*}{ Size } & Top Decile & 0.0440 \\
    & $9^{th}$ Decile & 0.0520 \\
    & Bottom Decile & 0.1480\\
    & $2^{nd}$ Decile & 0.0455\\
    & Top Minus Bottom & 0.3340\\
    \multirow{7}{*}{ Value } & Top Decile & 0.0615   \\
    & Bottom Decile & 0.1710 \\
    & Top Minus Lowest (Decile) & 0.4175 \\
    & Top $30^{th}$ Percentile & 0.0730 \\
    & Mid $40^{th}$ Percentile & 0.0575 \\
    & Bottom $30^{th}$ Percentile & 0.1015 \\
    & Highest Minus Lowest ($30^{th}$ Percentile) & 0.4425 \\
    \bottomrule                              
\end{tabularx}
\end{document}

enter image description here

| improve this answer | |

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.