Graphics, Figures & TablesRectangles around Table Cells

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Mini
Posts: 73
Joined: Thu Aug 06, 2009 12:46 pm

Rectangles around Table Cells

Post by Mini »

Hello,

I'd like to achieve the attached image in LaTeX.

How could I make a rectangle around a bunch of cells in LaTeX?

Thanks
Attachments
Screen shot 2011-05-25 at 5.17.47 PM.png
Screen shot 2011-05-25 at 5.17.47 PM.png (21.02 KiB) Viewed 14866 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX books
ignasi
Posts: 20
Joined: Tue Jul 28, 2009 5:10 pm

Rectangles around Table Cells

Post by ignasi »

Do you know the karnaugh package on CTAN?

I used it long time ago. More recently, but still some years ago I made some Karnaugh maps with TikZ. If you are interested I can send you some example.

Ignasi
Mini
Posts: 73
Joined: Thu Aug 06, 2009 12:46 pm

Re: Rectangles around Table Cells

Post by Mini »

Yes but it doesnt arrange the K maps as I want them to do (ie. not in the correct standard cell order).

Therefore I would like to do it myself..
ignasi
Posts: 20
Joined: Tue Jul 28, 2009 5:10 pm

Rectangles around Table Cells

Post by ignasi »

I've found my tikz code for Karnaugh maps. Command names are in catalan, but I've added some comments in English. I hope you could understand them. You only need tikz. Next you'll find the code with two examples using it.

Best regards,

Ignasi

Code: Select all

