Graphics, Figures & TablesSpanning 8 columns over an 9 column table

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
thenightmonkey
Posts: 1
Joined: Thu Mar 10, 2011 4:09 am

Spanning 8 columns over an 9 column table

Post by thenightmonkey »

Hi there,

I have an 9 column table with 3 rows. On the bottom row, I would like to span 8 columns across the 9 columns in the other 2 rows.

Can anyone give me any tips on this?

To give a rough example, I'm looking for something similar to the table in the 'Diatonic Scale' section of the following wikipedia article:

http://en.wikipedia.org/wiki/Just_intonation

Thanks in advance for any help!

Craig

Recommended reading 2024:

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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

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

Spanning 8 columns over an 9 column table

Post by localghost »

This is the mentioned table from the Wikipedia article translated to LaTeX. The \rowstyle command is taken from the TeX FAQ [1].

Code: Select all

\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{array,multirow,tabularx}

\newcolumntype{$}{>{\global\let\currentrowstyle\relax}}
\newcolumntype{^}{>{\currentrowstyle}}
\newcommand{\rowstyle}[1]{%
  \gdef\currentrowstyle{#1}%
  #1\ignorespaces
}

\begin{document}
  \begin{tabular}{|>{\bfseries}$c|*8{^c|}}\hline
    \rowstyle{\bfseries} 
    Note & C & D & E & F & G & A & B & C \\\hline
    Ratio & 1/1 & 9/8 & 5/4 & 4/3 & 3/2 & 5/3 & 15/8 & 2/1 \\\hline
    Natural & 24 & 27 & 30 & 32 & 36 & 40 & 45 & 48 \\\hline
    Cents & 0 &	204 & 386 & 498 & 702 & 884 & 1088 & 1200 \\\hline
    Step &
      \multicolumn{8}{c|}{
        \multirow{2}{*}{
          \begin{tabular}{*8{c|}c}
            & T & t & s & T & t & T & s & \\\cline{2-8}
            & 204 & 182 & 112 & 204 & 182 & 204 & 112 &
          \end{tabular}
        }
      }\\\cline{1-1}
    Cent Step & \multicolumn{8}{c|}{}\\\hline
  \end{tabular}
\end{document}
However, this is tedious and the code becomes quite unclear for more complicated structures.

[1] TeX Frequently Asked Questions — How to change a whole row of a table


Bes regards and welcome to the board
Thorsten
Attachments
Result of the given code.
Result of the given code.
table-xmpl.png (9.05 KiB) Viewed 1620 times
Post Reply