summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/tikz-karnaugh/tikz-karnaugh-doc.tex
blob: 4cadf7c952333bd7e0831476b76113f5fb7784de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{lmodern}
\usepackage{tikz}
\usepackage{url}
\def\tikzname{Ti\emph{k}Z}%
\input ../tex/tikz-karnaugh
\sloppy
\begin{document}
\title{Typesetting Karnaugh Maps with \LaTeX{} and \tikzname{}}
\author{Luis Paulo Laus\\e-mail: \texttt{laus@utfpr.edu.br}}
\date{Version 1.0 of 22 December 2017}

\maketitle


\section{Abstract}

Karnaugh maps are used to simplify logic equations leading to the most compact expression of two level for a given truth table. The drawing of them used to be a boring, annoying and error-prone task. This set of macros intend to simplify the task. They can typeset Karnaugh maps with up to twelve variables, which is more than you might likely need. You only have to provide a list of variable identifiers plus the truth table of your logic function(s). The macros also allow to mark the simplifications of your logic function directly within a Karnaugh map. These package is based on \verb|kvmacros.tex| from \verb|karnaugh| package referred herein as ``the original one''. The modifications carried out intended to use \tikzname{} instead of native \LaTeX{} commands allowing easier customisation, easier extension when you need to draw other elements along with the map and leading to high graph quality.

\section{Introduction}

Karnaugh maps and Veitch charts are used to simplify logic equations. They are map representations of logic functions, and in that they are equivalent. Veitch charts are not supported by this package, but it should not be a big problem to port Andreas W. Wieland's veitch macro, available in \verb|karnaugh| package, if you need it.
Please note that this software, including its documentation, is based on Andreas W. Wieland's previous work and the author wished to register his acknowledgment.

\subsection{Comparison with Other Packages}

If you ask yourself ``why another Karnaugh map typesetting package?'' the answer is easy: because I was not completely happy with the packages available I know and those are:
\begin{enumerate}
\item \verb|karnaugh|: it is great package that uses native \LaTeX{} commands to draw the map. It supports Karnaugh maps and Veitch charts. It employs a recursive algorithm with no size limit (well, it works until you blow the memory out which will happen about ten to twelve variables) which leads to an interesting kind of symmetry. Remember, Karnaugh maps are all about symmetry. It is not customisable, for instance, one cannot change the distance between bars (the marks showing around the map with variable identifiers on them) and if the variable identifier is long it will overlap another bar. Also, I want to use \tikzname{} to draw colourful semi-transparent figures on to top of the map to point out groups (prime implicants) and, although it is possible, it is rather difficult and the results is not very good because they always look a bit of. I have a long-time experience with this package and I have also written a java program to draw the maps because, though typesetting simple maps is easy, to point out the prime implicants is not.
\item \verb|karnaughmap|: it uses \tikzname{} so you got a lot of options for customisation. It is limited to eight variable which, to be honest, should be enough for anyone. The problem is that it only draws bars (those marking mentioned above) up to for four variables. Also, the order in with the variable list is inputted is different from the order employed by \verb|karnaugh|.
\item \verb|askmaps|: this package generates configurable American style Karnaugh maps for 2, 3, 4 and 5 variables. In America, instead of bars denoting the one value of variables, they use Gray code on the top and left side of the map. This behaviour can be mimic with \verb|tikz-karnaugh|, though, in my twenty years of experience teaching the subject, I have found out that bars are much more intuitive. The \verb|askmaps| contains four macros, one for each number of variables, and it can be used to point out prime implicants in the very same way that \verb|karnaugh| does.
\item \verb|karnaugh-map|: uses \tikzname{} to draw up to four maps of four variables leading to a 3D six variables map. It contains commands for drawing implicants on top of the map. Like \verb|askmaps|, this package uses Gray code instead of bars.
\end{enumerate}


\subsection{Introductory example}