Code, edit and compile here:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix,calc}
%internal group
%#1-space between node and grouping line. Default=0
%#2-top left node
%#3-bottom right node
\newcommand{\implicant}[3][0]{
\draw[rounded corners=3pt] ($(#2.north west)+(135:#1)$) rectangle ($(#3.south east)+(-45:#1)$);
}
%group lateral borders
%#1-space between node and grouping line. Default=0
%#2-top left node
%#3-bottom right node
\newcommand{\implicantcostats}[3][0]{
\draw[rounded corners=3pt] ($(rf.east |- #2.north)+(90:#1)$)-| ($(#2.east)+(0:#1)$) |- ($(rf.east |- #3.south)+(-90:#1)$);
\draw[rounded corners=3pt] ($(cf.west |- #2.north)+(90:#1)$) -| ($(#3.west)+(180:#1)$) |- ($(cf.west |- #3.south)+(-90:#1)$);
}
%group top-bottom borders
%#1-space between node and grouping line. Default=0
%#2-top left node
%#3-bottom right node
\newcommand{\implicantdaltbaix}[3][0]{
\draw[rounded corners=3pt] ($(cf.south -| #2.west)+(180:#1)$) |- ($(#2.south)+(-90:#1)$) -| ($(cf.south -| #3.east)+(0:#1)$);
\draw[rounded corners=3pt] ($(rf.north -| #2.west)+(180:#1)$) |- ($(#3.north)+(90:#1)$) -| ($(rf.north -| #3.east)+(0:#1)$);
}
%group corners
%#1-space between node and grouping line. Default=0
\newcommand{\implicantcantons}[1][0]{
\draw[rounded corners=3pt] ($(rf.east |- 0.south)+(-90:#1)$) -| ($(0.east |- cf.south)+(0:#1)$);
\draw[rounded corners=3pt] ($(rf.east |- 8.north)+(90:#1)$) -| ($(8.east |- rf.north)+(0:#1)$);
\draw[rounded corners=3pt] ($(cf.west |- 2.south)+(-90:#1)$) -| ($(2.west |- cf.south)+(180:#1)$);
\draw[rounded corners=3pt] ($(cf.west |- 10.north)+(90:#1)$) -| ($(10.west |- rf.north)+(180:#1)$);
}
%Empty Karnaugh map 4x4
\newenvironment{Karnaugh}%
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
oozypal
Posts: 12
Joined: Fri Dec 21, 2012 8:46 am

Re: Rectangles around Table Cells

Post by oozypal »

Hello,

I am having the same issue. Did you find the right code?

Were you able to draw the kmap in your picture?

Thank you
OOzy
ignasi
Posts: 20
Joined: Tue Jul 28, 2009 5:10 pm

Re: Rectangles around Table Cells

Post by ignasi »

Have you tested the code I posted in my previous answer?

Ignasi
oozypal
Posts: 12
Joined: Fri Dec 21, 2012 8:46 am

Rectangles around Table Cells

Post by oozypal »

Hello,

Yes, I did but it does not produce the image shown above with:

Code: Select all

A
________
| |
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
I hope you get it.

Thank you
ignasi
Posts: 20
Joined: Tue Jul 28, 2009 5:10 pm

Rectangles around Table Cells

Post by ignasi »

I think that the line which marks negate or not negate variables is not necessary if you uses 0 and 1 to label rows and columns, but, in any case, I've made some changes to the code and something similar to wanted lines and labels are shown now.

I hope you could adapt the code to your needs.

Code: Select all

Code, edit and compile here:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix,calc}
%internal group
%#1-space between node and grouping line. Default=0
%#2-top left node
%#3-bottom right node
\newcommand{\implicant}[3][0]{
\draw[rounded corners=3pt] ($(#2.north west)+(135:#1)$) rectangle ($(#3.south east)+(-45:#1)$);
}
%group lateral borders
%#1-space between node and grouping line. Default=0
%#2-top left node
%#3-bottom right node
\newcommand{\implicantcostats}[3][0]{
\draw[rounded corners=3pt] ($(rf.east |- #2.north)+(90:#1)$)-| ($(#2.east)+(0:#1)$) |- ($(rf.east |- #3.south)+(-90:#1)$);
\draw[rounded corners=3pt] ($(cf.west |- #2.north)+(90:#1)$) -| ($(#3.west)+(180:#1)$) |- ($(cf.west |- #3.south)+(-90:#1)$);
}
%group top-bottom borders
%#1-space between node and grouping line. Default=0
%#2-top left node
%#3-bottom right node
\newcommand{\implicantdaltbaix}[3][0]{
\draw[rounded corners=3pt] ($(cf.south -| #2.west)+(180:#1)$) |- ($(#2.south)+(-90:#1)$) -| ($(cf.south -| #3.east)+(0:#1)$);
\draw[rounded corners=3pt] ($(rf.north -| #2.west)+(180:#1)$) |- ($(#3.north)+(90:#1)$) -| ($(rf.north -| #3.east)+(0:#1)$);
}
%group corners
%#1-space between node and grouping line. Default=0
\newcommand{\implicantcantons}[1][0]{
\draw[rounded corners=3pt] ($(rf.east |- 0.south)+(-90:#1)$) -| ($(0.east |- cf.south)+(0:#1)$);
\draw[rounded corners=3pt] ($(rf.east |- 8.north)+(90:#1)$) -| ($(8.east |- rf.north)+(0:#1)$);
\draw[rounded corners=3pt] ($(cf.west |- 2.south)+(-90:#1)$) -| ($(2.west |- cf.south)+(180:#1)$);
\draw[rounded corners=3pt] ($(cf.west |- 10.north)+(90:#1)$) -| ($(10.west |- rf.north)+(180:#1)$);
}
%Empty Karnaugh map 4x4
\newenvironment{Karnaugh}%
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
barrera
Posts: 1
Joined: Sat Mar 16, 2013 3:09 am

Re: Rectangles around Table Cells

Post by barrera »

I improved a little the code that I copied here (now you can draw maps up to 3x3 variables) and put it inside this .sty file, to use like a package. Feel free to use it.
Attachments
karnaughmapalternative.sty
For free use.
(11.78 KiB) Downloaded 517 times
Post Reply