11

I'm interested in methods to create a vertical line in a table that spans a range of rows but not all rows. I've found one solution below, but is there another solution such as \cline which allows you to specify which columns you would like your horizontal line to span?

http://www.latex-community.org/forum/viewtopic.php?f=45&t=3849

Vertical line that spans all rows

\documentclass[a4paper]{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\begin{document}

\begin{tabular}{c c|c c c c|}
  \multicolumn{2}{c}{} & Piano & Trumpet & Flute & Viola\\
  \multicolumn{2}{c}{}& \textbf{pno} & \textbf{tpt} & \textbf{flt} & \textbf{vla}\\
  \cline{3-6}
  Piano & \textbf{pno} & 0 & 0.5 & 0.25 & 0.75\\
  Trumpet & \textbf{tpt} & 0 & 0 & 0.25 & 0.5\\
  Flute & \textbf{flt} & 0 & 0 & 0 & 0.75\\
  Viola & \textbf{vla} & 0& 0 & 0 & 0\\
  \cline{3-6}
\end{tabular}

\end{document}

Vertical line that spans a range of rows

\documentclass[a4paper]{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\begin{document}

\begin{tabular}{c c|c c c c|}
\multicolumn{2}{c}{} & Piano & Trumpet & Flute & \multicolumn{1}{c}{Viola}\\
\multicolumn{2}{c}{}& \textbf{pno} & \textbf{tpt} & \textbf{flt} & \multicolumn{1}{c}{\textbf{vla}}\\
\cline{3-6}
Piano & \textbf{pno} & 0 & 0.5 & 0.25 & 0.75\\
Trumpet & \textbf{tpt} & 0 & 0 & 0.25 & 0.5\\
Flute & \textbf{flt} & 0 & 0 & 0 & 0.75\\
Viola & \textbf{vla} & 0& 0 & 0 & 0\\
\cline{3-6}
\end{tabular}

\end{document}

1 Answer 1

12

I've been referring to the easybmat package lately, and since no other answers have been given, I'll do it again. The problem with the easybmat is that it has to be inside mathmode...so you'd have to wrap your text with \text{} at every cell, or in the column definition. However, with BMAT you can put any lines you like:

$\begin{BMAT}[5pt]{|ccccc|}{|cccc|}
* & * & * & * & * \\
* & * & * & * & * \\
* & * & * & * & * \\
* & * & * & * & *
\addpath{(1,1,0)ruld}
\addpath{(4,3,;)lldrrdll}
\end{BMAT} $

produces:

alt text

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .