3

I've been struggling with this for a while.

1.) I want the 2.5 and 97.5 to appear distinctly from the "Percentile" label but still in the same cell.

2.) I want the 2.5 to appear centered around the "P" in "Percentile and I want the 97.5 to appear centered around the last e in "percentile"

3.) the 0.05 and 0.57 should appear directly below the 2.5 and 97.5 respectively (in their new positions)

Baz

\usepackage{multirow}

\begin{tabular}{l|cc}
\hline
\multicolumn{3}{c}{Steepener Sharpe Ratio Estimation Results} \\
\cline{1-3}
\multicolumn{1}{c|}{\multirow{2}{*}{Estimate} }  &  \multicolumn{2}{c}{\multirow{2}{*}{Percentile}} \\
\multicolumn{1}{c|}{} &  \multicolumn{1}{c}{2.5} &  \multicolumn{1}{c}{97.5} \\
\cline{2-3} 
TNA & 0.05 & 0.57 \\
\hline
\end{tabular}
  • 2
    Please provide a compilable Minimum Working Example as that it is much more useful than a mere fragment of code. May I ask why you want to do this? That is, why do you want things centered on the first and last letter of the column header? I ask because I don't think this will be straightforward at all. You could do it using TiKZ, for example, but you are trying to do something with tabular which is not really what tabular is intended to do. That is, you are not really trying to typeset a table but something effectively closer to a graphic. – cfr Sep 14 '14 at 14:37
  • I have flexibility is the formatting so I'm happy to go with a simpler layout that displays the same data – Bazman Sep 14 '14 at 14:45
4

I suggest you take the following steps:

  • Use a table environment, with a \caption that's distinct from the tabular material itself. The caption can be placed either above or below the tabular material. In the example below I use \caption* -- a macro provided by the caption package -- to create an unnumbered table float. (If you want a "regular", i.e., numbered table float, use \caption instead of \caption*.)

  • Use the line-drawing commands of the booktabs package to get well-spaced horizontal lines.

  • Don't use vertical lines -- they merely add visual clutter. (If you don't believe me, try to create a few tables for yourself, first with vertical lines and then without. Ask yourself critically if any of the vertical lines in any of your tables truly add visual clarity.)

The following screenshot shows both your current table as well as the one I suggest.

enter image description here

\documentclass{article}
\usepackage{multirow}          % for old code
\usepackage{booktabs,caption}  % for new code
\begin{document}

before:
\begin{center}
\begin{tabular}{l|cc}
\hline
\multicolumn{3}{c}{Steepener Sharpe Ratio Estimation Results} \\
\cline{1-3}
\multicolumn{1}{c|}{\multirow{2}{*}{Estimate} }  &  \multicolumn{2}{c}{\multirow{2}{*}{Percentile}} \\
\multicolumn{1}{c|}{} &  \multicolumn{1}{c}{2.5} &  \multicolumn{1}{c}{97.5} \\
\cline{2-3} 
TNA & 0.05 & 0.57 \\
\hline
\end{tabular}
\end{center}

\bigskip
new:
\begin{table}[h!] % "[h!]" location specifier just for this example
\caption*{Steepener Sharpe Ratio Estimation Results}
\centering
\begin{tabular}{lcc}
\toprule
Estimate & \multicolumn{2}{c}{Percentile} \\
\cmidrule{2-3}
& 2.5 & 97.5 \\
\midrule
TNA & 0.05 & 0.57 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
  • Is there any way to make the \cmidrule line lighter, with lighter meaning thinner or greysh? – Mengops May 28 '15 at 17:49
  • 1
    @Mengops - Absolutely. The default value of \cmidrulewidth is 0.03em. To change it to, say, 0.02em, you'd issue the command \setlength\cmidrulewidth{0.02em}. – Mico May 28 '15 at 18:35
  • I've tried your solution, but after compiling, nothing changes. may it be due to the fact that I'm using a report documentclass? If so how can I solve it? – Mengops Jun 2 '15 at 15:59
  • 1
    @Mengops - I'm afraid a term such as "nothing changes" is not very informative. I suggest you post a new query, in which you state what you're trying to achieve and what you've tried so far. – Mico Jun 2 '15 at 16:23
4

May be this would do:

\documentclass{article}
\usepackage{multirow}
\begin{document}
{\centering
Steepener Sharpe Ratio Estimation Results

\begin{tabular}{l|cc}
%\hline
%\multicolumn{3}{c}{Steepener Sharpe Ratio Estimation Results} \\
\cline{1-3}
\multirow{2}{*}{Estimate}  &  \multicolumn{2}{c}{Percentile} \\
 &  2.5 &  97.5 \\
\cline{2-3}
TNA & 0.05 & 0.57 \\
\hline
\end{tabular}
\par
}
\end{document}

enter image description here

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.