Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
add comment

1 Answer

up vote 11 down vote accepted

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.