Let us start first with an introduction on how to use these macros:
The first thing you have to do is to put the macro file \verb|tikz-karnaugh.tex| into a directory where \TeX{} will find it, i.e., you have to put it into a directory where your \texttt{TEXINPUTS} environment variable points to. You can then load them by typing \verb|\input tikz-karnaugh| somewhere in the preamble of your document. Also, you are going to need \tikzname{}. For this type \verb|\usepackage{tikz}|.

Suppose now you have a logic function~$f$ with the following truth table: 

\begin{center}

\begin{tabular}{lr}
  \begin{tabular}[t]{r|cccc|c}
Index&$a$&$b$&$c$&$d$&$f$\\
\hline
0&0&0&0&0&1\\
1&0&0&0&1&1\\
2&0&0&1&0&1\\
3&0&0&1&1&0\\
4&0&1&0&0&0\\
5&0&1&0&1&1\\
6&0&1&1&0&1\\
7&0&1&1&1&0\\
  \end{tabular}
&
  \begin{tabular}[t]{r|cccc|c}
Index&$a$&$b$&$c$&$d$&$f$\\
\hline
8&1&0&0&0&0\\
9&1&0&0&1&1\\
10&1&0&1&0&1\\
11&1&0&1&1&0\\
12&1&1&0&0&0\\
13&1&1&0&1&1\\
14&1&1&1&0&1\\
15&1&1&1&1&0\\
  \end{tabular}
\end{tabular}
\end{center}

This logic function can easily be put into a Karnaugh map by using the
\verb|\karnaughmap| macro in a \tikzname{} environment (\verb|\begin{tikzpicture}|) or inline command (\verb|\tikz|). It has five parameters:
\begin{enumerate}
\item the number of variables in the  map;
\item an identifier for the function;
\item a list of variable identifiers for the variables; and
\item the list of values of $f$ for each line in the truth table; and
\item a set of \tikzname{} commands that will be drown before the function values so the values will appear on top of them.
\end{enumerate}

The variable identifiers in the third parameter are ordered from highest to lowest significance (the same way as in the truth table, with $a$ having a significance of $2^3=8$ and $d$ having a significance of $2^0=1$). The list of values of $f$ was read from lowest to highest index. The fifth parameter remains empty in this example, it will be discussed further on:

\begin{verbatim}
\tikz[karnaugh,kmindex/.style={red,font=\tiny}]%
  \karnaughmap{4}{f(a,b,c,d):}{abcd}{1110011001100110}{};
\end{verbatim}

This produces the following Karnaugh map, where the indices in the upper left
corner of each box correspond to the indices in the truth
table:\footnote{The indices can easily be calculated from the variable values
  in the truth table, i.e. line 11: the index equals $2^{3}\,a+2^{2}\,b+2^{1}\,c+2^{0}\,d=8\,a+4\,b+2\,d+1\,d=8+2+1=11$.} 

\begin{center}
\tikz[karnaugh,kmindex/.style={red,font=\tiny}]%
  \karnaughmap{4}{f(a,b,c,d):}{abcd}{1110011001100110}{};
\end{center}

