texlive[46277] Master: tikz-karnaugh (10jan18)

commits+karl at tug.org commits+karl at tug.org
Wed Jan 10 22:42:44 CET 2018


Revision: 46277
          http://tug.org/svn/texlive?view=revision&revision=46277
Author:   karl
Date:     2018-01-10 22:42:43 +0100 (Wed, 10 Jan 2018)
Log Message:
-----------
tikz-karnaugh (10jan18)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/tikz-karnaugh/README.txt
    trunk/Master/texmf-dist/doc/latex/tikz-karnaugh/tikz-karnaugh-doc.pdf
    trunk/Master/texmf-dist/doc/latex/tikz-karnaugh/tikz-karnaugh-doc.tex
    trunk/Master/tlpkg/libexec/ctan2tds

Added Paths:
-----------
    trunk/Master/texmf-dist/doc/latex/tikz-karnaugh/tikzlibrarykarnaugh.code.tex

Removed Paths:
-------------
    trunk/Master/texmf-dist/tex/latex/tikz-karnaugh/

Modified: trunk/Master/texmf-dist/doc/latex/tikz-karnaugh/README.txt
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tikz-karnaugh/README.txt	2018-01-10 21:41:55 UTC (rev 46276)
+++ trunk/Master/texmf-dist/doc/latex/tikz-karnaugh/README.txt	2018-01-10 21:42:43 UTC (rev 46277)
@@ -9,7 +9,7 @@
 later is part of all distributions of LaTeX version 1999/12/01
 or later.
 
- Version 1.0 of 23 December 2017
+ Version 1.1 of 10 January 2018
 
 ------------------------------------------------------------
 

Modified: trunk/Master/texmf-dist/doc/latex/tikz-karnaugh/tikz-karnaugh-doc.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/tikz-karnaugh/tikz-karnaugh-doc.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tikz-karnaugh/tikz-karnaugh-doc.tex	2018-01-10 21:41:55 UTC (rev 46276)
+++ trunk/Master/texmf-dist/doc/latex/tikz-karnaugh/tikz-karnaugh-doc.tex	2018-01-10 21:42:43 UTC (rev 46277)
@@ -2,45 +2,44 @@
 \usepackage[T1]{fontenc}
 \usepackage[latin9]{inputenc}
 \usepackage{lmodern}
+\usepackage{url}
 \usepackage{tikz}
-\usepackage{url}
+% \usetikzlibrary{karnaugh}
+\input ../tex/tikzlibrarykarnaugh.code
 \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 at utfpr.edu.br}}
-\date{Version 1.0 of 22 December 2017}
+\date{Version 1.1 of 10 January 2018}
 
 \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.
+Karnaugh maps are used to simplify logic equations leading to the most compact expression of two levels 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\footnote{The actual limit may be different for you.}, 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. The macros also allow to highlight the simplifications of your logic function directly within a Karnaugh map. This 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 higher 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.
+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 \verb|veitch| macro, available in \verb|karnaugh| package, if you need it.
+Please note that this package, including its documentation, is based on Andreas W. Wieland's previous work and the author wishes 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|: it is a 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\footnote{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\footnote{Those bars have been underappreciated along the history. Karnaugh (1953) himself called them ``simplified labels'' and used them only to replace the Gray coded numbers showing around the map. Their true strength is the ease way they point out which variable belong to a prime implicant and which does not. An approach much easier than interpreting the Gray coded numbers.} (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 highlight groups (prime implicants) and, although it is possible, it is rather difficult and the result is not very good because they always look a bit off. 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, highlighting 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 four variables. Also, the order in which 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 coded binaries on the top and left side of the map. This behaviour can be mimic with \verb|tikz-karnaugh| (see Section~\ref{sec:american}), 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 highlight the 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}
 
+With \verb|tikz-karnaugh| you can typeset big (up to twelve variables or 4096 cells) good looking maps. Using a java software, you can do it automatically, including highlighting the solution.
 
 \subsection{Introductory example}
 
+Let us start with an introduction on how to use these macros. The first thing you have to do is to load \tikzname{}. For this type \verb|\usepackage{tikz}| in the preamble of you document. Then, if the package is somewhere \TeX{} can find it, load the library with the command \verb|\usetikzlibrary{karnaugh}|. If it is not, you can use something like \verb|\input tikzlibrarykarnaugh.code|. You may need to provide the full or relative path to file \verb|tikzlibrarykarnaugh.code.tex|.
 
-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}
@@ -75,81 +74,75 @@
 \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:
+\verb|\karnaughmap| macro in a \tikzname{} environment (\verb|\begin{tikzpicture}|) or inline command (\verb|\tikz|). The \verb|\karnaughmap| macro has five mandatory 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 a list of variable identifiers for the variables;
 \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.
+\item a possibly empty 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}{};
+\tikz[karnaugh,enable indices]%
+  \karnaughmap{4}{f(a,b,c,d)}{abcd}{1110 0110 0110 0110}{};
 \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$.} 
+This produces the following Karnaugh map, where the indices in the upper left corner of each cell correspond to the indices in the truth table:\footnote{The indices can easily be calculated from the variable value in the truth table, e.g., row~11: the index equals $2^{3}\,a+2^{2}\,b+2^{1}\,c+2^{0}\,d=8\,a+4\,b+2\,c+1\,d=8+2+1=11$.} 
 
 \begin{center}
-\tikz[karnaugh,kmindex/.style={red,font=\tiny}]%
-  \karnaughmap{4}{f(a,b,c,d):}{abcd}{1110011001100110}{};
+\tikz[karnaugh,enable indices]%
+  \karnaughmap{4}{f(a,b,c,d)}{abcd}{1110 0110 0110 0110}{};
 \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:
+Each entry has to be one character long and spaces are allowed\footnote{White spaces are really usable to make the string more readable leading to fast verification.}, otherwise -- like a variable identifier enclosed in \$s -- you have to put it into curly brackets:
 
 \begin{verbatim}
 \begin{tikzpicture}[karnaugh]
-   \karnaughmap{4}{$f(a,b,c,d):$}{{$a$}{$b$}{$c$}{$d$}}%
-     {0110011001100110}{}
+   \karnaughmap{4}{$f(a,b,c,d)$}{{$a$}{$b$}{$c$}{$d$}}%
+     {0110 0110 0110 0110}{}
 \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:
+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|,enable indices| from the options list. This produces the following Karnaugh map (observe that the labels are all in math mode):
 
 \begin{center}
 \begin{tikzpicture}[karnaugh]
-   \karnaughmap{4}{$f(a,b,c,d):$}{{$a$}{$b$}{$c$}{$d$}}%
-     {0110011001100110}{}
+   \karnaughmap{4}{$f(a,b,c,d)$}{{$a$}{$b$}{$c$}{$d$}}%
+     {0110 0110 0110 0110}{}
 \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:
+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 highlighting 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}]
+    thick,
+    grp/.style n args={3}{#1,fill=#1!30,
+      minimum width=#2\kmunitlength,
+      minimum height=#3\kmunitlength,
+      rounded corners=0.2\kmunitlength,
+      fill opacity=0.6,
+      rectangle,draw}]
   \karnaughmap{4}{$f(a,b,c,d)$}{{$a$}{$b$}{$c$}{$d$}}%
-    {0110011001100110}%
+    {0110 0110 0110 0110}%
     {
-      \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);
-  }
+      \node[grp={blue}{0.9}{1.9}](n000) at (0.5,2.0) {};
+      \node[grp={blue}{0.9}{1.9}](n001) at (3.5,2.0) {};
+      \draw[blue] (n000.north) to [bend left=25]  (n001.north)
+                  (n000.south) to [bend right=25] (n001.south);
+      \node[grp={red}{1.9}{0.9}](n100) at (2.0,3.5) {};
+      \node[grp={red}{1.9}{0.9}](n110) at (2.0,0.5) {};
+      \draw[red]  (n100.west) to [bend right=25] (n110.west)
+                  (n100.east) to [bend left=25] (n110.east);
+   }
 \end{tikzpicture}
 \end{verbatim}
 
@@ -158,162 +151,159 @@
 \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}]
+    thick,
+    grp/.style n args={3}{#1,fill=#1!30,
+      minimum width=#2\kmunitlength,
+      minimum height=#3\kmunitlength,
+      rounded corners=0.2\kmunitlength,
+      fill opacity=0.6,
+      rectangle,draw}]
   \karnaughmap{4}{$f(a,b,c,d)$}{{$a$}{$b$}{$c$}{$d$}}%
-    {0110011001100110}%
+    {0110 0110 0110 0110}%
     {
-      \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);
-  }
+      \node[grp={blue}{0.9}{1.9}](n000) at (0.5,2.0) {};
+      \node[grp={blue}{0.9}{1.9}](n001) at (3.5,2.0) {};
+      \draw[blue] (n000.north) to [bend left=25]  (n001.north)
+                  (n000.south) to [bend right=25] (n001.south);
+      \node[grp={red}{1.9}{0.9}](n100) at (2.0,3.5) {};
+      \node[grp={red}{1.9}{0.9}](n110) at (2.0,0.5) {};
+      \draw[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}.\]
+and the corresponding expression is:\[f(a,b,c,d) = {\color{blue}c\,\bar{d}} + {\color{red}\bar{c}\,d}\]where colours were used to relate the subexpression with the prime implicant highlighted on the map.
  
-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|.
+Instead of \LaTeX's graphics macros\footnote{As in the original package.} you can use \tikzname{} for this purpose. In this example, a new style \verb|grp| was defined in order to draw semi-transparent rectangles with a specified colour, width and height (both given in \verb|\kmunitlength|). The Karnaugh map has its datum at the lower left point \emph{exactly}. The centre point coordinates of those rectangles are specified using the \verb|at| command. The length of a single cell within the Karnaugh map is equal to \verb|\kmunitlength|. Thus, the \verb|x| and \verb|y| units are set to \verb|1\kmunitlength| so the coordinates can be written without the unit and the rectangles will fall in the precise position even if one changes the map size by changing the \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:
+\section{Adjusting the map size}
 
+Possibly the most important feature that you can change is the size of the diagrams and it is done by changing the size of the cells within the map, simply by typing:
+
 \begin{verbatim}
 \kmunitlength=15mm
 \begin{tikzpicture}[karnaugh]
-   \karnaughmap{4}{$f:$}{abcd}{0110011001100110}{}
+   \karnaughmap{4}{$f$}{abcd}{0110 0110 0110 0110}{}
 \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:
+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}{}
+   \karnaughmap{4}{$f$}{abcd}{0110 0110 0110 0110}{}
 \end{tikzpicture}
 \end{center}
 
-Another feature is that you can switch on the indices inside the map like in the fisrt example by typing: 
 
+\section{If you use the original version of the macros\ldots}
+
+\ldots{} you 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 or inline command.
+
+
+\section{Dimensions, styles and switches}
+
+The appearance of the Karnaugh map is controlled by some styles, dimensions and switches as follows:
+\begin{description}
+\item [{kmbar/.style}] style used for the 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 thin line with T chapped tips.
+\item [{kmbar label/.style}] style used for the variable identifiers 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|red,font=\tiny| meaning they all will typeset in red tiny font if enable (see \verb| enable indices|).
+\item [{kmcell/.style}] style used for cell contents. The default value is \verb|black|.
+\item [{kmbox/.style}] style used for the box surrounding the map. The default value is \verb|thin|.
+\item [{kmlines/.style}] style used for the lines separating adjacent rows and columns. The default value is \verb|thin|.
+\item [{bar sep}] distance between the bar closer to the map and the 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 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 at the left side of map. It depends mainly on the variable identifier width and the font size used in \verb|kmbar label/.style|. The default value is \verb|1\kmunitlength|.
+\item [{enable indices}] boolean switch that enables the typesetting of all indices. The default is \verb|false| meaning that the indices will not be typeset unless they are enabled.
+\item [{disable bars}] boolean switch that disables the typesetting of all bars and the function identifier. Usable when you want an American style map. The default is \verb|false| meaning that the bars will be typeset unless they are disabled.
+\end{description}
+
+For more on styles, have a look in the \tikzname{} documentation.
+
+One feature that you can switch on is the indices inside the map (like in the first example) by typing: 
+
 \begin{verbatim}
-\begin{tikzpicture}[karnaugh,kmindex/.style={red,font=\tiny}]
-  \karnaughmap{4}{$f:$}{abcd}{0110011001100110}{}
+\begin{tikzpicture}[karnaugh,enable indices]
+  \karnaughmap{3}{$f(a,b,c)$}{{$a$}{$b$}{$c$}}{0110 0110}{}
 \end{tikzpicture}
 \end{verbatim}
 
 \begin{center}
 \kmunitlength=8mm
-\begin{tikzpicture}[karnaugh,kmindex/.style={red,font=\tiny}]
-  \karnaughmap{4}{$f:$}{abcd}{0110011001100110}{}
+\begin{tikzpicture}[karnaugh,enable indices]
+  \karnaughmap{3}{$f(a,b,c)$}{{$a$}{$b$}{$c$}}{0110 0110}{}
 \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}
+The font size of the map's contents and indices should be set to suitable values (usually \verb|\tiny| for \verb|kmindex/.style| and \verb|\normalsize| for \verb|kmcell/.style|). Those sizes, of course, can be adjusted as needed in agreement with the cell size controlled by \verb|\kmunitlength|.
 
