Graphics, Figures & TablesHelp with a centering a multicolum heading

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
amzi160586
Posts: 4
Joined: Sat Mar 14, 2009 8:44 pm

Help with a centering a multicolum heading

Post by amzi160586 »

Hi all,

Im currently in the process of writing up my final year thesis and I've been trying to center a column heading over the space of 6 columns in a multicolumn table. For some reason, the part of the text "Binomial Method starts at the beginning of column 3, but wont center between the columns 3 and 8. Here is the code i've got so far, anyone have any ideas???

Code: Select all

\begin{table}[ht]
\caption{Black Scholes Vs Binomial values for European Call} % title of Table
\centering
\small
\begin{tabular}{l*{6}{c}r}
\hline\hline
\multicolumn{8}{c}{Binomial Method} \\
\cline{3-8}
T & Black Scholes & M=16 & M=32 & M=64 & M=128 & M=256  & M=512\\
\hline\hline
0.25 & 0.0875 & 0.0836	& 0.0879 & 0.0877 & 0.0869 & 0.0869 & 0.0875\\
0.50 & 0.3620 & 0.3652  & 0.3623 & 0.3646 & 0.3634 & 0.3618 & 0.3615\\
0.75 & 0.6808 & 0.6804	& 0.6908 & 0.6840 & 0.6825 & 0.6822 & 0.6815\\
1.00 & 1.0031 & 1.0356	& 1.0135 & 1.0069 & 1.0069 & 1.0049 & 1.0031\\
2.00 & 2.1907 & 2.2166	& 2.2271 & 2.2054 & 2.1971 & 2.1953 & 2.1930\\
\hline\hline
\end{tabular}
\label{Table 5 - Black Scholes Vs Binomial values European Call}
\end{table}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Help with a centering a multicolum heading

Post by localghost »

The key is that you have to center the entry in the first line of your table only over the last six columns.

Code: Select all

& & \multicolumn{6}{c}{Binomial Method} \\
With some additional packages you can tweak your table a little bit.

Code: Select all

\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{babel}
\usepackage[font=small,labelfont=bf,tableposition=top]{caption}
\usepackage{booktabs,multirow}
\usepackage{lmodern}

\begin{document}
  \begin{table}[!ht]
    \caption{Black Scholes Vs Binomial values for European Call}\label{tab:BSvsBvEC}
    \centering
    \small
    \begin{tabular}{l*{6}{c}r} \toprule
      \multirow{2}{*}[-0.5ex]{T} & \multirow{2}{*}[-0.5ex]{Black Scholes} & \multicolumn{6}{c}{Binomial Method} \\ \cmidrule{3-8}
      &  & M=16 & M=32 & M=64 & M=128 & M=256 & M=512\\ \midrule[0.8pt]
      0.25 & 0.0875 & 0.0836 & 0.0879 & 0.0877 & 0.0869 & 0.0869 & 0.0875 \\
      0.50 & 0.3620 & 0.3652 & 0.3623 & 0.3646 & 0.3634 & 0.3618 & 0.3615 \\
      0.75 & 0.6808 & 0.6804 & 0.6908 & 0.6840 & 0.6825 & 0.6822 & 0.6815 \\
      1.00 & 1.0031 & 1.0356 & 1.0135 & 1.0069 & 1.0069 & 1.0049 & 1.0031 \\
      2.00 & 2.1907 & 2.2166 & 2.2271 & 2.2054 & 2.1971 & 2.1953 & 2.1930 \\ \bottomrule
    \end{tabular}
  \end{table}
\end{document}
Information about the used packages can be found on CTAN.


Best regards and welcome to the board
Thorsten¹
amzi160586
Posts: 4
Joined: Sat Mar 14, 2009 8:44 pm

Help with a centering a multicolum heading

Post by amzi160586 »

Thanks for your help Thorsten. Im kinda new latex but once again many thanks for you great advice.

It seems as if i'm not getting to grips with how to set the distance between the two lines. Any chance you could give me any adivce with regards to the followg???

Code: Select all

\begin{table}[ht]
\caption{Black Scholes: European Call w/Continuous Dividend Yield} % title of Table
\centering
\begin{tabular}{c c c c c c}
\hline\hline
T & D=30 & D=20 & D=15 & D=10 & D=4\\ [0.5ex]
%heading
\hline\hline
0.25 & 0.0410 & 0.0532 & 0.0605	& 0.0685 & 0.0794\\
0.50 & 0.1409 & 0.1959 & 0.2295 & 0.2683 & 0.3217\\
0.75 & 0.2264 & 0.3339 & 0.4022	& 0.4819 & 0.5944\\
1.00 & 0.2894 & 0.4504 & 0.5560	& 0.6814 & 0.8620\\
2.00 & 0.0410 & 0.0532 & 0.0605	& 0.0685 & 0.0794\\[1ex]
\hline\hline
\end{tabular}
\label{Table 3 - Black Scholes values for a European Call w/Continuous Dividend Yield}
\end{table}
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Help with a centering a multicolum heading

Post by localghost »

As already mentioned in my last reply, you should take a look at the booktabs package. I already modified your first table with code from that package. Here is the table from your last post.

Code: Select all

\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{babel}
\usepackage[font=small,labelfont=bf,tableposition=top]{caption}
\usepackage{booktabs}
\usepackage{lmodern}

\begin{document}
  \begin{table}[!ht]
    \caption{Black Scholes: European Call w/Continuous Dividend Yield}\label{tab:BSvECcDY}
    \centering
    \begin{tabular}{c c c c c c}\toprule
      T & D=30 & D=20 & D=15 & D=10 & D=4 \\\midrule
      0.25 & 0.0410 & 0.0532 & 0.0605 & 0.0685 & 0.0794 \\
      0.50 & 0.1409 & 0.1959 & 0.2295 & 0.2683 & 0.3217 \\
      0.75 & 0.2264 & 0.3339 & 0.4022 & 0.4819 & 0.5944 \\
      1.00 & 0.2894 & 0.4504 & 0.5560 & 0.6814 & 0.8620 \\
      2.00 & 0.0410 & 0.0532 & 0.0605 & 0.0685 & 0.0794 \\\bottomrule
    \end{tabular}
  \end{table}
\end{document}
The package also provides code to set specific interline space. Refer to its manual to learn more.
amzi160586
Posts: 4
Joined: Sat Mar 14, 2009 8:44 pm

Re: Help with a centering a multicolum heading

Post by amzi160586 »

Thanks again, I really appreciate your help at this moment in time!:)
Post Reply