Graphics, Figures & Tablesdrawing boxes around sub-rectangles of a table

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
lloyd22
Posts: 8
Joined: Mon Jul 05, 2010 2:39 am

drawing boxes around sub-rectangles of a table

Post by lloyd22 »

Hi,

Any hints on how I might accomplish this? I would like to draw boxes around subsquares of a table. For instance, in a 10 by 10 table, whose cells I identify here by column/row pairs, I want to box the rectangle whose corners encompass cells (2,3) and (7,6), then add another smaller box around (7,5) to (8,6). (The small box sits at the right of the big box, sharing one side wall, and the baselines for each are coterminal.)

Thanks!

Recommended reading 2024:

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

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

Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

drawing boxes around sub-rectangles of a table

Post by Juanjo »

The following code may give you some hints:

Code: Select all

\documentclass[a4paper]{article}

\newcommand\LL[1]{\multicolumn{1}{|c}{#1}}
\newcommand\RR[1]{\multicolumn{1}{c|}{#1}}
\newcommand\LR[1]{\multicolumn{1}{|c|}{#1}}

\begin{document}

\begin{tabular}{*{10}{c}}
 X & X & X & X & X & X & X & X & X & X \\
 X & X & X & X & X & X & X & X & X & X \\
 \cline{2-7}
 X & \LL{X} & X & X & X & X & \RR{X} & X & X & X \\
 X & \LL{X} & X & X & X & X & \RR{X} & X & X & X \\
 \cline{7-8}
 X & \LL{X} & X & X & X & X & \LR{X} & \RR{X} & X & X \\
 X & \LL{X} & X & X & X & X & \LR{X} & \RR{X} & X & X \\
 \cline{2-8}
 X & X & X & X & X & X & X & X & X & X \\
 X & X & X & X & X & X & X & X & X & X \\
 X & X & X & X & X & X & X & X & X & X \\
 X & X & X & X & X & X & X & X & X & X 
\end{tabular}

\end{document}
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
lloyd22
Posts: 8
Joined: Mon Jul 05, 2010 2:39 am

Re: drawing boxes around sub-rectangles of a table

Post by lloyd22 »

That works great Juanjo, thanks very much!
Last edited by lloyd22 on Mon Aug 09, 2010 11:56 pm, edited 1 time in total.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

drawing boxes around sub-rectangles of a table

Post by localghost »

Now that the problem is solved, please mark the topic accordingly as described in Section 3 of the Board Rules.


Best regards
Thorsten
Post Reply