-\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.
+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},
+    thick,
+    grp/.style n args={3}{#1,fill=#1!30,
+      minimum width=#2\kmunitlength,
+      minimum height=#3\kmunitlength,
+      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},
+    kmbar label/.style={red!70!black,font=\large},
     kmindex/.style={orange,font=\tiny},
+    enable indices,
     kmcell/.style={cyan!80!black},
+    kmbox/.style={brown,thick},
     kmlines/.style={brown,thin},
-    kmvar/.style={green!70!black}]
+    kmvar/.style={green!70!black,font=\huge},
+    lbl/.style={left,align=right,text width=1.5\kmunitlength}]
   \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}%
+    {$x_{5}$}{$x_{2}$}{$x_{4}$}{$x_{1}$}%
+      {[yellow!70!black,name=Nv,|-|,double=red,very thick,
+       label={[font=\tiny,green!50!black]above:var.},
+       text=blue!60!red]$x_{3}$}%
+      {$x_{0}$}}%
+    {--1{}1{}1{}-11-1{}1{}1-{}1{}{}1-1-{}1-{}-1-1%
+     {[red,name=Nc,label={[name=Nl,orange!90!black,
+       label distance=1\kmunitlength]left:Special},
+       circle,inner sep=2pt,draw=green!70!blue]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);
-  }
+      \node[grp={blue}{1.9}{0.9}](n000) at (1.0,7.5) {};
+      \node[grp={blue}{1.9}{0.9}](n002) at (7.0,7.5) {};
+      \node[grp={blue}{1.9}{1.9}](n010) at (1.0,4.0) {};
+      \node[grp={blue}{1.9}{1.9}](n012) at (7.0,4.0) {};
+      \node[grp={blue}{1.9}{0.9}](n030) at (1.0,0.5) {};
+      \node[grp={blue}{1.9}{0.9}](n032) at (7.0,0.5) {};
+      \draw[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={red}{0.8}{7.8}](n100) at (0.5,4.0) {};
+      \node[grp={red}{0.8}{7.8}](n101) at (3.5,4.0) {};
+      \draw[red] (n100.north) to [bend left=25]  (n101.north)
+                 (n100.south) to [bend right=25] (n101.south);
+      \node[grp={orange}{1.9}{1.9}](n200) at (5.0,6.0) {};
+      \node[grp={orange}{1.9}{1.9}](n220) at (5.0,2.0) {};
+      \draw[orange] (n200.west) to [bend right=25] (n220.west)
+                    (n200.east) to [bend left=25]  (n220.east);
+      \node[grp={teal}{1.8}{1.8}](n300) at (6.0,6.0) {};
+      \node[grp={teal}{1.8}{1.8}](n320) at (6.0,2.0) {};
+      \draw[teal] (n300.west) to [bend right=25] (n320.west)
+                  (n300.east) to [bend left=25]  (n320.east);
+ }
+  \draw[<-] (Nv) -- +(-1,1)  node[lbl]{variable on its bar};
+  \draw[<-] (Nc) -- +(-1,-1) node[lbl]{special cell};
+  \draw[<-] (Nl.120) -- +(-1.1,3.5)  node[lbl]{label for special cell};
 \end{tikzpicture}
 \end{verbatim}
 
@@ -322,89 +312,84 @@
 \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},
+    thick,
+    grp/.style n args={3}{#1,fill=#1!30,
+      minimum width=#2\kmunitlength,
+      minimum height=#3\kmunitlength,
+      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},
+    kmbar label/.style={red!70!black,font=\large},
     kmindex/.style={orange,font=\tiny},
+    enable indices,
     kmcell/.style={cyan!80!black},
+    kmbox/.style={brown,thick},
     kmlines/.style={brown,thin},
-    kmvar/.style={green!70!black}]
+    kmvar/.style={green!70!black,font=\huge},
+    lbl/.style={left,align=right,text width=1.5\kmunitlength}]
   \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}%
+    {$x_{5}$}{$x_{2}$}{$x_{4}$}{$x_{1}$}%
+      {[yellow!70!black,name=Nv,|-|,double=red,very thick,
+       label={[font=\tiny,green!50!black]above:var.},
+       text=blue!60!red]$x_{3}$}%
+      {$x_{0}$}}%
+    {--1{}1{}1{}-11-1{}1{}1-{}1{}{}1-1-{}1-{}-1-1%
+     {[red,name=Nc,label={[name=Nl,orange!90!black,
+       label distance=1\kmunitlength]left:Special},
+       circle,inner sep=2pt,draw=green!70!blue]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);
-  }
+      \node[grp={blue}{1.9}{0.9}](n000) at (1.0,7.5) {};
+      \node[grp={blue}{1.9}{0.9}](n002) at (7.0,7.5) {};
+      \node[grp={blue}{1.9}{1.9}](n010) at (1.0,4.0) {};
+      \node[grp={blue}{1.9}{1.9}](n012) at (7.0,4.0) {};
+      \node[grp={blue}{1.9}{0.9}](n030) at (1.0,0.5) {};
+      \node[grp={blue}{1.9}{0.9}](n032) at (7.0,0.5) {};
+      \draw[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={red}{0.8}{7.8}](n100) at (0.5,4.0) {};
+      \node[grp={red}{0.8}{7.8}](n101) at (3.5,4.0) {};
+      \draw[red] (n100.north) to [bend left=25]  (n101.north)
+                 (n100.south) to [bend right=25] (n101.south);
+      \node[grp={orange}{1.9}{1.9}](n200) at (5.0,6.0) {};
+      \node[grp={orange}{1.9}{1.9}](n220) at (5.0,2.0) {};
+      \draw[orange] (n200.west) to [bend right=25] (n220.west)
+                    (n200.east) to [bend left=25]  (n220.east);
+      \node[grp={teal}{1.8}{1.8}](n300) at (6.0,6.0) {};
+      \node[grp={teal}{1.8}{1.8}](n320) at (6.0,2.0) {};
+      \draw[teal] (n300.west) to [bend right=25] (n320.west)
+                  (n300.east) to [bend left=25]  (n320.east);
+ }
+  \draw[<-] (Nv) -- +(-1,1)  node[lbl]{variable on its bar};
+  \draw[<-] (Nc) -- +(-1,-1) node[lbl]{special cell};
+  \draw[<-] (Nl.120) -- +(-1.1,3.5)  node[lbl]{label for special cell};
 \end{tikzpicture}
 \end{center}