The macros that read the variable list and the list of logic values (i.e., parameters \#3 and \#4) work recursively. 

Each entry has to be one character long, otherwise -- like a variable identifier enclosed in \$s -- you have to put it into braces:

\begin{verbatim}
\begin{tikzpicture}[karnaugh]
   \karnaughmap{4}{$f(a,b,c,d):$}{{$a$}{$b$}{$c$}{$d$}}%
     {0110011001100110}{}
\end{tikzpicture}
\end{verbatim}

Here, a \tikzname{} environment was used so there is no semicolon (;) in the end of \verb|\karnaughmap| macro. Also, the indices were omitted by removing \verb|,kmindex/.style={red,font=\tiny}| from the options list. This produces the following Karnaugh map:

\begin{center}
\begin{tikzpicture}[karnaugh]
   \karnaughmap{4}{$f(a,b,c,d):$}{{$a$}{$b$}{$c$}{$d$}}%
     {0110011001100110}{}
\end{tikzpicture}
\end{center}

\section{Marking simplifications}

The already mentioned fifth parameter can be used if you want to draw something inside the Karnaugh map. For example, this is useful if you want to show how you simplified a logic function pointing out the prime implicants:

\begin{verbatim}
\kmunitlength=2em
\begin{tikzpicture}[karnaugh,x=1\kmunitlength,y=1\kmunitlength,
  thick,grp/.style={rounded corners=0.2\kmunitlength,
  fill opacity=0.6,rectangle,draw}]
  \karnaughmap{4}{$f(a,b,c,d)$}{{$a$}{$b$}{$c$}{$d$}}%
    {0110011001100110}%
    {
      \node[grp,color=blue,fill=blue!30,
          minimum width=0.9\kmunitlength,
          minimum height=1.9\kmunitlength] (n000) at (0.5,2.0) {};
      \node[grp,color=blue,fill=blue!30,
          minimum width=0.9\kmunitlength,
          minimum height=1.9\kmunitlength] (n001) at (3.5,2.0) {};
      \node[grp,color=red,fill=red!30,
          minimum width=1.9\kmunitlength,
          minimum height=0.9\kmunitlength] (n100) at (2.0,3.5) {};
      \node[grp,color=red,fill=red!30,
          minimum width=1.9\kmunitlength,
          minimum height=0.9\kmunitlength] (n110) at (2.0,0.5) {};
      \draw[color=blue] (n000.north) to [bend left=25] (n001.north)
                        (n000.south) to [bend right=25] (n001.south);
      \draw[color=red]  (n100.west) to [bend right=25] (n110.west)
                        (n100.east) to [bend left=25] (n110.east);
  }
\end{tikzpicture}
\end{verbatim}

The corresponding Karnaugh map looks like this:

\begin{center}
\kmunitlength=2em
\begin{tikzpicture}[karnaugh,x=1\kmunitlength,y=1\kmunitlength,
  thick,grp/.style={rounded corners=0.2\kmunitlength,fill opacity=0.6,
  rectangle,draw}]
  \karnaughmap{4}{$f(a,b,c,d)$}{{$a$}{$b$}{$c$}{$d$}}%
    {0110011001100110}%
    {
      \node[grp,color=blue,fill=blue!30,minimum width=0.9\kmunitlength,
          minimum height=1.9\kmunitlength](n000) at (0.5,2.0) {};
      \node[grp,color=blue,fill=blue!30,minimum width=0.9\kmunitlength,
          minimum height=1.9\kmunitlength](n001) at (3.5,2.0) {};
      \node[grp,color=red,fill=red!30,minimum width=1.9\kmunitlength,
          minimum height=0.9\kmunitlength](n100) at (2.0,3.5) {};
      \node[grp,color=red,fill=red!30,minimum width=1.9\kmunitlength,
          minimum height=0.9\kmunitlength](n110) at (2.0,0.5) {};
      \draw[color=blue] (n000.north) to [bend left=25] (n001.north)
                                 (n000.south) to [bend right=25] (n001.south);
      \draw[color=red]  (n100.west) to [bend right=25] (n110.west)
                                 (n100.east) to [bend left=25] (n110.east);
  }
\end{tikzpicture}
\end{center}
and the corresponding expression is:\[f(a,b,c,d) = {\color{blue}c\,\bar{d}} + {\color{red}\bar{c}\,d}.\]
 
Instead of \LaTeX's graphics macros\footnote{As in the original software.} you can use \tikzname{} for this purpose. The Karnaugh map has its datum at the lower left point exactly. The length of a single cell within the Karnaugh map is equal to \verb|\kmunitlength|.

\section{Other features}

There are some more features that you can use. Possibly the most important is
that  you can change the size of the diagrams by changing the size of the
boxes within the map, simply by typing:

\begin{verbatim}
\kmunitlength=15mm
\begin{tikzpicture}[karnaugh]
   \karnaughmap{4}{$f:$}{abcd}{0110011001100110}{}
\end{tikzpicture}
\end{verbatim}

This results in the following Karnaugh map. The setting of the
\verb|\kmunitlength| remains active until you change it again;\footnote{Or, of
  course, until you leave the group in which you redefined the value.}
the default \verb|\kmunitlength| is 8\,mm:

\begin{center}
\kmunitlength=15mm
\begin{tikzpicture}[karnaugh]
   \karnaughmap{4}{$f:$}{abcd}{0110011001100110}{}
\end{tikzpicture}
\end{center}

Another feature is that you can switch on the indices inside the map like in the fisrt example by typing: 

\begin{verbatim}
\begin{tikzpicture}[karnaugh,kmindex/.style={red,font=\tiny}]
  \karnaughmap{4}{$f:$}{abcd}{0110011001100110}{}
\end{tikzpicture}
\end{verbatim}

\begin{center}
\kmunitlength=8mm
\begin{tikzpicture}[karnaugh,kmindex/.style={red,font=\tiny}]
  \karnaughmap{4}{$f:$}{abcd}{0110011001100110}{}
\end{tikzpicture}
\end{center}

Usually, the font size of the map's contents and indices should be suitable (\verb|\tiny| for \verb|kmindex/.style| and \verb|\normalsize| for \verb|kmcell/.style|). Those sizes, of course, can be adjusted.

\section{If you use the original version of the macros\ldots}

\ldots{} you will certainly have noticed a number of changes. The most important one is that now you control the appearance of cell, index, etc. by changing the style and not through macros. Also, you need a \tikzname{} picture environment.


\section{Dimensions and styles}

The appearance of the Karnaugh map is controlled by some styles and dimensions as follows:
\begin{description}
\item [{kmbar/.style }] top and side bars related to the variables and denoting the rows and columns for which the respective variable is 1. The default value is \verb!black,|-|,thin! meaning they all will be represented as a black think line with T chapped tips.
\item [{kmbar label/.style }] style used for the variable name on the bars. The default value is \verb|black|.
\item [{kmvar/.style }] style used for the variable name (function) of the map. The default value is \verb|black|.
\item [{kmindex/.style}] style used for cell index. The default value is \verb|transparent| meaning they all will be omitted (invisible to be precise).
\item [{kmcell/.style}] style used for cell contents. The default value is \verb|black|.
\item [{kmlines/.style}] style used for the lines separating adjacent rows and columns. The default value is \verb|black|.
\item [{bar sep}] distance between the bar closer to the map and map itself. It depends mainly on the line tip used in \verb|kmlines/.style|. The default value is \verb|0.2\kmunitlength|.
\item [{kmbar top sep}] distance between two bars on the top of map. It depends mainly on the font height used in \verb|kmbar label/.style|. The default value is \verb|1\kmunitlength|.
\item [{kmbar left sep}] distance between two bars on the left of map. It depends mainly on the variable name which and the font size used in \verb|kmbar label/.style|. The default value is \verb|1\kmunitlength|.
\end{description}
For more on styles have a look in the \tikzname{} documentation.

Let us see a more interesting and colourful example.
\begin{verbatim}
\kmunitlength=2.5em
\begin{tikzpicture}[karnaugh,x=1\kmunitlength,y=1\kmunitlength,
    thick,grp/.style={rounded corners=0.2\kmunitlength,
    fill opacity=0.6,rectangle,draw},
    kmbar/.style={blue,<->,double=white,semithick},
    bar left sep=1.2\kmunitlength,
    bar sep=0.4\kmunitlength,
    kmbar label/.style={red!70!black},
    kmindex/.style={orange,font=\tiny},
    kmcell/.style={cyan!80!black},
    kmlines/.style={brown,thin},
    kmvar/.style={green!70!black}]
  \karnaughmap{6}{$z_{0}$}{%
    {$x_{5}$}{$x_{2}$}{$x_{4}$}{$x_{1}$}{$x_{3}$}{$x_{0}$}}%
    {--1{}1{}1{}-11-1{}1{}1-{}1{}{}1-1-{}1-{}-1-1{\color{red}1}%
     --{}1{}-11{}-{}1--1{}1{}{}111-{}1{}--1}%
    {
      \node[grp,color=blue,fill=blue!30,
        minimum width=1.9\kmunitlength,
        minimum height=0.9\kmunitlength](n000) at (1.0,7.5) {};
      \node[grp,color=blue,fill=blue!30,
        minimum width=1.9\kmunitlength,
        minimum height=0.9\kmunitlength](n002) at (7.0,7.5) {};
      \node[grp,color=blue,fill=blue!30,
        minimum width=1.9\kmunitlength,
        minimum height=1.9\kmunitlength](n010) at (1.0,4.0) {};
      \node[grp,color=blue,fill=blue!30,
        minimum width=1.9\kmunitlength,
        minimum height=1.9\kmunitlength](n012) at (7.0,4.0) {};
      \node[grp,color=blue,fill=blue!30,
        minimum width=1.9\kmunitlength,
        minimum height=0.9\kmunitlength](n030) at (1.0,0.5) {};
      \node[grp,color=blue,fill=blue!30,
        minimum width=1.9\kmunitlength,
        minimum height=0.9\kmunitlength](n032) at (7.0,0.5) {};
      \draw[color=blue] (n000.east) to [bend left=25] (n002.west)
         (n010.east) to [bend left=25] (n012.west)
         (n030.east) to [bend right=25] (n032.west)
         (n000.south) to [bend right=25] (n010.north)
         (n002.south) to [bend left=25] (n012.north)
         (n010.south) to [bend right=25] (n030.north)
         (n012.south) to [bend left=25] (n032.north);
      \node[grp,color=red,fill=red!30,
        minimum width=0.8\kmunitlength,
        minimum height=7.8\kmunitlength](n100) at (0.5,4.0) {};
      \node[grp,color=red,fill=red!30,
        minimum width=0.8\kmunitlength,
        minimum height=7.8\kmunitlength](n101) at (3.5,4.0) {};
      \draw[color=red] (n100.north) to [bend left=25] (n101.north)
         (n100.south) to [bend right=25] (n101.south);
      \node[grp,color=orange,fill=orange!30,
        minimum width=1.9\kmunitlength,
        minimum height=1.9\kmunitlength](n200) at (5.0,6.0) {};
      \node[grp,color=orange,fill=orange!30,
        minimum width=1.9\kmunitlength,
        minimum height=1.9\kmunitlength](n220) at (5.0,2.0) {};
      \draw[color=orange] (n200.west) to [bend right=25] (n220.west)
         (n200.east) to [bend left=25] (n220.east);
      \node[grp,color=teal,fill=teal!30,
        minimum width=1.8\kmunitlength,
        minimum height=1.8\kmunitlength](n300) at (6.0,6.0) {};
      \node[grp,color=teal,fill=teal!30,
        minimum width=1.8\kmunitlength,
        minimum height=1.8\kmunitlength](n320) at (6.0,2.0) {};
      \draw[color=teal] (n300.west) to [bend right=25] (n320.west)
         (n300.east) to [bend left=25] (n320.east);
  }
\end{tikzpicture}
\end{verbatim}

The corresponding Karnaugh map looks like this:

\begin{center}
\kmunitlength=2.5em
\begin{tikzpicture}[karnaugh,x=1\kmunitlength,y=1\kmunitlength,
    thick,grp/.style={rounded corners=0.2\kmunitlength,
    fill opacity=0.6,rectangle,draw},
    kmbar/.style={blue,<->,double=white,semithick},
    bar left sep=1.2\kmunitlength,
    bar sep=0.4\kmunitlength,
    kmbar label/.style={red!70!black},
    kmindex/.style={orange,font=\tiny},
    kmcell/.style={cyan!80!black},
    kmlines/.style={brown,thin},
    kmvar/.style={green!70!black}]
  \karnaughmap{6}{$z_{0}$}{%
    {$x_{5}$}{$x_{2}$}{$x_{4}$}{$x_{1}$}{$x_{3}$}{$x_{0}$}}%
    {--1{}1{}1{}-11-1{}1{}1-{}1{}{}1-1-{}1-{}-1-1{\color{red}1}%
     --{}1{}-11{}-{}1--1{}1{}{}111-{}1{}--1}%
    {
      \node[grp,color=blue,fill=blue!30,
        minimum width=1.9\kmunitlength,
        minimum height=0.9\kmunitlength](n000) at (1.0,7.5) {};
      \node[grp,color=blue,fill=blue!30,
        minimum width=1.9\kmunitlength,
        minimum height=0.9\kmunitlength](n002) at (7.0,7.5) {};
      \node[grp,color=blue,fill=blue!30,
        minimum width=1.9\kmunitlength,
        minimum height=1.9\kmunitlength](n010) at (1.0,4.0) {};
      \node[grp,color=blue,fill=blue!30,
        minimum width=1.9\kmunitlength,
        minimum height=1.9\kmunitlength](n012) at (7.0,4.0) {};
      \node[grp,color=blue,fill=blue!30,
        minimum width=1.9\kmunitlength,
        minimum height=0.9\kmunitlength](n030) at (1.0,0.5) {};
      \node[grp,color=blue,fill=blue!30,
        minimum width=1.9\kmunitlength,
        minimum height=0.9\kmunitlength](n032) at (7.0,0.5) {};
      \draw[color=blue] (n000.east) to [bend left=25] (n002.west)
         (n010.east) to [bend left=25] (n012.west)
         (n030.east) to [bend right=25] (n032.west)
         (n000.south) to [bend right=25] (n010.north)
         (n002.south) to [bend left=25] (n012.north)
         (n010.south) to [bend right=25] (n030.north)
         (n012.south) to [bend left=25] (n032.north);
      \node[grp,color=red,fill=red!30,
        minimum width=0.8\kmunitlength,
        minimum height=7.8\kmunitlength](n100) at (0.5,4.0) {};
      \node[grp,color=red,fill=red!30,
        minimum width=0.8\kmunitlength,
        minimum height=7.8\kmunitlength](n101) at (3.5,4.0) {};
      \draw[color=red] (n100.north) to [bend left=25] (n101.north)
         (n100.south) to [bend right=25] (n101.south);
      \node[grp,color=orange,fill=orange!30,
        minimum width=1.9\kmunitlength,
        minimum height=1.9\kmunitlength](n200) at (5.0,6.0) {};
      \node[grp,color=orange,fill=orange!30,
        minimum width=1.9\kmunitlength,
        minimum height=1.9\kmunitlength](n220) at (5.0,2.0) {};
      \draw[color=orange] (n200.west) to [bend right=25] (n220.west)
         (n200.east) to [bend left=25] (n220.east);
      \node[grp,color=teal,fill=teal!30,
        minimum width=1.8\kmunitlength,
        minimum height=1.8\kmunitlength](n300) at (6.0,6.0) {};
      \node[grp,color=teal,fill=teal!30,
        minimum width=1.8\kmunitlength,
        minimum height=1.8\kmunitlength](n320) at (6.0,2.0) {};
      \draw[color=teal] (n300.west) to [bend right=25] (n320.west)
         (n300.east) to [bend left=25] (n320.east);
  }
\end{tikzpicture}
\end{center}

You may notice that the zeros were omitted (replaced by \verb|{}| in the list). Also, in the cell~34 the one is red beause \verb|{\color{red}1}|. You can put almost anything inside a cell using curly brackets. The distance between bars on the left side was set to \verb|1.2\kmunitlength| to prevent overlapping between $x_3$ (the label) and $x_4$ bar and $x_4$ and $x_5$ bar, but the distance between the bars on top was left unchanged. The distance between the map and the bars closest to it was set to \verb|0.4\kmunitlength| to prevent overlapping between the bar tip (\tikz[baseline] \draw[blue,->,double=white,semithick] (0,0.6ex) -- (0.5cm,0.6ex);) and the map itself. If you want an American style map you can use \verb|bar sep| to leave space for the Gray coded numbers.

The indices can be computed by \[32\,x_{5}+8\,x_{4}+2\,x_{3}+16\,x_{2}+4\,x_{1}+1\,x_{0}\] which is a bit bizarre. The truth table values ought to be arranged according to this index order. This bizarreness is the price we pay to have the variables placed in positions which are more intuitive. See Section~ \ref{sec:remarks} for a software that can help on this matter.

\section{American style}

If you really want an American style map and you are not afraid of admitting it publicly, you can still use this package to typeset it. The first thing to do is to disable the bars and the function identifiers by making them transparent. Therefore, these options have to be included in the \tikzname{} command:
\begin{verbatim}
   kmbar/.style={transparent},
   kmvar/.style={transparent}
\end{verbatim}

Then you will need rows and columns labels in Gray code and a caption for the map. In the last example, these can be achieved by appending the following code in the fifth argument of the \verb|karnaughmap| macro:
\begin{verbatim}
      \draw[brown,thin] (0,8) --
          node[below left,magenta]{$x_5,x_4,x_3$} 
          node[above right,violet]{$x_2,x_1,x_0$} +(-1,1) 
          node[above left,green!70!black] {$z_0$};
      \foreach \x/\l in %
       {0/000,1/001,2/011,3/010,4/110,5/111,6/101,7/100} {
        \node[violet] at (\x+0.5,8.2) {\l};
        \node[magenta] at (-0.4,7.5-\x) {\l};
      }
\end{verbatim}

The result should be:

\begin{center}
\kmunitlength=2.5em
\begin{tikzpicture}[karnaugh,x=1\kmunitlength,y=1\kmunitlength,
    thick,grp/.style={rounded corners=0.2\kmunitlength,
    fill opacity=0.6,rectangle,draw},
    kmbar/.style={transparent},
    bar left sep=0pt,
    bar top sep=0pt,
    bar sep=0pt,
    kmindex/.style={orange,font=\tiny},
    kmcell/.style={cyan!80!black},
    kmlines/.style={brown,thin},
    kmvar/.style={transparent}]
  \karnaughmap{6}{$z_{0}$}{%
    {$x_{5}$}{$x_{2}$}{$x_{4}$}{$x_{1}$}{$x_{3}$}{$x_{0}$}}%
    {--1{}1{}1{}-11-1{}1{}1-{}1{}{}1-1-{}1-{}-1-1{\color{red}1}%
     --{}1{}-11{}-{}1--1{}1{}{}111-{}1{}--1}%
    {
      \node[grp,color=blue,fill=blue!30,
        minimum width=1.9\kmunitlength,
        minimum height=0.9\kmunitlength](n000) at (1.0,7.5) {};
      \node[grp,color=blue,fill=blue!30,
        minimum width=1.9\kmunitlength,
        minimum height=0.9\kmunitlength](n002) at (7.0,7.5) {};
      \node[grp,color=blue,fill=blue!30,
        minimum width=1.9\kmunitlength,
        minimum height=1.9\kmunitlength](n010) at (1.0,4.0) {};
      \node[grp,color=blue,fill=blue!30,
        minimum width=1.9\kmunitlength,
        minimum height=1.9\kmunitlength](n012) at (7.0,4.0) {};
      \node[grp,color=blue,fill=blue!30,
        minimum width=1.9\kmunitlength,
        minimum height=0.9\kmunitlength](n030) at (1.0,0.5) {};
      \node[grp,color=blue,fill=blue!30,
        minimum width=1.9\kmunitlength,
        minimum height=0.9\kmunitlength](n032) at (7.0,0.5) {};
      \draw[color=blue] (n000.east) to [bend left=25] (n002.west)
         (n010.east) to [bend left=25] (n012.west)
         (n030.east) to [bend right=25] (n032.west)
         (n000.south) to [bend right=25] (n010.north)
         (n002.south) to [bend left=25] (n012.north)
         (n010.south) to [bend right=25] (n030.north)
         (n012.south) to [bend left=25] (n032.north);
      \node[grp,color=red,fill=red!30,
        minimum width=0.8\kmunitlength,
        minimum height=7.8\kmunitlength](n100) at (0.5,4.0) {};
      \node[grp,color=red,fill=red!30,
        minimum width=0.8\kmunitlength,
        minimum height=7.8\kmunitlength](n101) at (3.5,4.0) {};
      \draw[color=red] (n100.north) to [bend left=25] (n101.north)
         (n100.south) to [bend right=25] (n101.south);
      \node[grp,color=orange,fill=orange!30,
        minimum width=1.9\kmunitlength,
        minimum height=1.9\kmunitlength](n200) at (5.0,6.0) {};
      \node[grp,color=orange,fill=orange!30,
        minimum width=1.9\kmunitlength,
        minimum height=1.9\kmunitlength](n220) at (5.0,2.0) {};
      \draw[color=orange] (n200.west) to [bend right=25] (n220.west)
         (n200.east) to [bend left=25] (n220.east);
      \node[grp,color=teal,fill=teal!30,
        minimum width=1.8\kmunitlength,
        minimum height=1.8\kmunitlength](n300) at (6.0,6.0) {};
      \node[grp,color=teal,fill=teal!30,
        minimum width=1.8\kmunitlength,
        minimum height=1.8\kmunitlength](n320) at (6.0,2.0) {};
      \draw[color=teal] (n300.west) to [bend right=25] (n320.west)
         (n300.east) to [bend left=25] (n320.east);
      \draw[brown,thin] (0,8) -- node[below left,magenta]{$x_5,x_4,x_3$} node[above right,violet]{$x_2,x_1,x_0$} +(-1,1) node[above left,green!70!black] {$z_0$};
      \foreach \x/\l in {0/000,1/001,2/011,3/010,4/110,5/111,6/101,7/100} {
        \node[violet] at (\x+0.5,8.2) {\l};
        \node[magenta] at (-0.4,7.5-\x) {\l};
       }
  }
\end{tikzpicture}
\end{center}

Note, however, that the index inside a cell does not math the Gray code value of the respective row and column. The indices can still be computed by \[32\,x_{5}+8\,x_{4}+2\,x_{3}+16\,x_{2}+4\,x_{1}+1\,x_{0}.\]

\section{Final remarks\label{sec:remarks}}

This is not nearly all you need to know about the usage of these macros. In case you find a bug, or if you have comments or suggestions, please send me an e-mail.

The maximum size map I could produce was a Karnaugh map with 12~variables; with bigger maps I only exceeded \TeX's main memory. This is due to the macros' recursive algorithm. Quite likely you will exceed \TeX's capacity with even smaller maps if they occur in large documents.

If you need help to typeset Karnaugh maps with the marking for the solution on it you can try \verb| JQM - Java Quine McCluskey| for minimization of Boolean functions available on \url{https://sourceforge.net/projects/jqm-java-quine-mccluskey/}. It can generate the solution and create the corresponding map based on a given truth table.
One very useful feature of this software is that you can reorder de variables on the map to suite your particular application instead of rely exclusively on the macro to scatter your variables around.

\end{document}