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
Graphics, Figures & Tables ⇒ Rectangles around Table Cells
Rectangles around Table Cells
- Attachments
-
- Screen shot 2011-05-25 at 5.17.47 PM.png (21.02 KiB) Viewed 14866 times
Rectangles around Table Cells
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
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
Re: Rectangles around Table Cells
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..
Therefore I would like to do it myself..
Rectangles around Table Cells
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
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}%
Re: Rectangles around Table Cells
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
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
Re: Rectangles around Table Cells
Have you tested the code I posted in my previous answer?
Ignasi
Ignasi
Rectangles around Table Cells
Hello,
Yes, I did but it does not produce the image shown above with:
I hope you get it.
Thank you
Yes, I did but it does not produce the image shown above with:
Code: Select all
A________| |
Thank you
Rectangles around Table Cells
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.
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}%
Re: Rectangles around Table Cells
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