+end the logic expression\footnote{This is not of any importance here, but I couldn't hold myself back. By the way, if you are curious, there are another two minimal solutions.} is \[z = {\color{blue}\bar{x}_{3}\,\bar{x}_{1}} + {\color{red}\bar{x}_{2}\,\bar{x}_{0}} + {\color{orange}x_{3}\,x_{2}\,x_{1}} + {\color{teal}x_{3}\,x_{2}\,x_{0}}.\]
 
-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.
+You may notice that the zeros were omitted (replaced by \verb|{}| in the list). Also, the cell~34 is special beause \verb|{[red,name=Nc,| \verb|label={[name=Nl,orange!90!black,| \verb|label distance=|\verb|1\kmunitlength| \verb|]left:| \verb|Special},| \verb|circle,| \verb|inner sep=2pt,| \verb|draw=green!70!blue]1}|. You can put almost anything inside a cell using curly brackets and you can customize the cell style using square brackets. The format is: \verb|{[opt]string}| where \verb|opt| is an optional set of styles (among other \tikzname{} parameters) which will be passed as the last option of \tikzname{} command \verb|\node| and \verb|string| will be written inside de cell by that command. To use this syntax, it is imperative that the very first character after the opening curly brackets (\verb|{|) be the opening square brackets (\verb|[|). Matching pairs of square brackets are allowed inside the optional sequence provided that they are protected inside a pair of curly brackets. In this case, the proper content of cell~34 is just the number~1 near the end, all the rest is the style applied to this single~1, therefore coded between square brackets. The style uses \tikzname{} syntax in order to change colour, font size, add a label, add figure, add decoration and name it for future reference. In this case, two nodes are named \verb|Nc| and \verb|Nl| for future reference. Near the \tikzname{} environment end, those names are used to place arrows pointing to the nodes with a description. The \verb|\draw| command that draws those arrows cannot be placed inside the fifth argument of macro \verb|\karnaughmap| because the fifth argument is typeset before the cells contents (the fourth argument), therefore no name would be created at the time the fifth argument is typeset.
 
-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.
+The variables identifiers (the third argument) can also be formatted individually using style, but note that the custom style will be applied to both the bar line and the node for the variable identifier. If a bar gets segmented, just like $x_3$ bar, the named node will be the top most if the bar is vertical or the right most if the bar is horizontal. The $x_3$ bar is different from the other bars because \verb?[yellow!70!black,name=Nv,|-|,double=red? \verb|,very thick,label={[font=\tiny,green!50!black]above:var.},| \verb|text=| \verb|blue!60!red]| changes its appearance. The node name \verb|Nv| is also not available at the time the fifth argument is typeset. So any command that makes use of it will need to be placed after the end of macro \verb|\karnaughmap|.
 
-\section{American style}
+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.
 
-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}
+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 java software that can help on this matter.
 
-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:
+\section{American style\label{sec:american}}
+
+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. Therefore, this option has to be included in the \tikzname{} environment: \verb|disable bars|.
+
+Then you will need rows and columns labels in Gray code and a caption for the map and variables identifiers. 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) --
+      \draw[kmbox] (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$};
@@ -412,7 +397,7 @@
        {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:
@@ -420,90 +405,115 @@
 \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,
+    thick,
+    grp/.style n args={3}{#1,fill=#1!30,
+      minimum width=#2\kmunitlength,
+      minimum height=#3\kmunitlength,
+      rounded corners=0.2\kmunitlength,
+      fill opacity=0.6,
+      rectangle,draw},
+    disable bars,enable indices,
     kmindex/.style={orange,font=\tiny},
     kmcell/.style={cyan!80!black},
-    kmlines/.style={brown,thin},
-    kmvar/.style={transparent}]
+    kmbox/.style={brown,thick},
+    kmlines/.style={brown,thin}]
   \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{}1{}1{}-11-1{}1{}1-{}1{}{}1-1-{}1-{}-1-11%
      --{}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[grp={blue}{1.9}{0.9}](n000) at (1.0,7.5) {};
+      \node[grp={blue}{1.9}{0.9}](n002) at (7.0,7.5) {};
+      \node[grp={blue}{1.9}{1.9}](n010) at (1.0,4.0) {};
+      \node[grp={blue}{1.9}{1.9}](n012) at (7.0,4.0) {};
+      \node[grp={blue}{1.9}{0.9}](n030) at (1.0,0.5) {};
+      \node[grp={blue}{1.9}{0.9}](n032) at (7.0,0.5) {};
+      \draw[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={red}{0.8}{7.8}](n100) at (0.5,4.0) {};
+      \node[grp={red}{0.8}{7.8}](n101) at (3.5,4.0) {};
+      \draw[red] (n100.north) to [bend left=25]  (n101.north)
+                 (n100.south) to [bend right=25] (n101.south);
+      \node[grp={orange}{1.9}{1.9}](n200) at (5.0,6.0) {};
+      \node[grp={orange}{1.9}{1.9}](n220) at (5.0,2.0) {};
+      \draw[orange] (n200.west) to [bend right=25] (n220.west)
+                    (n200.east) to [bend left=25]  (n220.east);
+      \node[grp={teal}{1.8}{1.8}](n300) at (6.0,6.0) {};
+      \node[grp={teal}{1.8}{1.8}](n320) at (6.0,2.0) {};
+      \draw[teal] (n300.west) to [bend right=25] (n320.west)
+                  (n300.east) to [bend left=25]  (n320.east);
+      \draw[kmbox] (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}.\]
+Note, however, that the index inside a cell does not match the Gray code value of the respective row and column\footnote{Do not use a Gray code table to compute the index.}. 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{Vertical mode}
+
+For an odd number of variables, the Karnaugh map is rectangular and macro \verb|karnaughmap| will typeset it twice as wide as it is high (not taking into account the bars). Like this single variable map:
+\begin{center}
+\tikz[karnaugh,enable indices]%
+  \karnaughmap{1}{$f(a)$}{{$a$}}{10}{};
+\end{center}
+
+This layout is good for presentations because the projection area is usually wider than higher. Paper sheets, on the other hand, are usually higher than wider, so for a big map you may need something like\footnote{Or you can use landscape.}:
+\begin{center}
+\tikz[karnaugh,enable indices]%
+  \karnaughmapvert{1}{$f(a)$}{{$a$}}{10}{};
+\end{center}
+
+This is called, for lack of a better name, vertical mode\footnote{Not to be confused with \TeX{} vertical mode.} and it is done by the \verb|karnaughmapvert| macro. Note that \verb|karnaughmapvert| macro arranges the variables in a different order. Compare the two square (four variables) maps below in the normal (on the left) and vertical mode (on the right) paying attention to the indices and variables identifier.
+
+\begin{center}
+\begin{tabular}{ccc}
+\tikz[karnaugh,enable indices]%
+  \karnaughmap{4}{$f(a,b,c,d)$}{{$a$}{$b$}{$c$}{$d$}}{0101 1011 1011 1101}{};
+& \hspace{5mm} &
+\tikz[karnaugh,enable indices]%
+  \karnaughmapvert{4}{$f(a,b,c,d)$}{{$a$}{$b$}{$c$}{$d$}}{0101 1011 1011 1101}{};\\
+Normal (horizontal) mode && Vertical mode
+\end{tabular}
+\end{center}
+
+The indices are calculated in the same way, but their position inside the map are different because the variables positions are different. It is like one map is mirrored and then rotated 90$^o$ (mirrored horizontally and rotated clockwise or mirrored vertically and rotated counterclockwise.) Exactly like a matrix been transposed.
+
+One interesting application of vertical mode is when you want to keep consistency in variable identifier position among maps with odd and even number of variables. For example, if you want the most significant variable $a$ appearing on top of the maps you can use normal (horizontal) mode for maps of odd number of variables and vertical mode for even amounts, like this:
+
+\begin{center}
+\begin{tabular}[t]{ccc}
+\tikz[karnaugh,enable indices]%
+  \karnaughmap{3}{$f(a,b,c)$}{{$a$}{$b$}{$c$}}{0101 1011}{};
+& \hspace{5mm} &
+\tikz[karnaugh,enable indices]%
+  \karnaughmapvert{4}{$g(a,b,c,d)$}{{$a$}{$b$}{$c$}{$d$}}{0101 1011 1011 1101}{};\\
+Normal (horizontal) mode && Vertical mode
+\end{tabular}
+\end{center}
+
+A more general approach is to use the java software described in Section~\ref{sec:remarks} to create maps with arbitrary variables positioning. Suppose that you desire the most significant variable $a$ to appear at the left side of the map. You can do the opposite of what was done in the last example, but you will end up with a vertical map of three variables and maybe it is not what you want. Using the software described in Section~\ref{sec:remarks} allows $a$ to be placed at the left in a normal (horizontal) mode map, but it changes the indices because it reorder the truth tablet such that $a$ will no longer be the most significant variable, but without changing the logic function.
+
 \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.
+This is not even nearly all you need to know about the usage of these macros, but it is a good start. 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.
+If you need help to typeset Karnaugh maps with or without the prime implicants highlighted, 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}
-
-
+\end{document}
\ No newline at end of file

Added: trunk/Master/texmf-dist/doc/latex/tikz-karnaugh/tikzlibrarykarnaugh.code.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tikz-karnaugh/tikzlibrarykarnaugh.code.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/tikz-karnaugh/tikzlibrarykarnaugh.code.tex	2018-01-10 21:42:43 UTC (rev 46277)
@@ -0,0 +1,470 @@
+%% This is file `tikzlibrarykarnaugh.code.tex' formerly known as `tikz-karnaugh.tex',
+%% Version 1.1 of 10 January 2018
+%% 
+%% Copyright (C) 2017 by Luis Paulo Laus, laus at utfpr.edu.br
+%%
+%% This package can be redistributed and/or modified under the terms
+%% of the LaTeX Project Public License distributed from CTAN
+%% archives in directory macros/latex/base/lppl.txt; either
+%% version 1 of the License, or (at your option) any later version,
+%% with `The Package' referring to the software `tikzlibrarykarnaugh.code.tex' and its
+%% accompanying documentation and `The Copyright Holder' referring to the
+%% person Luis Paulo Laus.
+%% 
+%% This software is based on Andreas W. Wieland's kvmacros.tex to whom 
+%% the author wished to express his gratitude.
+%% 
+%% IMPORTANT NOTICE: 
+%% 
+%% For error reports, comments or suggestions in case of UNCHANGED 
+%% versions send mail to:
+%% laus at utfpr.edu.br
+%% 
+%%
+\typeout{}
+\typeout{Macros for typesetting Karnaugh maps}
+\typeout{Version 1.1 of 10 January 2018}
+\typeout{by Luis Paulo Laus, laus at utfpr.edu.br}
+\typeout{}
+%%
+%% Change History:
+%% 1.0: 22 December 2017: Original Version ported from kvmacros.tex
+%% 1.1: 10 January 2018: new style for the map outer box. Support for
+%% options in the identifiers and values lists. New vertical mode.
+%% New keys to enable indices and disable bars. Macro file renamed
+%% to proper tikz library file name.
+%%
+%%
+%%
+%% Setting up some TikZ parameters for Karnaugh Maps
+%%
+\tikzset{
+  karnaugh/.style={
+    kmbar/.style={black,|-|,thin},
+    kmbar label/.style={black},
+    bar sep/.style={kmbar sep={##1}},
+    bar top sep/.style={kmbar top sep={##1}},
+    bar left sep/.style={kmbar left sep={##1}},
+    kmindex/.style={red,font=\tiny},
+    karnaugh index/.style={kmindex/.style={##1}},
+    kmcell/.style={black},
+    kmvar/.style={black},
+    kmbox/.style={thin},
+    kmlines/.style={thin},
+    every karnaugh/.try,
+    enable indices/.is if=enableindices,
+    disable bars/.is if=disablebars,
+  }
+}
+
+\pgfkeys{/pgf/.cd,
+  kmbar sep/.initial=0.2\kmunitlength,
+  kmbar top sep/.initial=1\kmunitlength,
+  kmbar left sep/.initial=1\kmunitlength,
+}
+
+%%
+%% New ifs for the options above
+%%
+\newif\ifenableindices
+\enableindicesfalse
+\newif\ifdisablebars
+\disablebarsfalse
+%%
+%% We need a fixed dimension for a single field in a Karnaugh map
+%% and also an auxiliary dimension to place the bars.
+%%
+\newdimen\kmunitlength
+\newdimen\kmtemplength
+\kmunitlength=8mm
+%%
+%% First, we have to introduce some counters:
+%%
+%% \kmrecursiondepth is used to control the recursion of the
+%% \karnaughmakemap.
+%%
+\newcount\kmrecursiondepth
+%%
+%% The \kmindexcounter is needed for the indices in the fields of the
+%% diagrams. 
+%%
+\newcount\kmindexcounter
+%% 
+%% \kmxsize and \kmysize store the dimensions of an entire diagram.
+%%
+\newcount\kmxsize
+\newcount\kmysize
+%%
+%% Some counters are necessary to compute the bars for the variable
+%% identifiers:
+%%
+\newcount\kmvarno
+\newcount\kmxvarno
+\newcount\kmyvarno
+\newcount\kmbarstart
+\newcount\kmbarlength
+\newcount\kmbarnum
+\newcount\kmbarmove
+\newcount\kmtemppos
+%%
+%% Single cells in a diagram should be indexed, which makes the map easier to
+%% use (ok, not really, but it might be useful).
+%%
+\def\kmcurrentindex{%
+\the\kmindexcounter\global\advance\kmindexcounter by 1}%
+%%
+%% We need a macro that computes the powers of two:
+%%
+\def\kmpoweroftwo#1#2{{% Computes #1=2^#2, both of which have to be counters
+  \ifnum#2>0 
+    \global\multiply#1 by 2 
+    \advance#2 by -1
+    \kmpoweroftwo{#1}{#2}
+  \fi}}
+%%
+%% The macros \kmargumentstring and \kmsetoptstr are needed to
+%% process the variable-length parameters in \karnaughmap:
+%%
+\def\kmargumentstring#1{\gdef\kmstringbuf{#1{}\noexpand\end}}
+%%
+%% The macro \kmsetoptstr reads one token from the list of parameters in
+%% \karnaughmap in the form <[opt]>srt and sets the optional style kmtempsty 
+%% and saves its contents of the string srt in macro \kmstr
+%%
+\def\kmsetoptstr{\expandafter\kmgetonetok\kmstringbuf}
+%%
+%% The macros \kmgetonetok, \kmsplittok and \kmoptstrmake are
+%% auxiliary macros used to split the token and save to contents
+%%
+\def\kmgetonetok#1#2\end{\expandafter\kmsplittok#1{}\end \gdef\kmstringbuf{#2\noexpand\end}}
+\def\kmsplittok#1#2\end{\ifx#1[ \kmoptstrmake#2\end \else \kmoptstrmake]#1#2\end \fi}
+\def\kmoptstrmake#1]#2\end{\tikzset{kmtempsty/.style={#1}} \edef\kmstr{#2}}%\typeout{Teste #1 e #2}}
+%%\def\kmoptstrmake#1]#2\end{Test: #1 and #2.\par}
+%%
+%% The macro \karnaughmakemap calls itself recursively until the parameter #1
+%% equals 1, whereupon it draws one cell contents in a node and, if enabled,
+%% another node with the index.
+%%
+\def\karnaughmakemap#1#2#3#4{{%
+  \kmrecursiondepth #1\relax
+  \ifnum\kmrecursiondepth>1
+    \divide\kmrecursiondepth by 2
+    \edef\tempx{#3}
+    \edef\tempy{#4}
+    \kmtemppos=\tempx\relax
+    \advance\kmtemppos by \kmrecursiondepth
+    \edef\tempxs{\the\kmtemppos}
+    \kmtemppos=\tempy\relax
+    \advance\kmtemppos by \kmrecursiondepth
+    \edef\tempys{\the\kmtemppos}
+
+    \ifcase#2
+%%
+%% The parameter #2 of \karnaughmakemap is needed because the inner Karnaugh
+%% maps need to be mirrored. This is achieved by the following case-statement,
+%% which orders the inner Karnaugh maps properly:
+%% +---+---+
+%% | 0 | 1 |
+%% +---+---+
+%% | 2 | 3 |
+%% +---+---+
+%%
+%% Case 0: top-left Karnaugh map
+      \karnaughmakemap{\kmrecursiondepth}{0}{\tempx}{\tempys}%
+      \karnaughmakemap{\kmrecursiondepth}{1}{\tempxs}{\tempys}%
+      \karnaughmakemap{\kmrecursiondepth}{2}{\tempx}{\tempy}%
+      \karnaughmakemap{\kmrecursiondepth}{3}{\tempxs}{\tempy}%
+    \or
+%% Case 1: top-right Karnaugh map
+      \karnaughmakemap{\kmrecursiondepth}{1}{\tempxs}{\tempys}%
+      \karnaughmakemap{\kmrecursiondepth}{0}{\tempx}{\tempys}%
+      \karnaughmakemap{\kmrecursiondepth}{3}{\tempxs}{\tempy}%
+      \karnaughmakemap{\kmrecursiondepth}{2}{\tempx}{\tempy}%
+    \or
+%% Case 2: bottom-left Karnaugh map
+      \karnaughmakemap{\kmrecursiondepth}{2}{\tempx}{\tempy}%
+      \karnaughmakemap{\kmrecursiondepth}{3}{\tempxs}{\tempy}%
+      \karnaughmakemap{\kmrecursiondepth}{0}{\tempx}{\tempys}%
+      \karnaughmakemap{\kmrecursiondepth}{1}{\tempxs}{\tempys}%
+    \or
+%% Case 3: bottom-right Karnaugh map
+      \karnaughmakemap{\kmrecursiondepth}{3}{\tempxs}{\tempy}%
+      \karnaughmakemap{\kmrecursiondepth}{2}{\tempx}{\tempy}%
+      \karnaughmakemap{\kmrecursiondepth}{1}{\tempxs}{\tempys}%
+      \karnaughmakemap{\kmrecursiondepth}{0}{\tempx}{\tempys}%
+    \fi
+  \else
+    \ifenableindices
+      \node[kmindex,shift={(-0.3\kmunitlength,0.3\kmunitlength)}]
+        at (#3\kmunitlength,#4\kmunitlength) {\kmcurrentindex};
+    \fi
+    \kmsetoptstr{} % reads argument as <[opt]>str
+    \node[kmcell,kmtempsty] at (#3\kmunitlength,#4\kmunitlength){\kmstr};%
+  \fi}}%
+%%
+%% \karnaughmaketopbar typesets the variable bars of a Karnaugh map that are
+%% located on top of the diagram:
+%%
+\def\karnaughmaketopbar{%
+  \kmbarstart=1
+  \kmpoweroftwo{\kmbarstart}{\kmxvarno} % \kmybarstart is the start 
+% position for the \foreach
+  \kmbarlength=\kmbarstart 
+  \multiply\kmbarlength by 2 % \kmbarlength is the length of a bar
+  \kmbarmove=\kmbarstart 
+  \multiply\kmbarmove by 4 % This is the move distance for the \draw.
+  \kmbarnum=\kmxsize
+  \divide\kmbarnum by \kmbarmove % This is the number of repetitions for
+% the \foreach. 
+% The highest-order variable bar needs a special treatment:
+  \ifnum\kmbarnum=0\kmbarnum=1\divide\kmbarlength by 2\fi 
+  \advance\kmbarmove by \kmbarstart
+  \kmtemplength=\pgfkeysvalueof{/pgf/kmbar top sep}
+  \multiply \kmtemplength by \kmxvarno
+  \advance \kmtemplength by \pgfkeysvalueof{/pgf/kmbar sep}
+  \advance \kmtemplength by \kmysize\kmunitlength
+  \kmsetoptstr % reads argument as <[opt]>str
+  \ifnum\kmbarnum=1
+    \draw[kmbar,xshift=\kmbarstart\kmunitlength,yshift=\kmtemplength,kmtempsty]
+      (0,0) -- node[above, kmbar label,kmtempsty]{\kmstr} (\kmbarlength\kmunitlength,0);
+  \else
+    \foreach \x in {\kmbarstart,\kmbarmove,...,\kmxsize}
+      \draw[kmbar,xshift=\x\kmunitlength,yshift=\kmtemplength,kmtempsty]
+        (0,0) -- node[above, kmbar label,kmtempsty]{\kmstr} (\kmbarlength\kmunitlength,0);
+  \fi
+}
+%%
+%% \karnaughmakeleftbar typesets the variable bars of a Karnaugh map that are
+%% located on the left of the diagram:
+%%
+\def\karnaughmakeleftbar{%
+  \kmbarstart=1
+  \kmpoweroftwo{\kmbarstart}{\kmyvarno} % \kmbarstart is the start 
+% position for the \foreach
+  \kmbarlength=\kmbarstart 
+  \multiply\kmbarlength by 2 % \kmbarlength is the length of a bar
+  \kmbarmove=\kmbarstart 
+  \multiply\kmbarmove by 4 % This now is the move distance for the
+% \foreach. 
+  \kmbarnum=\kmysize
+  \divide\kmbarnum by \kmbarmove % This now is the number of 
+% repetitions for the \draw. 
+%The highest-order variable bar needs a special treatment:
+  \ifnum\kmbarnum=0\kmbarstart=0\kmbarnum=1\divide\kmbarlength by 2\fi 
+  \advance\kmbarmove by \kmbarstart
+  \kmtemplength=-\pgfkeysvalueof{/pgf/kmbar left sep}
+  \multiply \kmtemplength by \kmyvarno
+  \advance \kmtemplength by -\pgfkeysvalueof{/pgf/kmbar sep}
+  \kmsetoptstr % reads argument as <[opt]>str
+  \ifnum\kmbarnum=1
+    \draw[kmbar,yshift=\kmbarstart\kmunitlength,xshift=\kmtemplength,kmtempsty]
+      (0,0) -- node[left,kmbar label,kmtempsty]{\kmstr} (0,\kmbarlength\kmunitlength);
+  \else
+    \foreach \y in {\kmbarstart,\kmbarmove,...,\kmysize}
+      \draw[kmbar,yshift=\y\kmunitlength,xshift=\kmtemplength,kmtempsty]
+        (0,0) -- node[left,kmbar label,kmtempsty]{\kmstr} (0,\kmbarlength\kmunitlength);
+  \fi
+}
+%% \karnaughmakebars calls \karnaughmaketopbar or \karnaughmakeleftbar
+%% depending on whether \kmvarno is odd or even.
+%%
+\def\karnaughmakebars{%
+  \ifnum\kmvarno>0
+    \let\next=\karnaughmakebars
+    \ifodd\kmvarno % We have to make a bar at the top
+      \advance\kmxvarno by -1
+      \karnaughmaketopbar
+    \else          % We have to make a bar at the left
+      \advance\kmyvarno by -1
+      \karnaughmakeleftbar
+    \fi
+    \advance\kmvarno by -1
+  \else
+    \let\next=\relax
+  \fi
+  \next
+}
+%%
+%% \karnaughmap is the macro that a user calls if he wants to draw a
+%% Karnaugh map: 
+%%
+\def\karnaughmap#1#2#3#4#5{%
+%%
+%% #1 is the number of variables in the Karnaugh map
+%% #2 is the identifier of the function
+%% #3 is the list of identifiers of those variables 
+%% #4 is the list of tokens that have to be written into the map
+%% #5 a possibly empty set of TikZ commands that will be drown before
+%% the function values so the values will appear on top of them
+%%
+  \kmvarno=#1 % \kmvarno is the total number of variables 
+  \kmyvarno=#1 % \kmyvarno is the number of variable bars at the left 
+  \divide\kmyvarno by 2
+  \kmxvarno=#1 % \kmxvarno is the number of variable bars on top 
+  \advance\kmxvarno by -\kmyvarno
+  \kmxsize=1
+  \kmpoweroftwo{\kmxsize}{\kmxvarno}
+  \kmysize=1
+  \kmpoweroftwo{\kmysize}{\kmyvarno}
+  \kmtemppos=\kmxsize
+  \advance\kmtemppos by -1
+  \foreach \x in {1,...,\kmtemppos}
+    \draw[kmlines] (\x\kmunitlength,0) -- (\x\kmunitlength,\kmysize\kmunitlength);
+  \kmtemppos=\kmysize
+  \advance\kmtemppos by -1
+  \ifnum\kmtemppos>0
+    \foreach \y in {1,...,\kmtemppos}
+      \draw[kmlines] (0,\y\kmunitlength) -- (\kmxsize\kmunitlength,\y\kmunitlength);
+  \fi
+  \draw[kmbox] (0,0) rectangle (\kmxsize\kmunitlength,\kmysize\kmunitlength);
+  #5
+  \ifdisablebars\relax\else
+    \node[kmvar,above left] at (0,\kmysize\kmunitlength){#2};
+    \kmargumentstring{#3}
+    \karnaughmakebars
+  \fi
+  \pgftransformshift{\pgfpoint{0.5\kmunitlength}{0.5\kmunitlength}}
+  \kmvarno=#1 % \kmvarno is the total number of variables 
+  \kmindexcounter=0
+  \kmargumentstring{#4}
+  \karnaughmakemap{\the\kmysize}{0}{0}{0}
+  \ifodd\kmvarno
+    \divide\kmxsize by 2
+    \karnaughmakemap{\the\kmysize}{1}{\the\kmxsize}{0}
+  \fi
+  \pgftransformreset
+}%
+%% Vertical Mode
+%% The next three macros are similar to the ones for normal mode.
+%% The macro \karnaughmakemapvert calls itself recursively until the parameter #1
+%% equals 1, whereupon it draws one cell contents in a node and, if enabled,
+%% another node with the index.
+%%
+\def\karnaughmakemapvert#1#2#3#4{{%
+  \kmrecursiondepth #1\relax
+  \ifnum\kmrecursiondepth>1
+    \divide\kmrecursiondepth by 2
+    \edef\tempx{#3}
+    \edef\tempy{#4}
+    \kmtemppos=\tempx\relax
+    \advance\kmtemppos by \kmrecursiondepth
+    \edef\tempxs{\the\kmtemppos}
+    \kmtemppos=\tempy\relax
+    \advance\kmtemppos by \kmrecursiondepth
+    \edef\tempys{\the\kmtemppos}
+
+    \ifcase#2
+%%
+%% The parameter #2 of \karnaughmakemapvert is needed because the inner Karnaugh
+%% maps need to be mirrored. This is achieved by the following case-statement,
+%% which orders the inner Karnaugh maps properly:
+%% +---+---+
+%% | 0 | 2 |
+%% +---+---+
+%% | 1 | 3 |
+%% +---+---+
+%%
+%% Case 0: top-left Karnaugh map
+      \karnaughmakemapvert{\kmrecursiondepth}{0}{\tempx}{\tempys}%
+      \karnaughmakemapvert{\kmrecursiondepth}{1}{\tempx}{\tempy}%
+      \karnaughmakemapvert{\kmrecursiondepth}{2}{\tempxs}{\tempys}%
+      \karnaughmakemapvert{\kmrecursiondepth}{3}{\tempxs}{\tempy}%
+    \or
+%% Case 1: bottom-left Karnaugh map
+      \karnaughmakemapvert{\kmrecursiondepth}{1}{\tempx}{\tempy}%
+      \karnaughmakemapvert{\kmrecursiondepth}{0}{\tempx}{\tempys}%
+      \karnaughmakemapvert{\kmrecursiondepth}{3}{\tempxs}{\tempy}%
+      \karnaughmakemapvert{\kmrecursiondepth}{2}{\tempxs}{\tempys}%
+    \or
+%% Case 2: top-right Karnaugh map
+      \karnaughmakemapvert{\kmrecursiondepth}{2}{\tempxs}{\tempys}%
+      \karnaughmakemapvert{\kmrecursiondepth}{3}{\tempxs}{\tempy}%
+      \karnaughmakemapvert{\kmrecursiondepth}{0}{\tempx}{\tempys}%
+      \karnaughmakemapvert{\kmrecursiondepth}{1}{\tempx}{\tempy}%
+    \or
+%% Case 3: bottom-right Karnaugh map
+      \karnaughmakemapvert{\kmrecursiondepth}{3}{\tempxs}{\tempy}%
+      \karnaughmakemapvert{\kmrecursiondepth}{2}{\tempxs}{\tempys}%
+      \karnaughmakemapvert{\kmrecursiondepth}{1}{\tempx}{\tempy}%
+      \karnaughmakemapvert{\kmrecursiondepth}{0}{\tempx}{\tempys}%
+    \fi
+  \else
+    \ifenableindices
+      \node[kmindex,shift={(-0.3\kmunitlength,0.3\kmunitlength)}]
+        at (#3\kmunitlength,#4\kmunitlength) {\kmcurrentindex};%
+    \fi
+    \kmsetoptstr{} % reads argument as <[opt]>str
+    \node[kmcell,kmtempsty] at (#3\kmunitlength,#4\kmunitlength){\kmstr};%
+  \fi}}%
+%%
+%% \karnaughmakebarsvert calls \karnaughmaketopbar or \karnaughmakeleftbar
+%% depending on whether \kmvarno is odd or even.
+%%
+\def\karnaughmakebarsvert{%
+  \ifnum\kmvarno>0
+    \let\next=\karnaughmakebarsvert
+    \ifodd\kmvarno % We have to make a bar at the left
+      \advance\kmyvarno by -1
+      \karnaughmakeleftbar 
+    \else          % We have to make a bar at the top
+      \advance\kmxvarno by -1
+      \karnaughmaketopbar
+    \fi
+    \advance\kmvarno by -1
+  \else
+    \let\next=\relax
+  \fi
+  \next
+}
+%%
+%% \karnaughmapvert is the macro that a user calls if he wants to draw a
+%% Karnaugh map in vertical mode (not be confused with TeX vertical mode): 
+%%
+\def\karnaughmapvert#1#2#3#4#5{%
+%%
+%% #1 is the number of variables in the Karnaugh map
+%% #2 is the identifier of the function
+%% #3 is the list of identifiers of those variables 
+%% #4 is the list of tokens that have to be written into the map
+%% #5 a possibly empty set of TikZ commands that will be drown before
+%% the function values so the values will appear on top of them
+%%
+  \kmvarno=#1 % \kmvarno is the total number of variables 
+  \kmxvarno=#1 % \kmxvarno is the number of variable bars on top
+  \divide\kmxvarno by 2
+  \kmyvarno=#1 % \kmyvarno is the number of variable bars at the left
+  \advance\kmyvarno by -\kmxvarno
+  \kmxsize=1
+  \kmpoweroftwo{\kmxsize}{\kmxvarno}
+  \kmysize=1
+  \kmpoweroftwo{\kmysize}{\kmyvarno}
+  \kmtemppos=\kmxsize
+  \advance\kmtemppos by -1
+  \ifnum\kmtemppos>0
+    \foreach \x in {1,...,\kmtemppos}
+      \draw[kmlines] (\x\kmunitlength,0) -- (\x\kmunitlength,\kmysize\kmunitlength);
+  \fi
+  \kmtemppos=\kmysize
+  \advance\kmtemppos by -1
+  \foreach \y in {1,...,\kmtemppos}
+    \draw[kmlines] (0,\y\kmunitlength) -- (\kmxsize\kmunitlength,\y\kmunitlength);
+  \draw[kmbox] (0,0) rectangle (\kmxsize\kmunitlength,\kmysize\kmunitlength);
+  #5
+  \ifdisablebars\relax\else
+    \node[kmvar,above left] at (0,\kmysize\kmunitlength){#2};
+    \kmargumentstring{#3}
+    \karnaughmakebarsvert
+  \fi
+  \pgftransformshift{\pgfpoint{0.5\kmunitlength}{0.5\kmunitlength}}
+  \kmvarno=#1 % \kmvarno is the total number of variables 
+  \kmindexcounter=0
+  \kmargumentstring{#4}
+  \ifodd\kmvarno
+    \divide\kmysize by 2
+    \karnaughmakemapvert{\the\kmxsize}{0}{0}{\the\kmysize}
+    \karnaughmakemapvert{\the\kmxsize}{1}{0}{0}
+  \else
+    \karnaughmakemapvert{\the\kmxsize}{0}{0}{0}
+  \fi
+  \pgftransformreset
+}%


Property changes on: trunk/Master/texmf-dist/doc/latex/tikz-karnaugh/tikzlibrarykarnaugh.code.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/tlpkg/libexec/ctan2tds
===================================================================
--- trunk/Master/tlpkg/libexec/ctan2tds	2018-01-10 21:41:55 UTC (rev 46276)
+++ trunk/Master/tlpkg/libexec/ctan2tds	2018-01-10 21:42:43 UTC (rev 46277)
@@ -693,6 +693,7 @@
  'lxfonts',     "&MAKEflatten",
  'ly1',         "&MAKEcopy",
  'lyx',         "die 'skipping, container directory'",
+ 'm-tx',        "die 'skipping, awaiting tl18!'",
  'mab2bib',     "die 'skipping, python'",
  'magyar',      "die 'skipping, use babel-hungarian'",
  'make-env',    "die 'skipping, no license, too old to bother with'",



More information about the tex-live-commits mailing list