diff options
author | Karl Berry <karl@freefriends.org> | 2015-04-21 23:42:00 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2015-04-21 23:42:00 +0000 |
commit | ca0df6497bcdb1e76efe38af03eac5da6bfb3f20 (patch) | |
tree | 3c4448b281cf485a89add4f3f58f5f96671551a2 | |
parent | e582c1ed07943cc8587a433d923c157b031a5762 (diff) |
karnaughmap (21apr15)
git-svn-id: svn://tug.org/texlive/trunk@36989 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/doc/latex/karnaughmap/README | 22 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/karnaughmap/karnaughmap.pdf | bin | 0 -> 325634 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/karnaughmap/karnaughmap.dtx | 1815 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/karnaughmap/karnaughmap.ins | 64 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/karnaughmap/karnaughmap.sty | 579 | ||||
-rwxr-xr-x | Master/tlpkg/bin/tlpkg-ctan-check | 2 | ||||
-rw-r--r-- | Master/tlpkg/tlpsrc/collection-science.tlpsrc | 1 | ||||
-rw-r--r-- | Master/tlpkg/tlpsrc/karnaughmap.tlpsrc | 0 |
8 files changed, 2482 insertions, 1 deletions
diff --git a/Master/texmf-dist/doc/latex/karnaughmap/README b/Master/texmf-dist/doc/latex/karnaughmap/README new file mode 100644 index 00000000000..47ec072c501 --- /dev/null +++ b/Master/texmf-dist/doc/latex/karnaughmap/README @@ -0,0 +1,22 @@ +Copyright (C) 2015 by Michael Vonbun <m.vonbun@gmail.com> +--------------------------------------------------------- + +The karnaughmap package may be distributed and/or modified under the +conditions of the LaTeX Project Public License, either version 1.2 +of this license or (at your option) any later version. +The latest version of this license is in: + http://www.latex-project.org/lppl.txt +and version 1.2 or later is part of all distributions of LaTeX +version 1999/12/01 or later. + + +April 20, 2015 + +KARNAUGHMAP is a LaTeX package used to draw Karnaugh maps. + +It got inspired by the karnaugh macros provided at https://www.ctan.org/tex-archive/macros/latex/contrib/karnaugh. + +It offers an easy to use key-value interface, based on the input of an ordered truth table. +Intended for educational purposes, it allows to customize the fields of the Karnaugh map (e.g. by enumerating the fields). + +For details see the package documentation. diff --git a/Master/texmf-dist/doc/latex/karnaughmap/karnaughmap.pdf b/Master/texmf-dist/doc/latex/karnaughmap/karnaughmap.pdf Binary files differnew file mode 100644 index 00000000000..92896da46ee --- /dev/null +++ b/Master/texmf-dist/doc/latex/karnaughmap/karnaughmap.pdf diff --git a/Master/texmf-dist/source/latex/karnaughmap/karnaughmap.dtx b/Master/texmf-dist/source/latex/karnaughmap/karnaughmap.dtx new file mode 100644 index 00000000000..7f9244b7f65 --- /dev/null +++ b/Master/texmf-dist/source/latex/karnaughmap/karnaughmap.dtx @@ -0,0 +1,1815 @@ +% \iffalse meta-comment +% +% Copyright (C) 2015 by Michael Vonbun <m.vonbun@gmail.com> +% --------------------------------------------------------- +% +% This file may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.2 +% of this license or (at your option) any later version. +% The latest version of this license is in: +% +% http://www.latex-project.org/lppl.txt +% +% and version 1.2 or later is part of all distributions of LaTeX +% version 1999/12/01 or later. +% +% \fi +% +% \iffalse +%<*driver> +\ProvidesFile{karnaughmap.dtx} +%</driver> +%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01] +%<package>\ProvidesPackage{karnaughmap} +%<*package> + [2015/04/20 v2.0 draw karnaugh maps using tikz] +%</package> +% +%<*driver> +\documentclass{ltxdoc} +\usepackage{xkvview} +\usepackage{hyperref} +\usepackage{karnaughmap}[2013/12/06] +\EnableCrossrefs +\CodelineIndex +\RecordChanges +\begin{document} + \DocInput{karnaughmap.dtx} + \PrintChanges + \PrintIndex +\end{document} +%</driver> +% \fi +% +% \CheckSum{751} +% +% \CharacterTable +% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +% Digits \0\1\2\3\4\5\6\7\8\9 +% Exclamation \! Double quote \" Hash (number) \# +% Dollar \$ Percent \% Ampersand \& +% Acute accent \' Left paren \( Right paren \) +% Asterisk \* Plus \+ Comma \, +% Minus \- Point \. Solidus \/ +% Colon \: Semicolon \; Less than \< +% Equals \= Greater than \> Question mark \? +% Commercial at \@ Left bracket \[ Backslash \\ +% Right bracket \] Circumflex \^ Underscore \_ +% Grave accent \` Left brace \{ Vertical bar \| +% Right brace \} Tilde \~} +% +% +% \changes{v1.0}{2013/08/29}{Initial version} +% \changes{v1.0a}{2013/08/29}{Added a to do section} +% \changes{v1.1}{2013/08/29}{Added binary indices} +% \changes{v1.2}{2013/08/30}{Added negated labels +% and adjusted the positioning of variable and function labels.} +% \changes{v1.3}{2013/09/04}{Made the table color adjustable.} +% \changes{v1.4}{2013/12/06}{Added a colored box highlight macro.} +% \changes{v2.0}{2015/04/20}{Minor touchup for publication.} +% +% \GetFileInfo{karnaughmap.dtx} +% +% \DoNotIndex{\newcommand,\newenvironment,\else,\fi} +% +% +% \title{The \textsf{karnaughmap} package\thanks{This document +% corresponds to \textsf{karnaughmap}~\fileversion, dated \filedate.}} +% \author{Michael Vonbun \\ \texttt{m.vonbun@gmail.com}} +% +% \maketitle +% +% \section{Introduction}% \iffalse TODO: SEC:Intoduction \fi +% +% This package uses TikZ to typeset Karnaugh maps in an easy way. +% Though the map size is restricted to four variables (as for \fileversion), +% it is easier and customizable compared to \textsf{karnaugh.tex}. +% +% \section{Installation}% \iffalse TODO: SEC:Installation \fi +% +% Install this package like any other \LaTeX~package.\\ +% +% \noindent +% The end of this file contains the installation file (.ins) code in case +% the provided ins-file got lost.\\ +% +% \noindent +% For style creation run |latex karnaughmap.ins|. +% For doc/manual creation run |latex karnaughmap.dtx| afterwards. +% +% \section{Dependencies}% \iffalse TODO: SEC:Dependencies \fi +% +% As of \textsf{karnaughmap}~\fileversion~this package depends on +% \begin{itemize} +% \item \textsf{tikz} +% \item \textsf{xkeyval} +% \item \textsf{ifthen} +% \item \textsf{xstring} +% \end{itemize} +% +% \section{Usage}% \iffalse TODO: SEC:Usage \fi +% +% \subsection{Karnaugh Map Macros}% \iffalse TODO: SUBSEC:Karnaugh Map Macros \fi +% +% \DescribeMacro{\karnaughmap} |\karnaughmap|\oarg{key=value}\marg{entries} +% +% Use this macro inside of a |tikzpicture|-environment to typeset a Karnaugh map +% of a corresponding truth table.\\ +% +% \paragraph{Example} +% Assume the truth table with inputs $a$ and $b$ and output $z$ is +% \begin{center} +% \begin{tabular}{ccc} +% $a$ & $b$ & $z$ \\\hline +% 0 & 0 & 0 \\ +% 0 & 1 & 0 \\ +% 1 & 0 & * \\ +% 1 & 1 & 1 +% \end{tabular} +% \end{center} +% +% \begin{minipage}[t]{0.45\textwidth}% +% Then, the corresponding Karnaugh map with default layout is:\\ +% \begin{tikzpicture}[thick] +% \karnaughmap{00*1} +% \end{tikzpicture}\\ +% \end{minipage} +% \hfill +% \begin{minipage}[t]{0.45\textwidth}% +% Which was typeset using:\\ +% |\begin{tikzpicture}[thick] |\\ +% | \karnaughmap{00*1} |\\ +% |\end{tikzpicture} | +% \end{minipage} +% +% To produce empty maps, there are two possibilities. +% First is to use the key |defaultmap| described later and omit the mandatory input, +% the second is by providing a scalar mandatory argument that is equal the number of cells desired, +% i.e. 4,8, or 16. +% +% \begin{minipage}[t]{0.45\textwidth}% +% \begin{center} +% |\karnaughmap{4}|\\ +% \begin{tikzpicture}[thick] +% \karnaughmap{4} +% \end{tikzpicture}\\ +% \end{center} +% \end{minipage} +% \hfill +% \begin{minipage}[t]{0.45\textwidth}% +% \begin{center} +% |\karnaughmap[defaultmap=4]{}|\\ +% \begin{tikzpicture}[thick] +% \karnaughmap[defaultmap=4]{} +% \end{tikzpicture}\\ +% \end{center} +% \end{minipage}\\ +% +% \medskip +% +% Note that it is also possible to provide the input string with blanks: +% +% \noindent +% |\begin{tikzpicture}[thick]|\\ +% | \karnaughmap{1100 0101}|\\ +% |\end{tikzpicture}|\\ +% +% \begin{center} +% \begin{tikzpicture}[thick] +% \karnaughmap{1100 0101} +% \end{tikzpicture}\\ +% \end{center} +% +% This is especially useful when larger maps are typeset as it increases +% readability of the \LaTeXe code.\\ +% +% +% \DescribeMacro{\karnaughmapcolorfield} |\karnaughmapcolorfield|\oarg{key=value}\marg{map size}\marg{field string}\marg{color} +% +% Use this macro inside of a |tikzpicture|-environment to color a Karnaugh map of size |map size|. +% Use hexadecimal values to address a certain field of the map in the |field string|.\\ +% +% \noindent +% |\begin{tikzpicture}[thick]|\\ +% |\karnaughmapcolorfield{2}{01}{teal!50}%|\\ +% |\karnaughmapcolorfield{2}{3}{violet!50}%|\\ +% |\karnaughmap{4}|\\ +% |\end{tikzpicture}|\\ +% +% \begin{center} +% \begin{tikzpicture}[thick] +% \karnaughmapcolorfield{2}{01}{teal!50}% +% \karnaughmapcolorfield{2}{3}{violet!50}% +% \karnaughmap{4} +% \end{tikzpicture}\\ +% \end{center}% +% +% The keys for this macro allow for two different styles: +% \emph{filled} |fill| and \emph{outlined} |outline|. +% The default is filled. +% In addition, TikZ keys are forwarded to the |\draw| or |\fill| command, +% allowing a good adjustment of styles.\\ +% +% \noindent +% |\begin{tikzpicture}[thick]|\\ +% |\karnaughmapcolorfield[outline]{2}{01}{teal!50}%|\\ +% |\karnaughmapcolorfield[outline,ultra thick]{2}{3}{violet!50}%|\\ +% |\karnaughmap{4}|\\ +% |\end{tikzpicture}|\\ +% +% \begin{center} +% \begin{tikzpicture}[thick] +% \karnaughmapcolorfield[outline]{2}{01}{teal!50}% +% \karnaughmapcolorfield[outline,ultra thick]{2}{3}{violet!50}% +% \karnaughmap{4} +% \end{tikzpicture}\\ +% \end{center}% +% +% +% +% +% +% +% +% \subsection{Style Customizations}% \iffalse TODO: SUBSEC:Style Customizations \fi +% +% For style customization a key-value system is provided. +% +% \DescribeMacro{\setkarnaughmap} |\setkarnaughmap|\oarg{key=value} +% This is the interface function for setting the keys. +% To restore the defaults call |\setkarnaughmap|. +% +% The defaults are\\ +% | \setkarnaughmap[omitzeros, defaultmap=16, |\\ +% | function=z, variables=abcd, dontcare=*]|. +% +% \paragraph{Key-Value List} The following table is an overview over all options provided. +% The exact behavior and description of the keys are described below. +% +% \xkvview{family=karnaughmap} +% +% \paragraph{Selective Entry Printing} +% The following keys control the printing of different types of Karnaugh map cell entries. +% +% \DescribeMacro{omitzeros} |omitzeros|\oarg{=\textbf{true}/false} +% Toggle between printing and omitting zero-valued entries in the Karnaugh map. +% \begin{center} +% |\karnaughmap[omitzeros=false]{00*1}|\\ +% \begin{tikzpicture}[thick] +% \karnaughmap[omitzeros=false]{00*1} +% \end{tikzpicture}\\ +% \end{center} +% +% \DescribeMacro{omitones} |omitones|\oarg{=true/\textbf{false}} +% Toggle between printing and omitting one-valued entries in the Karnaugh map. +% \begin{center} +% |\karnaughmap[omitzeros=false,omitones]{00*1}|\\ +% \begin{tikzpicture}[thick] +% \karnaughmap[omitzeros=false,omitones]{00*1} +% \end{tikzpicture}\\ +% \end{center} +% +% \DescribeMacro{omitdontcares} |omitdontcares|\oarg{=true/\textbf{false}} +% Toggle between printing and omitting don't care entries in the Karnaugh map. +% \begin{center} +% |\karnaughmap[omitzeros=false,omitdontcares]{00*1}|\\ +% \begin{tikzpicture}[thick] +% \karnaughmap[omitzeros=false,omitdontcares]{00*1} +% \end{tikzpicture}\\ +% \end{center} +% +% \paragraph{Karnaugh Map Style} +% The following keys control the printing of different types of Karnaugh map labels. +% +% \DescribeMacro{omitbinaries} |omitbinaries|\oarg{true/\textbf{false}} +% Toggle between printing and omitting the binary encoding on top and left of the Karnaugh map. +% \begin{center} +% |\karnaughmap[omitbinaries]{00*1}|\\ +% \begin{tikzpicture}[thick] +% \karnaughmap[omitbinaries]{00*1} +% \end{tikzpicture}\\ +% \end{center} +% +% \DescribeMacro{omitvariables} |omitvariables|\oarg{=true/\textbf{false}} +% Toggle between printing and omitting the variable labeling of rows and columns around the Karnaugh map. +% \begin{center} +% |\karnaughmap[omitvariables]{00*1}|\\ +% \begin{tikzpicture}[thick] +% \karnaughmap[omitvariables]{00*1} +% \end{tikzpicture}\\ +% \end{center} +% +% \DescribeMacro{omitidx} |omitidx|\oarg{=true/\textbf{false}} +% Toggle between printing and omitting index values besides the cell entries in the Karnaugh map. +% \begin{center} +% |\karnaughmap[omitidx]{00*1}|\\ +% \begin{tikzpicture}[thick] +% \karnaughmap[omitidx]{00*1} +% \end{tikzpicture}\\ +% \end{center} +% +% \DescribeMacro{binaryidx} |binaryidx|\oarg{=true/\textbf{false}} +% Toggle between decimal and binary indices. +% \begin{center} +% |\karnaughmap[binaryidx]{00*1}|\\ +% \begin{tikzpicture}[thick] +% \karnaughmap[binaryidx]{00*1} +% \end{tikzpicture}\\ +% \end{center} +% +% \DescribeMacro{omitnegated} |omitnegated|\oarg{=\textbf{true}/false} +% Toggle between typesetting the negated in addition to the non-negated variable labels. +% \begin{center} +% |\karnaughmap[omitnegated=false]{00*1}|\\ +% \begin{tikzpicture}[thick] +% \karnaughmap[omitnegated=false]{00*1} +% \end{tikzpicture}\\ +% \end{center} +% +% \paragraph{Map Customizations} +% The following keys can be used to customize the Karnaugh maps in various ways. +% +% \DescribeMacro{defaultmap} |defaultmap|\oarg{=\textbf{16}} +% Set the default map size (4,8, or 16), i.e. this map size is used if the mandatory argument of +% |\karnaughmap{}| is empty. Thus, empty maps can be produced. +% \begin{center} +% |\karnaughmap[defaultmap=4]{}|, |\karnaughmap[defaultmap=8]{}|\\ +% \begin{tikzpicture}[thick] +% \karnaughmap[defaultmap=4]{} +% \end{tikzpicture} +% \begin{tikzpicture}[thick] +% \karnaughmap[defaultmap=8]{} +% \end{tikzpicture}\\ +% \end{center} +% Note that the same functionality can be achieved by providing a scalar mandatory input +% \begin{center} +% |\karnaughmap{4}|, |\karnaughmap[defaultmap=8]{}|\\ +% \begin{tikzpicture}[thick] +% \karnaughmap{4} +% \end{tikzpicture} +% \begin{tikzpicture}[thick] +% \karnaughmap{8} +% \end{tikzpicture}\\ +% \end{center} +% +% \DescribeMacro{function} |function|\oarg{=\textbf{z}} +% Set the function label used to label the Karnaugh map. +% \begin{center} +% |\karnaughmap[function={f(a,b)}]{00*1}|\\ +% \begin{tikzpicture}[thick] +% \karnaughmap[function={f(a,b)}]{00*1} +% \end{tikzpicture}\\ +% \end{center} +% \begin{center} +% |\karnaughmap[function=]{00*1}|\\ +% \begin{tikzpicture}[thick] +% \karnaughmap[function=]{00*1} +% \end{tikzpicture}\\ +% \end{center} +% +% \DescribeMacro{variables} |variables|\oarg{=\textbf{abcd}} +% Set the variable names used in the Karnaugh map. +% Note that you have to provide a single string of variables +% or variables embraced by curly braces. +% \begin{center} +% |\karnaughmap[variables=kl]{00*1}|\\ +% \begin{tikzpicture}[thick] +% \karnaughmap[variables=kl]{00*1} +% \end{tikzpicture}\\ +% \end{center} +% +% \begin{center} +% |\karnaughmap[variables={{s_2}{s_1}{s_0}{a}}]{01** 10** 0101 **00}|\\ +% \begin{tikzpicture}[thick] +% \karnaughmap[variables={{s_2}{s_1}{s_0}{a}}]{01** 10** 0101 **00} +% \end{tikzpicture}\\ +% \end{center} +% +% +% +% \DescribeMacro{dontcare} |dontcare|\oarg{=\textbf{*}} +% Set the don't care character. +% This is only needed if you provide the |omitdontcares| key and use +% don't care characters other than |*| in the |\karnaughmap{x}| inputstring. +% \begin{center} +% |\karnaughmap[dontcare=X,omitdontcares,omitzeros=false]{00X1}|\\ +% \begin{tikzpicture}[thick] +% \karnaughmap[dontcare=X,omitdontcares,omitzeros=false]{00X1} +% \end{tikzpicture}\\ +% \end{center} +% +% \DescribeMacro{color} |color|\oarg{=\textbf{black}} +% Set the color of the \emph{entire} Karnaugh map, including labels, entries, etc. +% \begin{center} +% |\karnaughmap[color=teal]{00*1}|\\ +% \begin{tikzpicture}[thick] +% \karnaughmap[color=teal]{00*1} +% \end{tikzpicture}\\ +% \end{center} +% +% \DescribeMacro{draw} |draw|\oarg{=\textbf{same as color}} +% Set the color of the Karnaugh map \emph{only}, i.e. the lines that are drawn. +% The labels are not affected. +% \begin{center} +% |\karnaughmap[draw=teal]{00*1}|\\ +% \begin{tikzpicture}[thick] +% \karnaughmap[draw=teal]{00*1} +% \end{tikzpicture}\\ +% \end{center} +% +% \DescribeMacro{labelcolor} |labelcolor|\oarg{=\textbf{same as color}} +% Set the color of the labels of the Karnaugh map \emph{only}. +% The lines are not affected. +% \begin{center} +% |\karnaughmap[labelcolor=teal]{00*1}|\\ +% \begin{tikzpicture}[thick] +% \karnaughmap[labelcolor=teal]{00*1} +% \end{tikzpicture}\\ +% \end{center} +% +% \paragraph{Multiple Karnaugh Maps in one TikZ Picture} +% To typeset more than one Karnaugh map into one TikZ Picture, +% use |xshift| and |yshift|, just as usual n TikZ. +% +% \DescribeMacro{xshift} |xshift|\oarg{=\textbf{0}} +% Shift the Karnaugh map in x-direction within the TikZ picture. +% \begin{center} +% |\karnaughmap{4}\karnaughmap[xshift=5cm]{4}|\\ +% \begin{tikzpicture}[thick] +% \karnaughmap{4} +% \karnaughmap[xshift=5cm]{4} +% \end{tikzpicture}\\ +% \end{center} +% +% \DescribeMacro{yshift} |yshift|\oarg{=\textbf{0}} +% Shift the Karnaugh map in x-direction within the TikZ picture. +% \begin{center} +% |\karnaughmap{4}\karnaughmap[yshift=5cm]{4}|\\ +% \begin{tikzpicture}[thick] +% \karnaughmap{4} +% \karnaughmap[yshift=5cm]{4} +% \end{tikzpicture}\\ +% \end{center} +% +% \section{Examples}% \iffalse TODO: SEC:Examples \fi +% \subsection{Basic Usage Examples:}% \iffalse TODO: SUBSEC:Basic Examples \fi +% \begin{center} +% |\karnaughmap[defaultmap=16,binaryidx,omitnegated=false]{}|\\ +% \begin{tikzpicture}[thick] +% \karnaughmap[defaultmap=16,binaryidx,omitnegated=false,function={f(a,b,c,d)}]{} +% \end{tikzpicture}\\ +% \end{center} +% +% \begin{center} +% |\karnaughmap[defaultmap=4,binaryidx,omitnegated=false,color=teal]{}|\\ +% \begin{tikzpicture}[thick] +% \karnaughmap[defaultmap=4,binaryidx,omitnegated=false,color=teal]{} +% \end{tikzpicture}\\ +% \end{center} +% +% +% \noindent +% |\karnaughmap{4}| +% \begin{center} +% \begin{tikzpicture}[thick] +% \karnaughmap{4} +% \end{tikzpicture}\\ +% \end{center} +% +% +% \subsection{Field coloring}% \iffalse TODO: SUBSEC:Field Coloring \fi +% \noindent +% |\begin{tikzpicture}[thick]|\\ +% |\foreach \x [count=\xi] in {0,1,2,3} {%|\\ +% | \pgfmathparse{-20+30*\xi}%|\\ +% | \karnaughmapcolorfield{2}{\x}{teal!\pgfmathresult}%|\\ +% |}%|\\ +% |\karnaughmap{2}|\\ +% |\end{tikzpicture}|\\ +% +% \begin{center} +% \begin{tikzpicture}[thick] +% \foreach \x [count=\xi] in {0,1,2,3} {% +% \pgfmathparse{-20+30*\xi} +% \karnaughmapcolorfield{2}{\x}{teal!\pgfmathresult}% +% }% +% \karnaughmap{4} +% \end{tikzpicture}\\ +% \end{center} +% +% +% \noindent +% |\begin{tikzpicture}[thick]|\\ +% |\foreach \x [count=\xi] in {0,1,2,3} {%|\\ +% | \pgfmathparse{-20+30*\xi}%|\\ +% | \karnaughmapcolorfield{3}{\x}{teal!\pgfmathresult}%|\\ +% |}%|\\ +% |\foreach \x [count=\xi] in {4,5,6,7} {%|\\ +% | \pgfmathparse{-20+30*\xi}%|\\ +% | \karnaughmapcolorfield{3}{\x}{purple!\pgfmathresult}%|\\ +% |}%|\\ +% |\karnaughmap{8}|\\ +% |\end{tikzpicture}|\\ +% +% \begin{center} +% \begin{tikzpicture}[thick] +% \foreach \x [count=\xi] in {0,1,2,3} {% +% \pgfmathparse{-20+30*\xi}% +% \karnaughmapcolorfield{3}{\x}{teal!\pgfmathresult}% +% }% +% \foreach \x [count=\xi] in {4,5,6,7} {% +% \pgfmathparse{-20+30*\xi}% +% \karnaughmapcolorfield{3}{\x}{purple!\pgfmathresult}% +% }% +% \karnaughmap{8} +% \end{tikzpicture}\\ +% \end{center} +% +% +% \noindent +% |\begin{tikzpicture}[thick]|\\ +% |\foreach \x [count=\xi] in {0,1,2,3} {%|\\ +% | \pgfmathparse{-20+30*\xi}%|\\ +% | \karnaughmapcolorfield{4}{\x}{teal!\pgfmathresult}%|\\ +% |}%|\\ +% |\foreach \x [count=\xi] in {4,5,6,7} {%|\\ +% | \pgfmathparse{-20+30*\xi}%|\\ +% | \karnaughmapcolorfield{4}{\x}{purple!\pgfmathresult}%|\\ +% |}%|\\ +% |\foreach \x [count=\xi] in {8,9,a,b} {%|\\ +% | \pgfmathparse{-20+30*\xi}%|\\ +% | \karnaughmapcolorfield{4}{\x}{olive!\pgfmathresult}%|\\ +% |}%|\\ +% |\foreach \x [count=\xi] in {c,d,e,f} {%|\\ +% | \pgfmathparse{-20+30*\xi}%|\\ +% | \karnaughmapcolorfield{4}{\x}{violet!\pgfmathresult}%|\\ +% |}%|\\ +% |\karnaughmap[defaultmap=16]{}%|\\ +% |\end{tikzpicture}|\\ +% +% \begin{center} +% \begin{tikzpicture}[thick] +% \foreach \x [count=\xi] in {0,1,2,3} {% +% \pgfmathparse{-20+30*\xi}% +% \karnaughmapcolorfield{4}{\x}{teal!\pgfmathresult}% +% }% +% \foreach \x [count=\xi] in {4,5,6,7} {% +% \pgfmathparse{-20+30*\xi}% +% \karnaughmapcolorfield{4}{\x}{purple!\pgfmathresult}% +% }% +% \foreach \x [count=\xi] in {8,9,a,b} {% +% \pgfmathparse{-20+30*\xi}% +% \karnaughmapcolorfield{4}{\x}{olive!\pgfmathresult}% +% }% +% \foreach \x [count=\xi] in {c,d,e,f} {% +% \pgfmathparse{-20+30*\xi}% +% \karnaughmapcolorfield{4}{\x}{violet!\pgfmathresult}% +% }% +% \karnaughmap[defaultmap=16]{} +% \end{tikzpicture}\\ +% \end{center} +% +% +% \section{Field Allocation Reference}\iffalse TODO: SEC: Field Alloc Reference \fi +% This package provides maps with full control up to \emph{4} variables, +% which is equivalent to a map size of \emph{16} fields.\\ +% For bigger maps, the package provides just basic typesetting, +% i.e. just the column and row encoding and the, possibly filled matrix.\\ +% However, the biggest map supported yet has 256 fields.\\ +% +% The reference can be read as follows: +% the first row contains the value of the rows, +% the columns are then likewise enumerated. +% By this procedure, you can check if everything went right (debugging) +% and got an easy reference. +% +% \subsection{2 Variables -- 4 Fields} +% \noindent +% |\begin{tikzpicture}[thick]|\\ +% | \karnaughmap[variables=ab]{o1 11 }|\\ +% |\end{tikzpicture}| +% +% \begin{tikzpicture}[thick] +% \karnaughmap[variables=ab]{o1 11 } +% \end{tikzpicture} +% +% +% \subsection{3 Variables -- 8 Fields} +% \noindent +% |\begin{tikzpicture}[thick]|\\ +% | \karnaughmap[variables=abc]{o1 11 21 31 }|\\ +% |\end{tikzpicture}| +% +% \begin{tikzpicture}[thick] +% \karnaughmap[variables=abc]{o1 11 21 31 } +% \end{tikzpicture} +% +% +% \subsection{4 Variables -- 16 Fields} +% \noindent +% |\begin{tikzpicture}[thick]|\\ +% | \karnaughmap[variables=abcd]{o123 1123 2123 3123 }|\\ +% |\end{tikzpicture}| +% +% \begin{tikzpicture}[thick] +% \karnaughmap[variables=abcd]{o123 1123 2123 3123 } +% \end{tikzpicture} +% +% +% \subsection{5 Variables -- 32 Fields} +% \noindent +% |\begin{tikzpicture}[thick]|\\ +% | \karnaughmap[variables=abcde]{0000 0001 0010 0011 0100 0101 0110 1111}|\\ +% |\end{tikzpicture}| +% +% \begin{tikzpicture}[thick] +% \karnaughmap[variables=abcde]{o123 1123 2123 3123 4123 5123 6123 7123} +% \end{tikzpicture} +% +% +% \subsection{6 Variables -- 64 Fields} +% \noindent +% |\begin{tikzpicture}[thick]|\\ +% | \karnaughmap[variables=abcdef]{o1234567 11234567 21234567 31234567 |\\ +% | 41234567 51234567 61234567 71234567 }|\\ +% |\end{tikzpicture}| +% +% \begin{tikzpicture}[thick] +% \karnaughmap[variables=abcdef]{o1234567 11234567 21234567 31234567 +% 41234567 51234567 61234567 71234567 } +% \end{tikzpicture} +% +% +% \subsection{7 Variables -- 128 Fields} +% \noindent +% |\begin{tikzpicture}[thick]|\\ +% | \karnaughmap[variables=abcdefg]{o1234567 11234567 21234567 31234567 |\\ +% | 41234567 51234567 61234567 71234567 |\\ +% | 81234567 91234567 a1234567 b1234567 |\\ +% | c1234567 d1234567 e1234567 f1234567 }|\\ +% |\end{tikzpicture}| +% +% \hspace*{-4cm} +% \begin{tikzpicture}[thick] +% \karnaughmap[variables=abcdefg]{o1234567 11234567 21234567 31234567 +% 41234567 51234567 61234567 71234567 +% 81234567 91234567 a1234567 b1234567 +% c1234567 d1234567 e1234567 f1234567 } +% \end{tikzpicture} +% +% +% \subsection{8 Variables -- 256 Fields} +% \noindent +% |\begin{tikzpicture}[thick]|\\ +% | \karnaughmap[variables=abcdefg]{o123456789abcdef 1123456789abcdef |\\ +% | 2123456789abcdef 3123456789abcdef |\\ +% | 4123456789abcdef 5123456789abcdef |\\ +% | 6123456789abcdef 7123456789abcdef |\\ +% | 8123456789abcdef 9123456789abcdef |\\ +% | a123456789abcdef b123456789abcdef |\\ +% | c123456789abcdef d123456789abcdef |\\ +% | e123456789abcdef f123456789abcdef }|\\ +% |\end{tikzpicture}| +% +% \hspace*{-4cm} +% \begin{tikzpicture}[thick] +% \karnaughmap[variables=abcdefg]{o123456789abcdef 1123456789abcdef 2123456789abcdef 3123456789abcdef +% 4123456789abcdef 5123456789abcdef 6123456789abcdef 7123456789abcdef +% 8123456789abcdef 9123456789abcdef a123456789abcdef b123456789abcdef +% c123456789abcdef d123456789abcdef e123456789abcdef f123456789abcdef } +% \end{tikzpicture} +% +% +% +% +% +% +% \section{Macros for Internal Usage}% \iffalse TODO: SEC:Macros for Internal Usage \fi +% These macros are not intended to be used by the user, +% rather these are auxiliary functions invoked by the main macro |\karnaughmap{x}|. +% +% Nevertheless, for documentation these macros are described here briefly. +% +% +% \StopEventually{} +% +% \section{Implementation}% \iffalse TODO: SEC:Implementation \fi +% +% \subsection{Load Dependencies}% \iffalse TODO: SUBSEC:Load Dependencies \fi +% \begin{macrocode} +\RequirePackage{tikz} +\RequirePackage{xkeyval} +\RequirePackage{ifthen} +\RequirePackage{xstring} +% \end{macrocode} +% +% \subsection{Allocate Counters}% \iffalse TODO: SUBSEC:Allocate Counters \fi +% \begin{macrocode} +\newcounter{karnaughmapIdxCounter} +\newcounter{karnaughmapStrCounter} +\setcounter{karnaughmapIdxCounter}{0} +\setcounter{karnaughmapStrCounter}{0} +% \end{macrocode} +% +% \subsection{Key-Val Interface}% \iffalse TODO: SUBSEC:Key-Val Interface \fi +% \paragraph{Switches} +% Simple switches are used to control basic layout options of the Karnaugh map.\\ +% +% These boolean switches control if specific entries +% -- i.e. zeros, ones, and don't cares -- are printed or not (omitted). +% \begin{macrocode} +\define@boolkeys{karnaughmap}{omitzeros, omitones, omitdontcares}[true] +% \end{macrocode} +% +% These boolean switches control the layout of the Karnaugh map. +% The |omitbinaries| switch is used to control if binary encoding is typeset left and on top of the Karnaugh map. +% The |omitvariables| switch is used to control if the Karnaugh map is labeled with the variables. +% The |omitidx| switch controls the typesetting of decimal indices within the cells of the Karnaugh map. +% The |binaryidx| switch controls whether the indices are decimal or binary. +% The |omitnegated| switch controls whether the negated variable labels are typeset as well. +% \begin{macrocode} +\define@boolkeys{karnaughmap}{omitbinaries, omitvariables, omitidx, binaryidx, omitnegated}[true] +% \end{macrocode} +% +% These boolean switches control the behavior of the highlighting function. +% +% \begin{macrocode} +\define@boolkey{karnaughmap}{outline}[true]{\setkeys{karnaughmap}{fill=false}} +\define@boolkeys{karnaughmap}{fill}[true] +\define@cmdkey{karnaughmap}{opacity}[0.5]{} +% \end{macrocode} +% +% \paragraph{Customizations} +% In contrast to the boolean switches these keys are used to customize the Karnaugh map.\\ +% +% This key controls the default size of the Karnaugh map. +% It is set to 16, i.e. a 4 variable map is typeset. +% \begin{macrocode} +\define@cmdkey{karnaughmap}{defaultmap}[16]{} +% \end{macrocode} +% +% This key controls the Karnaugh map function label. +% The default is 'z'. +% \begin{macrocode} +\define@cmdkey{karnaughmap}{function}[z]{} +% \end{macrocode} +% +% This key controls the variables. +% Provide the variables as a string. +% Maybe more control over variables will be added in a later version. +% The default is 'abcd' +% \begin{macrocode} +\define@cmdkey{karnaughmap}{variables}[abcd]{} +% \end{macrocode} +% +% Define the standard "`Don't Care"' character. +% The default is '*'. +% \begin{macrocode} +\define@cmdkey{karnaughmap}{dontcare}[*]{} +% \end{macrocode} +% +% Define the color. +% For desired functionality both the draw and color have to be set. +% \begin{macrocode} +\define@key{karnaughmap}{color}[black]{% + \colorlet{karnaughmapColor}{#1}% + \colorlet{karnaughmapMapColor}{#1}} +% \end{macrocode} +% +% Define the draw color, i.e. the color of the map itself. +% Default is the same as color. +% \begin{macrocode} +\define@key{karnaughmap}{draw}[karnaughmapColor]{\colorlet{karnaughmapMapColor}{#1}} +% \end{macrocode} +% +% Define the label color. +% By setting the color only, the draw remains unchanged. +% \begin{macrocode} +\define@key{karnaughmap}{labelcolor}[karnaughmapColor]{% + \colorlet{karnaughmapColor}{#1}} +% \end{macrocode} +% +% Define the shifts. +% \begin{macrocode} +\define@cmdkeys{karnaughmap}{xshift,yshift}[0] +% \end{macrocode} +% +% \paragraph{Set Key Defaults} +% The default is a map with full information, +% i.e. binary and variable labels as well as decimal indices. +% The zeros are omitted by default.\\ +% +% \begin{macro}{\setkarnaughmap} +% Simple interface function. +% \begin{macrocode} +\newcommand{\setkarnaughmap}[1][]{% +\ifthenelse{\equal{#1}{}}{% +% \end{macrocode} +% +% Change the default behavior by uncommenting the specific key. +% \begin{macrocode} +\setkeys{karnaughmap}{% +% \end{macrocode} +% omitones, +% omitdontcares, +% omitbinaries, +% omitvariables, +% omitidx, +% binaryidx +% \begin{macrocode} +omitzeros, omitnegated} +% \end{macrocode} +% +% The key-definition defaults are assigned here. +% See the definition of the keys above for the defaults. +% \begin{macrocode} +\setkeys{karnaughmap}{defaultmap, function, variables, dontcare, color, draw, labelcolor, xshift, yshift} +% \end{macrocode} +% +% If the optional input is provided set the keys accordingly. +% \begin{macrocode} +}{ +\setkeys{karnaughmap}{#1} +}} +% \end{macrocode} +% \end{macro} +% +% Assign the defaults during style file call. +% \begin{macrocode} +\setkarnaughmap +% \end{macrocode} +% +% +% +% \subsection{Auxiliary Functions}% \iffalse TODO: SUBSEC:Auxiliary Functions \fi +% These function are called by the main function to facilitate code execution. +% +% \begin{macro}{\karnaughmapPrintIndex} +% |\karnaughmapPrintIndex|\oarg{numBits} +% +% This macro typesets the indices inside the cells. +% If the switch |binaryidx| is true binary instead of decimal indices are typeset. +% The number provided as optional argument is used to determine the number of bits used. +% +% Every time the macro is called, it prints the counter value +% of counter |karnaughmapIdxCounter| and increments the counter thereafter. +% +% The size of the indices is very small (scriptsize). +% \begin{macrocode} +\newcommand{\karnaughmapPrintIndex}[1][4]{% +\scriptsize% +\ifKV@karnaughmap@binaryidx +% \end{macrocode} +% +% Typeset binary indices. +% \begin{macrocode} + \ifthenelse{\equal{#1}{2}}{% + \ifcase\value{karnaughmapIdxCounter}% + 00\or 01\or 10\or 11 + \fi + }{}% + \ifthenelse{\equal{#1}{3}}{% + \ifcase\value{karnaughmapIdxCounter}% + 000\or 001\or 010\or 011\or 100\or 101\or 110\or 111 + \fi + }{}% + \ifthenelse{\equal{#1}{4}}{% + \ifcase\value{karnaughmapIdxCounter}% + 0000\or 0001\or 0010\or 0011\or 0100\or 0101\or 0110\or 0111\or + 1000\or 1001\or 1010\or 1011\or 1100\or 1101\or 1110\or 1111 + \fi + }{}% +\else +% \end{macrocode} +% +% Typeset decimal indices. +% \begin{macrocode} +$\thekarnaughmapIdxCounter$% +\fi +\stepcounter{karnaughmapIdxCounter}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\karnaughmapPrintValue} +% |\karnaughmapPrintValue|\marg{inputstring} +% +% This macro typesets the entries of the Karnaugh map. +% Every time the macro is called, it increments the counter |karnaughmapStrCounter| +% and prints the character at position of the counter value of its mandatory input. +% \begin{macrocode} +\newcommand{\karnaughmapPrintValue}[2][]{% + \stepcounter{karnaughmapStrCounter}% + \StrChar{#2}{\thekarnaughmapStrCounter}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\karnaughmapPrintCellContents} +% |\karnaughmapPrintCellContents|\oarg{node-position}\marg{x-offset}\marg{y-offset}\\ +% \marg{size}\marg{rowsize}\marg{function} +% +% This macro is used to provide the positions of the cells of the map, +% as they are not straight forward (e.g. order is 0-1-3-2 for first column of 4x4 maps). +% It takes 5 mandatory and one optional arguments as specified above. +% +% By default, it evaluates |function| as contents of a node at the top left +% of each cell of a Karnaugh map of size |size| with |rowsize| rows. +% By providing the bias (x- and y-offset), the provided point is shifted accordingly. +% The alignment of the node is controlled by the optional argument. +% \begin{macrocode} +\newcommand{\karnaughmapPrintCellContents}[6][]{% +% \end{macrocode} +% If map is 2x2, the order is pretty simple:\\ +% 0 2 \\ +% 1 3 +% \begin{macrocode} +\ifthenelse{\equal{#4}{4}}{% + \def\karnaughmapPCCColumnSpecifier{++( 0,-1) node[#1] {#6}}% + \path (0, #5) + ++(#2,#3) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+1,+1) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ; +}{} +% \end{macrocode} +% If map is 2x4, the order is more complex:\\ +% 0 2 6 4 \\ +% 1 3 7 5 +% \begin{macrocode} +\ifthenelse{\equal{#4}{8}}{% + \def\karnaughmapPCCColumnSpecifier{++( 0,-1) node[#1] {#6}}% + \path (0, #5) + ++(#2,#3) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+1,+1) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+2,+1) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-1,+1) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ; +}{} +% \end{macrocode} +% If map is 4x4, the same ordering as before is present in both x- and y-direction:\\ +% 0 4 12 8 \\ +% 1 5 13 9 \\ +% 3 7 15 11 \\ +% 2 6 14 10 +% \begin{macrocode} +\ifthenelse{\equal{#4}{16}}{% + \def\karnaughmapPCCColumnSpecifier{% + ++( 0,-1) node[#1] {#6} + ++( 0,-2) node[#1] {#6} + ++( 0,+1) node[#1] {#6} + }% + \path (0, #5) + ++(#2,#3) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+1,+2) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+2,+2) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-1,+2) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ; +}{} +% \end{macrocode} +% +% If map is 4x8, the ordering as before has to be extended in x-direction, +% but from the middle in reverse order:\\ +% 0 4 12 8 24 28 20 16 \\ +% 1 5 13 9 25 29 21 17 \\ +% 3 7 15 11 27 31 23 29 \\ +% 2 6 14 10 26 30 22 18 +% \begin{macrocode} +\ifthenelse{\equal{#4}{32}}{% + \def\karnaughmapPCCColumnSpecifier{% + ++( 0,-1) node[#1] {#6} + ++( 0,-2) node[#1] {#6} + ++( 0,+1) node[#1] {#6} + }% + \path (0, #5) + ++(#2,#3) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+1,+2) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+2,+2) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-1,+2) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+5,+2) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-1,+2) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-2,+2) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+1,+2) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ; +}{} +% \end{macrocode} +% +% If map is 8x8, the ordering as before has to be extended in y-direction, too.\\ +% 0 8 24 16 48 56 40 32 \\ +% 1 9 25 17 49 57 41 33 \\ +% 3 11 27 19 51 59 43 35 \\ +% 2 10 26 18 50 58 42 34 \\ +% 6 14 30 22 54 62 46 38 \\ +% 7 15 31 23 55 63 47 39 \\ +% 5 13 29 21 53 61 45 37 \\ +% 4 12 28 20 52 60 44 36 +% \begin{macrocode} +\ifthenelse{\equal{#4}{64}}{% + \def\karnaughmapPCCColumnSpecifier{% + ++( 0,-1) node[#1] {#6} + ++( 0,-2) node[#1] {#6} + ++( 0,+1) node[#1] {#6} + ++( 0,-5) node[#1] {#6} + ++( 0,+1) node[#1] {#6} + ++( 0,+2) node[#1] {#6} + ++( 0,-1) node[#1] {#6} + }% + \path (0, #5) + ++(#2,#3) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+1,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+2,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-1,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+5,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-1,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-2,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+1,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ; +}{} +% \end{macrocode} +% +% If map is 8x16, the ordering is:\\ +% 0 8 24 16 48 56 40 32 \\ +% 1 9 25 17 49 57 41 33 \\ +% 3 11 27 19 51 59 43 35 \\ +% 2 10 26 18 50 58 42 34 \\ +% 6 14 30 22 54 62 46 38 \\ +% 7 15 31 23 55 63 47 39 \\ +% 5 13 29 21 53 61 45 37 \\ +% 4 12 28 20 52 60 44 36 +% \begin{macrocode} +\ifthenelse{\equal{#4}{128}}{% + \def\karnaughmapPCCColumnSpecifier{% + ++( 0,-1) node[#1] {#6} + ++( 0,-2) node[#1] {#6} + ++( 0,+1) node[#1] {#6} + ++( 0,-5) node[#1] {#6} + ++( 0,+1) node[#1] {#6} + ++( 0,+2) node[#1] {#6} + ++( 0,-1) node[#1] {#6} + }% + \path (0, #5) + ++(#2,#3) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+1,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+2,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-1,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+5,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-1,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-2,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+1,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+10,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-1,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-2,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+1,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-5,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+1,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+2,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-1,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ; +}{} +% \end{macrocode} +% +% If map is 16x16, the ordering is:\\ +% 0 8 24 16 48 56 40 32 \\ +% 1 9 25 17 49 57 41 33 \\ +% 3 11 27 19 51 59 43 35 \\ +% 2 10 26 18 50 58 42 34 \\ +% 6 14 30 22 54 62 46 38 \\ +% 7 15 31 23 55 63 47 39 \\ +% 5 13 29 21 53 61 45 37 \\ +% 4 12 28 20 52 60 44 36 +% \begin{macrocode} +\ifthenelse{\equal{#4}{256}}{% + \def\karnaughmapPCCColumnSpecifier{% + ++( 0,-1) node[#1] {#6} + ++( 0,-2) node[#1] {#6} + ++( 0,+1) node[#1] {#6} + ++( 0,-5) node[#1] {#6} + ++( 0,+1) node[#1] {#6} + ++( 0,+2) node[#1] {#6} + ++( 0,-1) node[#1] {#6} + + ++( 0,-10) node[#1] {#6} + ++( 0,+1) node[#1] {#6} + ++( 0,+2) node[#1] {#6} + ++( 0,-1) node[#1] {#6} + ++( 0,+5) node[#1] {#6} + ++( 0,-1) node[#1] {#6} + ++( 0,-2) node[#1] {#6} + ++( 0,+1) node[#1] {#6} + }% + \path (0, #5) + ++(#2,#3) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+1,+10) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+2,+10) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-1,+10) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+5,+10) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-1,+10) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-2,+10) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+1,+10) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+10,+10) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-1,+10) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-2,+10) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+1,+10) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-5,+10) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+1,+10) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+2,+10) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-1,+10) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ; +}{} +} +% \end{macrocode} +% \end{macro} +% + +% \begin{macro}{\karnaughmapHighlightField} +% Macro that defines the highlighting. +% |\karnaughmapHighlightField|\oarg{key=value}\marg{coordinates}\marg{color name} +% +% +% \end{macro} +% \begin{macrocode} +\newcommand{\karnaughmapHighlightField}[3][]{% +\ifKV@karnaughmap@fill + \path[fill=#3,opacity=\cmdKV@karnaughmap@opacity,#1] (#2) rectangle ++(1,1);% +\fi +\ifKV@karnaughmap@outline + \draw[#3,#1] (#2) ++ (0.1,0.1) rectangle ++(0.8,0.8);% +\fi +} +% \end{macrocode} +% \begin{macro}{\karnaughmapShadeMapfieldTWO} +% Macro to shade square two input karnaugh map fields.\\ +% |\karnaughmapShadeMapfieldTWO|\oarg{key=value}\marg{decimal field number}\marg{color name} +% +% Optional macro is used as key-val interface for option processing, +% mandatory ones specify the color used for highlighting and +% the fields that are to be highlighted as decimal integers from $1$ to $2^{\textrm{map size}}-1$. +% \begin{macrocode} +\newcommand{\karnaughmapShadeMapfieldTWO}[3][]{% +\begin{scope}[scale=1] + \ifthenelse{\equal{#2}{0}}{\karnaughmapHighlightField[#1]{0,1}{#3}}{}% + \ifthenelse{\equal{#2}{1}}{\karnaughmapHighlightField[#1]{0,0}{#3}}{}% + \ifthenelse{\equal{#2}{2}}{\karnaughmapHighlightField[#1]{1,1}{#3}}{}% + \ifthenelse{\equal{#2}{3}}{\karnaughmapHighlightField[#1]{1,0}{#3}}{}% +\end{scope} +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\karnaughmapShadeMapfieldTHREE} +% Macro to shade three input karnaugh map fields.\\ +% |\karnaughmapShadeMapfieldTHREE|\oarg{key=value}\marg{decimal field number}\marg{color name} +% +% Optional macro is used as key-val interface for option processing, +% mandatory ones specify the color used for highlighting and +% the fields that are to be highlighted as decimal integers from $1$ to $2^{\textrm{map size}}-1$. +% \begin{macrocode} +\newcommand{\karnaughmapShadeMapfieldTHREE}[3][]{% +\begin{scope}[scale=1] + \ifthenelse{\equal{#2}{0}}{\karnaughmapHighlightField[#1]{0,1}{#3}}{}% + \ifthenelse{\equal{#2}{1}}{\karnaughmapHighlightField[#1]{0,0}{#3}}{}% + \ifthenelse{\equal{#2}{2}}{\karnaughmapHighlightField[#1]{1,1}{#3}}{}% + \ifthenelse{\equal{#2}{3}}{\karnaughmapHighlightField[#1]{1,0}{#3}}{}% + \ifthenelse{\equal{#2}{4}}{\karnaughmapHighlightField[#1]{3,1}{#3}}{}% + \ifthenelse{\equal{#2}{5}}{\karnaughmapHighlightField[#1]{3,0}{#3}}{}% + \ifthenelse{\equal{#2}{6}}{\karnaughmapHighlightField[#1]{2,1}{#3}}{}% + \ifthenelse{\equal{#2}{7}}{\karnaughmapHighlightField[#1]{2,0}{#3}}{}% +\end{scope} +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\karnaughmapShadeMapfieldFOUR} +% Macro to shade square four input karnaugh map fields.\\ +% |\karnaughmapShadeMapfieldFOUR|\oarg{key=value}\marg{decimal field number}\marg{color name} +% +% Optional macro is used as key-val interface for option processing, +% mandatory ones specify the color used for highlighting and +% the fields that are to be highlighted as decimal integers from $1$ to $2^{\textrm{map size}}-1$. +% \begin{macrocode} +\newcommand{\karnaughmapShadeMapfieldFOUR}[3][]{% +\begin{scope}[scale=1]% +% \end{macrocode} +% 1st column +% \begin{macrocode} +\ifthenelse{\equal{#2}{0}}{\karnaughmapHighlightField[#1]{0,3}{#3}}{}% +\ifthenelse{\equal{#2}{1}}{\karnaughmapHighlightField[#1]{0,2}{#3}}{}% +\ifthenelse{\equal{#2}{2}}{\karnaughmapHighlightField[#1]{0,0}{#3}}{}% +\ifthenelse{\equal{#2}{3}}{\karnaughmapHighlightField[#1]{0,1}{#3}}{}% +% \end{macrocode} +% 2nd column +% \begin{macrocode} +\ifthenelse{\equal{#2}{4}}{\karnaughmapHighlightField[#1]{1,3}{#3}}{}% +\ifthenelse{\equal{#2}{5}}{\karnaughmapHighlightField[#1]{1,2}{#3}}{}% +\ifthenelse{\equal{#2}{6}}{\karnaughmapHighlightField[#1]{1,0}{#3}}{}% +\ifthenelse{\equal{#2}{7}}{\karnaughmapHighlightField[#1]{1,1}{#3}}{}% +% \end{macrocode} +% 4th column +% \begin{macrocode} +\ifthenelse{\equal{#2}{8}}{\karnaughmapHighlightField[#1]{3,3}{#3}}{}% +\ifthenelse{\equal{#2}{9}}{\karnaughmapHighlightField[#1]{3,2}{#3}}{}% +\ifthenelse{\equal{#2}{a}\OR\equal{#2}{A}}{\karnaughmapHighlightField[#1]{3,0}{#3}}{}% +\ifthenelse{\equal{#2}{b}\OR\equal{#2}{B}}{\karnaughmapHighlightField[#1]{3,1}{#3}}{}% +% \end{macrocode} +% 3rd column +% \begin{macrocode} +\ifthenelse{\equal{#2}{c}\OR\equal{#2}{C}}{\karnaughmapHighlightField[#1]{2,3}{#3}}{}% +\ifthenelse{\equal{#2}{d}\OR\equal{#2}{D}}{\karnaughmapHighlightField[#1]{2,2}{#3}}{}% +\ifthenelse{\equal{#2}{e}\OR\equal{#2}{E}}{\karnaughmapHighlightField[#1]{2,0}{#3}}{}% +\ifthenelse{\equal{#2}{f}\OR\equal{#2}{F}}{\karnaughmapHighlightField[#1]{2,1}{#3}}{}% +\end{scope} +} +% \end{macrocode} +% \end{macro} +% +% +% +% \subsection{Main Functions}% \iffalse TODO: SUBSEC:Main Functions \fi +% +% Here come the main functions to typeset the map +% and to mark certain cells (not implemented yet). +% +% \begin{macro}{\karnaughmap} +% The main macro takes one mandatory and one optional argument:\\ +% \oarg{key=value}\marg{inputstring}. +% +% The optional is used as key-val inteface, +% the mandatory is empty or holds the entry-pattern (inputstring) +% according to the corresponding ordered truth table +% of the desired logic function. +% \begin{macrocode} +\newcommand{\karnaughmap}[2][]{% +% \end{macrocode} +% +% If the optional input is not empty, assign the key-val. +% \begin{macrocode} +\ifthenelse{\equal{#1}{}}{}{\setkeys{karnaughmap}{#1}} +% \end{macrocode} +% +% For easy access store the mandatory argument as variable |\karnaughmapCellEntries|. +% \begin{macrocode} +\def\karnaughmapCellEntries{#2}% +% \end{macrocode} +% +% Check length of mandatory argument and store the result in |\karnaughmapSize|. +% +% If the mandatory argument is empty, +% use the default map size provided by the key-val interface (|defaultmap| key). +% \begin{macrocode} +\ifthenelse{\equal{#2}{}}{% + \def\karnaughmapSize{\cmdKV@karnaughmap@defaultmap} +}{% +% \end{macrocode} +% +% Else, determine the length of the input string to determine the map size. +% +% Before calculating the string length, remove any blanks in the input string. +% Usage of blanks in the input string can increase readability, +% e.g. when groups of four are provided. +% \begin{macrocode} +\IfSubStr{\karnaughmapCellEntries}{ }{% +\StrDel[0]{\karnaughmapCellEntries}{ }[\karnaughmapCellEntries] +}{} +% \end{macrocode} +% +% Now, calculate the string length. +% This is the old version. +% |\StrLen{#2}[\karnaughmapSize]%| +% \begin{macrocode} + \StrLen{\karnaughmapCellEntries}[\karnaughmapSize]% +% \end{macrocode} +% +% If the input is a scalar number, i.e. it is < 1000 (decimal), +% it is treated as number and is used to determine the map size. +% In this case adapt the variable |\karnaughmapCellEntries| accordingly. +% |\ifthenelse{\equal{\karnaughmapSize}{1}}{%| +% \begin{macrocode} + \ifthenelse{\karnaughmapSize < 4}{% + \def\karnaughmapSize{#2}\def\karnaughmapCellEntries{}}{}% +} +% \end{macrocode} +% +% +% Parse the input string and omit printing of '0', '1', or '*' entries +% if the switches say so. +% \begin{macrocode} +\ifKV@karnaughmap@omitzeros + \StrSubstitute[0]{\karnaughmapCellEntries}{0}{ }[\karnaughmapCellEntries] +\fi +\ifKV@karnaughmap@omitones + \StrSubstitute[0]{\karnaughmapCellEntries}{1}{ }[\karnaughmapCellEntries] +\fi +\ifKV@karnaughmap@omitdontcares + \StrSubstitute[0]{\karnaughmapCellEntries}{\cmdKV@karnaughmap@dontcare}{ }[\karnaughmapCellEntries] +\fi +% \end{macrocode} +% +% Initialize internal counters. +% \begin{macrocode} +\setcounter{karnaughmapIdxCounter}{0} +\setcounter{karnaughmapStrCounter}{0} +% \end{macrocode} +% +% Extract the map variables and alloc row and col sizes. +% In addition, store the number of variables in variable |\karnaughmapNumVar|. +% \begin{macrocode} +\ifthenelse{\karnaughmapSize = 4}{% + \StrChar{\cmdKV@karnaughmap@variables}{1}[\karnaughmapVarLabelA] + \def\karnaughmapVarLabelB{} + \StrChar{\cmdKV@karnaughmap@variables}{2}[\karnaughmapVarLabelC] + \def\karnaughmapVarLabelD{} + \def\karnaughmapNumRow{2} + \def\karnaughmapNumCol{2} + \def\karnaughmapNumVar{2} +}{} +\ifthenelse{\karnaughmapSize = 8}{% + \StrChar{\cmdKV@karnaughmap@variables}{1}[\karnaughmapVarLabelA] + \StrChar{\cmdKV@karnaughmap@variables}{2}[\karnaughmapVarLabelB] + \StrChar{\cmdKV@karnaughmap@variables}{3}[\karnaughmapVarLabelC] + \def\karnaughmapVarLabelD{} + \def\karnaughmapNumRow{2} + \def\karnaughmapNumCol{4} + \def\karnaughmapNumVar{3} +}{} +\ifthenelse{\karnaughmapSize = 16}{% + \StrChar{\cmdKV@karnaughmap@variables}{1}[\karnaughmapVarLabelA] + \StrChar{\cmdKV@karnaughmap@variables}{2}[\karnaughmapVarLabelB] + \StrChar{\cmdKV@karnaughmap@variables}{3}[\karnaughmapVarLabelC] + \StrChar{\cmdKV@karnaughmap@variables}{4}[\karnaughmapVarLabelD] + \def\karnaughmapNumRow{4} + \def\karnaughmapNumCol{4} + \def\karnaughmapNumVar{4} +}{} +% \end{macrocode} +% +% The bigger karnaugh maps, i.e. 32, 64, 128 and 512, lack finer control possibilities. +% Rather, the variables are set such that they can be used as map descriptors, +% but not for some fancy stuff like indicating the variable blocks. +% This means, that we force to omit printing of the the indices (omitidx=true) +% and we force to omit printing of the variables.\\ +% For the variable macros to work, we set the B and D macro to empty +% and put the remaining variables in the A for column and C for row variables. +% \begin{macrocode} +\ifthenelse{\karnaughmapSize = 32}{% + \setkeys{karnaughmap}{omitidx=true, omitvariables=true} + \StrMid{\cmdKV@karnaughmap@variables}{1}{3}[\karnaughmapVarLabelA] + \def\karnaughmapVarLabelB{} + \StrMid{\cmdKV@karnaughmap@variables}{4}{5}[\karnaughmapVarLabelC] + \def\karnaughmapVarLabelD{} + \def\karnaughmapNumRow{4} + \def\karnaughmapNumCol{8} + \def\karnaughmapNumVar{5} +}{} +\ifthenelse{\karnaughmapSize = 64}{% + \setkeys{karnaughmap}{omitidx=true, omitvariables=true} + \StrMid{\cmdKV@karnaughmap@variables}{1}{3}[\karnaughmapVarLabelA] + \def\karnaughmapVarLabelB{} + \StrMid{\cmdKV@karnaughmap@variables}{4}{6}[\karnaughmapVarLabelC] + \def\karnaughmapVarLabelD{} + \def\karnaughmapNumRow{8} + \def\karnaughmapNumCol{8} + \def\karnaughmapNumVar{6} +}{} +\ifthenelse{\karnaughmapSize = 128}{% + \setkeys{karnaughmap}{omitidx=true, omitvariables=true} + \StrMid{\cmdKV@karnaughmap@variables}{1}{4}[\karnaughmapVarLabelA] + \def\karnaughmapVarLabelB{} + \StrMid{\cmdKV@karnaughmap@variables}{5}{7}[\karnaughmapVarLabelC] + \def\karnaughmapVarLabelD{} + \def\karnaughmapNumRow{8} + \def\karnaughmapNumCol{16} + \def\karnaughmapNumVar{7} +}{} +\ifthenelse{\karnaughmapSize = 256}{% + \setkeys{karnaughmap}{omitidx=true, omitvariables=true} + \StrMid{\cmdKV@karnaughmap@variables}{1}{4}[\karnaughmapVarLabelA] + \def\karnaughmapVarLabelB{} + \StrMid{\cmdKV@karnaughmap@variables}{5}{8}[\karnaughmapVarLabelC] + \def\karnaughmapVarLabelD{} + \def\karnaughmapNumRow{16} + \def\karnaughmapNumCol{16} + \def\karnaughmapNumVar{8} +}{} +% \end{macrocode} +% +% \paragraph{Basic table} Typeset the basic table. +% +% Embed the draw commands in a scope environment for style control. +% \begin{macrocode} + \begin{scope}[xshift=\cmdKV@karnaughmap@xshift, + yshift=\cmdKV@karnaughmap@yshift, + color=karnaughmapColor, + draw=karnaughmapMapColor ] +% \end{macrocode} +% +% Draw table boundaries. +% \begin{macrocode} + \draw (0,0) rectangle (\karnaughmapNumCol, \karnaughmapNumRow); +% \end{macrocode} +% +% Draw column seperators. +% \begin{macrocode} + \foreach \x in {1,2,...,\karnaughmapNumCol} {% + \ifthenelse{\equal{\x}{1}}{}{% + \draw (\x-1,0) -- ++(0,\karnaughmapNumRow);% + }% + }% +% \end{macrocode} +% +% Draw row seperators. +% \begin{macrocode} + \foreach \x in {1,2,...,\karnaughmapNumRow} {% + \ifthenelse{\equal{\x}{1}}{}{% + \draw (0,\x-1) -- ++(\karnaughmapNumCol,0);% + }% + }% +% \end{macrocode} +% +% Draw map labels; +% Diagonal line and anchor first. +% \begin{macrocode} +\draw (0,\karnaughmapNumRow) -- ++(-0.4,0.4) coordinate(identifier) + -- ++(-0.4,0.4) +% \end{macrocode} +% +% Function label at the top of the map, +% if the function label is non-empty the label is followed by a colon. +% \begin{macrocode} + node[yshift=7.5,xshift=-3.5,right] {% + \ifthenelse{\equal{\cmdKV@karnaughmap@function}{}}{}{$\cmdKV@karnaughmap@function\colon$}}; +% \end{macrocode} +% +% Variable label right and below the diagonal. +% \begin{macrocode} + \path (identifier) node[above right, xshift=-2.5] {$\karnaughmapVarLabelA\karnaughmapVarLabelB$}; + \path (identifier) node[below left, yshift=0.5] {$\karnaughmapVarLabelC\karnaughmapVarLabelD$}; +% \end{macrocode} +% +% Typeset binaries if |omitbinaries| switch is false; +% \begin{macrocode} +\ifKV@karnaughmap@omitbinaries +\else +% \end{macrocode} +% +% 2 columns: anchors are above the top row |\karnaughmapNumRow| +% and in the middle of the cells at 0.5 and 1.5. +% \begin{macrocode} + \ifthenelse{\equal{\karnaughmapNumCol}{2}}{% + \foreach \pos/\lab in {0.5/0, 1.5/1} {% + \path (\pos, \karnaughmapNumRow) node[above] {$\lab$};% + }% + }{}% +% \end{macrocode} +% +% 4 columns: anchors are above the top row |\karnaughmapNumRow| +% and in the middle of the cells at 0.5 ... 3.5. +% \begin{macrocode} + \ifthenelse{\equal{\karnaughmapNumCol}{4}}{% + \foreach \pos/\lab in {0.5/00, 1.5/01, 2.5/11, 3.5/10} {% + \path (\pos, \karnaughmapNumRow) node[above] {$\lab$};% + }% + }{}% +% \end{macrocode} +% +% 8 columns: anchors are above the top row |\karnaughmapNumRow| +% and in the middle of the cells at 0.5 ... 7.5. +% \begin{macrocode} + \ifthenelse{\equal{\karnaughmapNumCol}{8}}{% + \foreach \pos/\lab in {0.5/000, 1.5/001, 2.5/011, 3.5/010, 4.5/110, 5.5/111, 6.5/101, 7.5/100} {% + \path (\pos, \karnaughmapNumRow) node[above] {$\lab$};% + }% + }{}% +% \end{macrocode} +% +% 16 columns: anchors are above the top row |\karnaughmapNumRow| +% and in the middle of the cells at 0.5 ... 15.5. +% \begin{macrocode} + \ifthenelse{\equal{\karnaughmapNumCol}{16}}{% + \foreach \pos/\lab in {0.5/0000, 1.5/0001, 2.5/0011, 3.5/0010, 4.5/0110, 5.5/0111, 6.5/0101, 7.5/0100, + 8.5/1100, 9.5/1101,10.5/1111,11.5/1110,12.5/1010,13.5/1011,14.5/1001,15.5/1000} {% + \path (\pos, \karnaughmapNumRow) node[above] {$\lab$};% + }% + }{}% +% \end{macrocode} +% +% 2 rows: anchors are left of the first column with coordinate (0, x) +% and in the middle of the cells at 0.5 and 1.5. +% \begin{macrocode} + \ifthenelse{\equal{\karnaughmapNumRow}{2}}{% + \foreach \pos/\lab in {0.5/0, 1.5/1} {% + \path (0, \karnaughmapNumRow-\pos) node[left] {$\lab$};% + }% + }{}% +% \end{macrocode} +% +% 4 rows: anchors are left of the first column with coordinate (0, x) +% and in the middle of the cells at 0.5 ... 3.5. +% \begin{macrocode} + \ifthenelse{\equal{\karnaughmapNumRow}{4}}{% + \foreach \pos/\lab in {0.5/00, 1.5/01, 2.5/11, 3.5/10} {% + \path (0, \karnaughmapNumRow-\pos) node[left] {$\lab$};% + }% + }{}% +% \end{macrocode} +% +% 8 rows: anchors are left of the first column with coordinate (0, x) +% and in the middle of the cells at 0.5 ... 7.5. +% \begin{macrocode} + \ifthenelse{\equal{\karnaughmapNumRow}{8}}{% + \foreach \pos/\lab in {0.5/000, 1.5/001, 2.5/011, 3.5/010, 4.5/110, 5.5/111, 6.5/101, 7.5/100} {% + \path (-0.125, \karnaughmapNumRow-\pos) node[left] {$\lab$};% + }% + }{}% +% \end{macrocode} +% +% 16 rows: anchors are left of the first column with coordinate (0, x) +% and in the middle of the cells at 0.5 ... 15.5. +% \begin{macrocode} + \ifthenelse{\equal{\karnaughmapNumRow}{16}}{% + \foreach \pos/\lab in {0.5/0000, 1.5/0001, 2.5/0011, 3.5/0010, 4.5/0110, 5.5/0111, 6.5/0101, 7.5/0100, + 8.5/1100, 9.5/1101,10.5/1111,11.5/1110,12.5/1010,13.5/1011,14.5/1001,15.5/1000} {% + \path (-0.1875, \karnaughmapNumRow-\pos) node[left] {$\lab$};% + }% + }{}% +\fi +% \end{macrocode} +% +% Typeset binary labels above and left of the map if switch |omitbinaries| is false. +% +% Set base bias of variable labels; +% the top and left bias is modified depending on if the binary labels are set or not. +% \begin{macrocode} +\def\karnaughmapVariableBaseBias{0.2} +\ifKV@karnaughmap@omitbinaries +% \end{macrocode} +% +% Set bias to 0 if binaries are not typeset. +% \begin{macrocode} + \def\karnaughmapVariableTopBias{0} + \def\karnaughmapVariableLeftBias{0} +\else +% \end{macrocode} +% +% Set bias accordingly if binaries have 1 or 2 characters. +% \begin{macrocode} + \def\karnaughmapVariableTopBias{0.3} + \ifthenelse{\equal{\karnaughmapVarLabelD}{}}{% + \def\karnaughmapVariableLeftBias{0.2} + }{% + \def\karnaughmapVariableLeftBias{0.4} + } +\fi +% \end{macrocode} +% +% Typeset the variable labels around the map if switch |omitvariables| is false. +% \begin{macrocode} +\ifKV@karnaughmap@omitvariables +\else + \ifthenelse{\equal{\karnaughmapVarLabelA}{}}{% + }{% + \ifthenelse{\equal{\karnaughmapVarLabelB}{}}{% + \draw (1.1, \karnaughmapNumRow + \karnaughmapVariableBaseBias + \karnaughmapVariableTopBias) + -- node[above] {$\karnaughmapVarLabelA$} ++(0.8, 0); + \ifKV@karnaughmap@omitnegated + \else + \draw (0.1, \karnaughmapNumRow + \karnaughmapVariableBaseBias + \karnaughmapVariableTopBias) + -- node[above] {$\overline{\karnaughmapVarLabelA}$} ++(0.8, 0); + \fi + }{% + \draw (2.1, \karnaughmapNumRow + \karnaughmapVariableBaseBias + \karnaughmapVariableTopBias) + -- node[above] {$\karnaughmapVarLabelA$} ++(1.8, 0); + \draw (1.1, -\karnaughmapVariableBaseBias) + -- node[below] {$\karnaughmapVarLabelB$} ++(1.8, 0); + \ifKV@karnaughmap@omitnegated + \else + \draw (0.1, \karnaughmapNumRow + \karnaughmapVariableBaseBias + \karnaughmapVariableTopBias) + -- node[above] {$\overline{\karnaughmapVarLabelA}$} ++(1.8, 0); + \draw (0.1, -\karnaughmapVariableBaseBias) + -- node[below] {$\overline{\karnaughmapVarLabelB}$} ++(0.8, 0); + \draw (3.1, -\karnaughmapVariableBaseBias) + -- node[below] {$\overline{\karnaughmapVarLabelB}$} ++(0.8, 0); + \fi + } + } + \ifthenelse{\equal{\karnaughmapVarLabelC}{}}{% + }{% + \ifthenelse{\equal{\karnaughmapVarLabelD}{}}{% + \draw (-\karnaughmapVariableBaseBias -\karnaughmapVariableLeftBias, 0.1) + -- node[left] {$\karnaughmapVarLabelC$} ++(0, 0.8); + \ifKV@karnaughmap@omitnegated + \else + \draw (-\karnaughmapVariableBaseBias -\karnaughmapVariableLeftBias, 1.1) + -- node[left] {$\overline{\karnaughmapVarLabelC}$} ++(0, 0.8); + \fi + }{% + \draw (-\karnaughmapVariableBaseBias -\karnaughmapVariableLeftBias, 0.1) + -- node[left] {$\karnaughmapVarLabelC$} ++(0, 1.8); + \draw (\karnaughmapNumCol + \karnaughmapVariableBaseBias, 1.1) + -- node[right] {$\karnaughmapVarLabelD$} ++(0, 1.8); + \ifKV@karnaughmap@omitnegated + \else + \draw (-\karnaughmapVariableBaseBias -\karnaughmapVariableLeftBias, 2.1) + -- node[left] {$\overline{\karnaughmapVarLabelC}$} ++(0, 1.8); + \draw (\karnaughmapNumCol + \karnaughmapVariableBaseBias, 0.1) + -- node[right] {$\overline{\karnaughmapVarLabelD}$} ++(0, 0.8); + \draw (\karnaughmapNumCol + \karnaughmapVariableBaseBias, 3.1) + -- node[right] {$\overline{\karnaughmapVarLabelD}$} ++(0, 0.8); + \fi + } + } +\fi +% \end{macrocode} +% +% Typeset decimal index if switch |omitidx| is false. +% \begin{macrocode} +\ifKV@karnaughmap@omitidx +\else + \karnaughmapPrintCellContents[anchor=west]{0.0}{-0.2}{\karnaughmapSize}{\karnaughmapNumRow}{\karnaughmapPrintIndex[\karnaughmapNumVar]} +\fi +% \end{macrocode} +% +% Typeset the cell entries. +% \begin{macrocode} +\karnaughmapPrintCellContents{0.5}{-0.5}{\karnaughmapSize}{\karnaughmapNumRow}{\karnaughmapPrintValue{\karnaughmapCellEntries}} +% \end{macrocode} +% +% Close the scope +% \begin{macrocode} + \end{scope} +% \end{macrocode} +% +% Finishing macro bracket. +% \begin{macrocode} +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\karnaughmapcolorfield} +% The coloring macro takes two mandatory and one optional argument:\\ +% \oarg{key=value}\marg{map size}\marg{fields}\marg{color}. +% \begin{macrocode} +\newcommand{\karnaughmapcolorfield}[4][]{% +\setkeys{karnaughmap}{fill,opacity}% +\ifthenelse{\equal{#1}{}}{}{\setkeys*{karnaughmap}{#1}}% +\ifthenelse{\equal{#3}{}}{}{% +\StrSplit{#3}{1}{\karnaughmapColorfieldCur}{\karnaughmapColorfieldRem} +\ifthenelse{\equal{#2}{2}}{% +\karnaughmapShadeMapfieldTWO[\XKV@rm]{\karnaughmapColorfieldCur}{#4} +}{} +\ifthenelse{\equal{#2}{3}}{% +\karnaughmapShadeMapfieldTHREE[\XKV@rm]{\karnaughmapColorfieldCur}{#4} +}{} +\ifthenelse{\equal{#2}{4}}{% +\karnaughmapShadeMapfieldFOUR[\XKV@rm]{\karnaughmapColorfieldCur}{#4} +}{} +\karnaughmapcolorfield[#1]{#2}{\karnaughmapColorfieldRem}{#4} +} +} +% \end{macrocode} +% \end{macro} +% +% +% +% +% +% +% +% +% \section{To Do}% \iffalse TODO: SEC:To Do \fi +% \begin{itemize} +% \item Adjust the map label positions as well as the function label to fit the negated variant. +% \item Increase supported karnaugh map size: 5 and 6 variables should be feasible in a single karnaugh map +% \item Provide the possibility to permute the karnaugh map +% \end{itemize} +% +% +% +% \iffalse ins meta-comment +% +% For convenience, the corresponding .ins file is provided here. +% Just copy this in a file called karnaughmap.ins and run it through latex. +% +% %% +% %% Copyright (C) 2013 by Michael Vonbun <michael.vonbun@tum.de> +% %% +% %% This file may be distributed and/or modified under the conditions of +% %% the LaTeX Project Public License, either version 1.2 of this license +% %% or (at your option) any later version. The latest version of this +% %% license is in: +% %% +% %% http://www.latex-project.org/lppl.txt +% %% +% %% and version 1.2 or later is part of all distributions of LaTeX version +% %% 1999/12/01 or later. +% %% +% +% \input docstrip.tex +% \keepsilent +% +% \usedir{tex/latex/lisstyles/karnaughmap} +% +% \preamble +% +% This is a generated file. +% +% Copyright (C) 2013 by Michael Vonbun <michael.vonbun@tum.de> +% +% This file may be distributed and/or modified under the conditions of +% the LaTeX Project Public License, either version 1.2 of this license +% or (at your option) any later version. The latest version of this +% license is in: +% +% http://www.latex-project.org/lppl.txt +% +% and version 1.2 or later is part of all distributions of LaTeX version +% 1999/12/01 or later. +% +% \endpreamble +% +% \generate{\file{karnaughmap.sty}{\from{karnaughmap.dtx}{package}}} +% +% \obeyspaces +% \Msg{*************************************************************} +% \Msg{* *} +% \Msg{* To finish the installation you have to move the following *} +% \Msg{* file into a directory searched by TeX: *} +% \Msg{* *} +% \Msg{* karnaughmap.sty *} +% \Msg{* *} +% \Msg{* To produce the documentation run the file karnaughmap.dtx *} +% \Msg{* through LaTeX/pdfLaTeX. *} +% \Msg{* To produce the changelog, run *} +% \Msg{* makeindex -s gind.ist -o karnaughmap.ind karnaughmap.idx *} +% \Msg{* To produce the index, run *} +% \Msg{* makeindex -s gglo.ist -o karnaughmap.gls karnaughmap.glo *} +% \Msg{* *} +% \Msg{* gglo.ist and gind.ist are shipped with the doc-package *} +% \Msg{* *} +% \Msg{* Happy TeXing! *} +% \Msg{* *} +% \Msg{*************************************************************} +% +% \endbatchfile +% +% \fi +% +% \setcounter{IndexColumns}{2} +% \Finale \PrintChanges \PrintIndex +\endinput diff --git a/Master/texmf-dist/source/latex/karnaughmap/karnaughmap.ins b/Master/texmf-dist/source/latex/karnaughmap/karnaughmap.ins new file mode 100644 index 00000000000..0d45506b70a --- /dev/null +++ b/Master/texmf-dist/source/latex/karnaughmap/karnaughmap.ins @@ -0,0 +1,64 @@ +%% +%% Copyright (C) 2015 by Michael Vonbun <m.vonbun@gmail.com> +%% +%% This file may be distributed and/or modified under the conditions of +%% the LaTeX Project Public License, either version 1.2 of this license +%% or (at your option) any later version. The latest version of this +%% license is in: +%% +%% http://www.latex-project.org/lppl.txt +%% +%% and version 1.2 or later is part of all distributions of LaTeX version +%% 1999/12/01 or later. +%% + +\input docstrip.tex +\keepsilent + +\usedir{./} + +\preamble + +This is a generated file. + +Copyright (C) 2013 by Michael Vonbun <michael.vonbun@tum.de> + +This file may be distributed and/or modified under the conditions of +the LaTeX Project Public License, either version 1.2 of this license +or (at your option) any later version. The latest version of this +license is in: + + http://www.latex-project.org/lppl.txt + +and version 1.2 or later is part of all distributions of LaTeX version +1999/12/01 or later. + +\endpreamble + +\askforoverwritefalse +\generate{\file{karnaughmap.sty}{\from{karnaughmap.dtx}{package}}} + +\obeyspaces +\Msg{*************************************************************} +\Msg{* *} +\Msg{* To finish the installation you have to move the following *} +\Msg{* file into a directory searched by TeX: *} +\Msg{* *} +\Msg{* karnaughmap.sty *} +\Msg{* *} +\Msg{* To produce the documentation run the file karnaughmap.dtx *} +\Msg{* through LaTeX/pdfLaTeX. *} +\Msg{* To produce the changelog, run *} +\Msg{* To produce the changelog, run *} +\Msg{* makeindex -s gind.ist -o karnaughmap.ind karnaughmap.idx *} +\Msg{* To produce the index, run *} +\Msg{* makeindex -s gglo.ist -o karnaughmap.gls karnaughmap.glo *} +\Msg{* Run LaTeX/pdfLaTeX again afterwards *} +\Msg{* *} +\Msg{* gglo.ist and gind.ist are shipped with the doc-package *} +\Msg{* *} +\Msg{* Happy TeXing! *} +\Msg{* *} +\Msg{*************************************************************} + +\endbatchfile diff --git a/Master/texmf-dist/tex/latex/karnaughmap/karnaughmap.sty b/Master/texmf-dist/tex/latex/karnaughmap/karnaughmap.sty new file mode 100644 index 00000000000..58c3e4fbebd --- /dev/null +++ b/Master/texmf-dist/tex/latex/karnaughmap/karnaughmap.sty @@ -0,0 +1,579 @@ +%% +%% This is file `karnaughmap.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% karnaughmap.dtx (with options: `package') +%% +%% This is a generated file. +%% +%% Copyright (C) 2013 by Michael Vonbun <michael.vonbun@tum.de> +%% +%% This file may be distributed and/or modified under the conditions of +%% the LaTeX Project Public License, either version 1.2 of this license +%% or (at your option) any later version. The latest version of this +%% license is in: +%% +%% http://www.latex-project.org/lppl.txt +%% +%% and version 1.2 or later is part of all distributions of LaTeX version +%% 1999/12/01 or later. +%% +\NeedsTeXFormat{LaTeX2e}[1999/12/01] +\ProvidesPackage{karnaughmap} + [2015/04/20 v2.0 draw karnaugh maps using tikz] +\RequirePackage{tikz} +\RequirePackage{xkeyval} +\RequirePackage{ifthen} +\RequirePackage{xstring} +\newcounter{karnaughmapIdxCounter} +\newcounter{karnaughmapStrCounter} +\setcounter{karnaughmapIdxCounter}{0} +\setcounter{karnaughmapStrCounter}{0} +\define@boolkeys{karnaughmap}{omitzeros, omitones, omitdontcares}[true] +\define@boolkeys{karnaughmap}{omitbinaries, omitvariables, omitidx, binaryidx, omitnegated}[true] +\define@boolkey{karnaughmap}{outline}[true]{\setkeys{karnaughmap}{fill=false}} +\define@boolkeys{karnaughmap}{fill}[true] +\define@cmdkey{karnaughmap}{opacity}[0.5]{} +\define@cmdkey{karnaughmap}{defaultmap}[16]{} +\define@cmdkey{karnaughmap}{function}[z]{} +\define@cmdkey{karnaughmap}{variables}[abcd]{} +\define@cmdkey{karnaughmap}{dontcare}[*]{} +\define@key{karnaughmap}{color}[black]{% + \colorlet{karnaughmapColor}{#1}% + \colorlet{karnaughmapMapColor}{#1}} +\define@key{karnaughmap}{draw}[karnaughmapColor]{\colorlet{karnaughmapMapColor}{#1}} +\define@key{karnaughmap}{labelcolor}[karnaughmapColor]{% + \colorlet{karnaughmapColor}{#1}} +\define@cmdkeys{karnaughmap}{xshift,yshift}[0] +\newcommand{\setkarnaughmap}[1][]{% +\ifthenelse{\equal{#1}{}}{% +\setkeys{karnaughmap}{% +omitzeros, omitnegated} +\setkeys{karnaughmap}{defaultmap, function, variables, dontcare, color, draw, labelcolor, xshift, yshift} +}{ +\setkeys{karnaughmap}{#1} +}} +\setkarnaughmap +\newcommand{\karnaughmapPrintIndex}[1][4]{% +\scriptsize% +\ifKV@karnaughmap@binaryidx + \ifthenelse{\equal{#1}{2}}{% + \ifcase\value{karnaughmapIdxCounter}% + 00\or 01\or 10\or 11 + \fi + }{}% + \ifthenelse{\equal{#1}{3}}{% + \ifcase\value{karnaughmapIdxCounter}% + 000\or 001\or 010\or 011\or 100\or 101\or 110\or 111 + \fi + }{}% + \ifthenelse{\equal{#1}{4}}{% + \ifcase\value{karnaughmapIdxCounter}% + 0000\or 0001\or 0010\or 0011\or 0100\or 0101\or 0110\or 0111\or + 1000\or 1001\or 1010\or 1011\or 1100\or 1101\or 1110\or 1111 + \fi + }{}% +\else +$\thekarnaughmapIdxCounter$% +\fi +\stepcounter{karnaughmapIdxCounter}% +} +\newcommand{\karnaughmapPrintValue}[2][]{% + \stepcounter{karnaughmapStrCounter}% + \StrChar{#2}{\thekarnaughmapStrCounter}} +\newcommand{\karnaughmapPrintCellContents}[6][]{% +\ifthenelse{\equal{#4}{4}}{% + \def\karnaughmapPCCColumnSpecifier{++( 0,-1) node[#1] {#6}}% + \path (0, #5) + ++(#2,#3) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+1,+1) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ; +}{} +\ifthenelse{\equal{#4}{8}}{% + \def\karnaughmapPCCColumnSpecifier{++( 0,-1) node[#1] {#6}}% + \path (0, #5) + ++(#2,#3) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+1,+1) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+2,+1) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-1,+1) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ; +}{} +\ifthenelse{\equal{#4}{16}}{% + \def\karnaughmapPCCColumnSpecifier{% + ++( 0,-1) node[#1] {#6} + ++( 0,-2) node[#1] {#6} + ++( 0,+1) node[#1] {#6} + }% + \path (0, #5) + ++(#2,#3) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+1,+2) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+2,+2) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-1,+2) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ; +}{} +\ifthenelse{\equal{#4}{32}}{% + \def\karnaughmapPCCColumnSpecifier{% + ++( 0,-1) node[#1] {#6} + ++( 0,-2) node[#1] {#6} + ++( 0,+1) node[#1] {#6} + }% + \path (0, #5) + ++(#2,#3) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+1,+2) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+2,+2) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-1,+2) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+5,+2) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-1,+2) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-2,+2) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+1,+2) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ; +}{} +\ifthenelse{\equal{#4}{64}}{% + \def\karnaughmapPCCColumnSpecifier{% + ++( 0,-1) node[#1] {#6} + ++( 0,-2) node[#1] {#6} + ++( 0,+1) node[#1] {#6} + ++( 0,-5) node[#1] {#6} + ++( 0,+1) node[#1] {#6} + ++( 0,+2) node[#1] {#6} + ++( 0,-1) node[#1] {#6} + }% + \path (0, #5) + ++(#2,#3) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+1,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+2,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-1,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+5,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-1,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-2,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+1,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ; +}{} +\ifthenelse{\equal{#4}{128}}{% + \def\karnaughmapPCCColumnSpecifier{% + ++( 0,-1) node[#1] {#6} + ++( 0,-2) node[#1] {#6} + ++( 0,+1) node[#1] {#6} + ++( 0,-5) node[#1] {#6} + ++( 0,+1) node[#1] {#6} + ++( 0,+2) node[#1] {#6} + ++( 0,-1) node[#1] {#6} + }% + \path (0, #5) + ++(#2,#3) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+1,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+2,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-1,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+5,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-1,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-2,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+1,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+10,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-1,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-2,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+1,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-5,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+1,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+2,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-1,+5) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ; +}{} +\ifthenelse{\equal{#4}{256}}{% + \def\karnaughmapPCCColumnSpecifier{% + ++( 0,-1) node[#1] {#6} + ++( 0,-2) node[#1] {#6} + ++( 0,+1) node[#1] {#6} + ++( 0,-5) node[#1] {#6} + ++( 0,+1) node[#1] {#6} + ++( 0,+2) node[#1] {#6} + ++( 0,-1) node[#1] {#6} + + ++( 0,-10) node[#1] {#6} + ++( 0,+1) node[#1] {#6} + ++( 0,+2) node[#1] {#6} + ++( 0,-1) node[#1] {#6} + ++( 0,+5) node[#1] {#6} + ++( 0,-1) node[#1] {#6} + ++( 0,-2) node[#1] {#6} + ++( 0,+1) node[#1] {#6} + }% + \path (0, #5) + ++(#2,#3) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+1,+10) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+2,+10) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-1,+10) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+5,+10) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-1,+10) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-2,+10) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+1,+10) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+10,+10) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-1,+10) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-2,+10) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+1,+10) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-5,+10) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+1,+10) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(+2,+10) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ++(-1,+10) node[#1] {#6} + \karnaughmapPCCColumnSpecifier + ; +}{} +} + +\newcommand{\karnaughmapHighlightField}[3][]{% +\ifKV@karnaughmap@fill + \path[fill=#3,opacity=\cmdKV@karnaughmap@opacity,#1] (#2) rectangle ++(1,1);% +\fi +\ifKV@karnaughmap@outline + \draw[#3,#1] (#2) ++ (0.1,0.1) rectangle ++(0.8,0.8);% +\fi +} +\newcommand{\karnaughmapShadeMapfieldTWO}[3][]{% +\begin{scope}[scale=1] + \ifthenelse{\equal{#2}{0}}{\karnaughmapHighlightField[#1]{0,1}{#3}}{}% + \ifthenelse{\equal{#2}{1}}{\karnaughmapHighlightField[#1]{0,0}{#3}}{}% + \ifthenelse{\equal{#2}{2}}{\karnaughmapHighlightField[#1]{1,1}{#3}}{}% + \ifthenelse{\equal{#2}{3}}{\karnaughmapHighlightField[#1]{1,0}{#3}}{}% +\end{scope} +} +\newcommand{\karnaughmapShadeMapfieldTHREE}[3][]{% +\begin{scope}[scale=1] + \ifthenelse{\equal{#2}{0}}{\karnaughmapHighlightField[#1]{0,1}{#3}}{}% + \ifthenelse{\equal{#2}{1}}{\karnaughmapHighlightField[#1]{0,0}{#3}}{}% + \ifthenelse{\equal{#2}{2}}{\karnaughmapHighlightField[#1]{1,1}{#3}}{}% + \ifthenelse{\equal{#2}{3}}{\karnaughmapHighlightField[#1]{1,0}{#3}}{}% + \ifthenelse{\equal{#2}{4}}{\karnaughmapHighlightField[#1]{3,1}{#3}}{}% + \ifthenelse{\equal{#2}{5}}{\karnaughmapHighlightField[#1]{3,0}{#3}}{}% + \ifthenelse{\equal{#2}{6}}{\karnaughmapHighlightField[#1]{2,1}{#3}}{}% + \ifthenelse{\equal{#2}{7}}{\karnaughmapHighlightField[#1]{2,0}{#3}}{}% +\end{scope} +} +\newcommand{\karnaughmapShadeMapfieldFOUR}[3][]{% +\begin{scope}[scale=1]% +\ifthenelse{\equal{#2}{0}}{\karnaughmapHighlightField[#1]{0,3}{#3}}{}% +\ifthenelse{\equal{#2}{1}}{\karnaughmapHighlightField[#1]{0,2}{#3}}{}% +\ifthenelse{\equal{#2}{2}}{\karnaughmapHighlightField[#1]{0,0}{#3}}{}% +\ifthenelse{\equal{#2}{3}}{\karnaughmapHighlightField[#1]{0,1}{#3}}{}% +\ifthenelse{\equal{#2}{4}}{\karnaughmapHighlightField[#1]{1,3}{#3}}{}% +\ifthenelse{\equal{#2}{5}}{\karnaughmapHighlightField[#1]{1,2}{#3}}{}% +\ifthenelse{\equal{#2}{6}}{\karnaughmapHighlightField[#1]{1,0}{#3}}{}% +\ifthenelse{\equal{#2}{7}}{\karnaughmapHighlightField[#1]{1,1}{#3}}{}% +\ifthenelse{\equal{#2}{8}}{\karnaughmapHighlightField[#1]{3,3}{#3}}{}% +\ifthenelse{\equal{#2}{9}}{\karnaughmapHighlightField[#1]{3,2}{#3}}{}% +\ifthenelse{\equal{#2}{a}\OR\equal{#2}{A}}{\karnaughmapHighlightField[#1]{3,0}{#3}}{}% +\ifthenelse{\equal{#2}{b}\OR\equal{#2}{B}}{\karnaughmapHighlightField[#1]{3,1}{#3}}{}% +\ifthenelse{\equal{#2}{c}\OR\equal{#2}{C}}{\karnaughmapHighlightField[#1]{2,3}{#3}}{}% +\ifthenelse{\equal{#2}{d}\OR\equal{#2}{D}}{\karnaughmapHighlightField[#1]{2,2}{#3}}{}% +\ifthenelse{\equal{#2}{e}\OR\equal{#2}{E}}{\karnaughmapHighlightField[#1]{2,0}{#3}}{}% +\ifthenelse{\equal{#2}{f}\OR\equal{#2}{F}}{\karnaughmapHighlightField[#1]{2,1}{#3}}{}% +\end{scope} +} +\newcommand{\karnaughmap}[2][]{% +\ifthenelse{\equal{#1}{}}{}{\setkeys{karnaughmap}{#1}} +\def\karnaughmapCellEntries{#2}% +\ifthenelse{\equal{#2}{}}{% + \def\karnaughmapSize{\cmdKV@karnaughmap@defaultmap} +}{% +\IfSubStr{\karnaughmapCellEntries}{ }{% +\StrDel[0]{\karnaughmapCellEntries}{ }[\karnaughmapCellEntries] +}{} + \StrLen{\karnaughmapCellEntries}[\karnaughmapSize]% + \ifthenelse{\karnaughmapSize < 4}{% + \def\karnaughmapSize{#2}\def\karnaughmapCellEntries{}}{}% +} +\ifKV@karnaughmap@omitzeros + \StrSubstitute[0]{\karnaughmapCellEntries}{0}{ }[\karnaughmapCellEntries] +\fi +\ifKV@karnaughmap@omitones + \StrSubstitute[0]{\karnaughmapCellEntries}{1}{ }[\karnaughmapCellEntries] +\fi +\ifKV@karnaughmap@omitdontcares + \StrSubstitute[0]{\karnaughmapCellEntries}{\cmdKV@karnaughmap@dontcare}{ }[\karnaughmapCellEntries] +\fi +\setcounter{karnaughmapIdxCounter}{0} +\setcounter{karnaughmapStrCounter}{0} +\ifthenelse{\karnaughmapSize = 4}{% + \StrChar{\cmdKV@karnaughmap@variables}{1}[\karnaughmapVarLabelA] + \def\karnaughmapVarLabelB{} + \StrChar{\cmdKV@karnaughmap@variables}{2}[\karnaughmapVarLabelC] + \def\karnaughmapVarLabelD{} + \def\karnaughmapNumRow{2} + \def\karnaughmapNumCol{2} + \def\karnaughmapNumVar{2} +}{} +\ifthenelse{\karnaughmapSize = 8}{% + \StrChar{\cmdKV@karnaughmap@variables}{1}[\karnaughmapVarLabelA] + \StrChar{\cmdKV@karnaughmap@variables}{2}[\karnaughmapVarLabelB] + \StrChar{\cmdKV@karnaughmap@variables}{3}[\karnaughmapVarLabelC] + \def\karnaughmapVarLabelD{} + \def\karnaughmapNumRow{2} + \def\karnaughmapNumCol{4} + \def\karnaughmapNumVar{3} +}{} +\ifthenelse{\karnaughmapSize = 16}{% + \StrChar{\cmdKV@karnaughmap@variables}{1}[\karnaughmapVarLabelA] + \StrChar{\cmdKV@karnaughmap@variables}{2}[\karnaughmapVarLabelB] + \StrChar{\cmdKV@karnaughmap@variables}{3}[\karnaughmapVarLabelC] + \StrChar{\cmdKV@karnaughmap@variables}{4}[\karnaughmapVarLabelD] + \def\karnaughmapNumRow{4} + \def\karnaughmapNumCol{4} + \def\karnaughmapNumVar{4} +}{} +\ifthenelse{\karnaughmapSize = 32}{% + \setkeys{karnaughmap}{omitidx=true, omitvariables=true} + \StrMid{\cmdKV@karnaughmap@variables}{1}{3}[\karnaughmapVarLabelA] + \def\karnaughmapVarLabelB{} + \StrMid{\cmdKV@karnaughmap@variables}{4}{5}[\karnaughmapVarLabelC] + \def\karnaughmapVarLabelD{} + \def\karnaughmapNumRow{4} + \def\karnaughmapNumCol{8} + \def\karnaughmapNumVar{5} +}{} +\ifthenelse{\karnaughmapSize = 64}{% + \setkeys{karnaughmap}{omitidx=true, omitvariables=true} + \StrMid{\cmdKV@karnaughmap@variables}{1}{3}[\karnaughmapVarLabelA] + \def\karnaughmapVarLabelB{} + \StrMid{\cmdKV@karnaughmap@variables}{4}{6}[\karnaughmapVarLabelC] + \def\karnaughmapVarLabelD{} + \def\karnaughmapNumRow{8} + \def\karnaughmapNumCol{8} + \def\karnaughmapNumVar{6} +}{} +\ifthenelse{\karnaughmapSize = 128}{% + \setkeys{karnaughmap}{omitidx=true, omitvariables=true} + \StrMid{\cmdKV@karnaughmap@variables}{1}{4}[\karnaughmapVarLabelA] + \def\karnaughmapVarLabelB{} + \StrMid{\cmdKV@karnaughmap@variables}{5}{7}[\karnaughmapVarLabelC] + \def\karnaughmapVarLabelD{} + \def\karnaughmapNumRow{8} + \def\karnaughmapNumCol{16} + \def\karnaughmapNumVar{7} +}{} +\ifthenelse{\karnaughmapSize = 256}{% + \setkeys{karnaughmap}{omitidx=true, omitvariables=true} + \StrMid{\cmdKV@karnaughmap@variables}{1}{4}[\karnaughmapVarLabelA] + \def\karnaughmapVarLabelB{} + \StrMid{\cmdKV@karnaughmap@variables}{5}{8}[\karnaughmapVarLabelC] + \def\karnaughmapVarLabelD{} + \def\karnaughmapNumRow{16} + \def\karnaughmapNumCol{16} + \def\karnaughmapNumVar{8} +}{} + \begin{scope}[xshift=\cmdKV@karnaughmap@xshift, + yshift=\cmdKV@karnaughmap@yshift, + color=karnaughmapColor, + draw=karnaughmapMapColor ] + \draw (0,0) rectangle (\karnaughmapNumCol, \karnaughmapNumRow); + \foreach \x in {1,2,...,\karnaughmapNumCol} {% + \ifthenelse{\equal{\x}{1}}{}{% + \draw (\x-1,0) -- ++(0,\karnaughmapNumRow);% + }% + }% + \foreach \x in {1,2,...,\karnaughmapNumRow} {% + \ifthenelse{\equal{\x}{1}}{}{% + \draw (0,\x-1) -- ++(\karnaughmapNumCol,0);% + }% + }% +\draw (0,\karnaughmapNumRow) -- ++(-0.4,0.4) coordinate(identifier) + -- ++(-0.4,0.4) + node[yshift=7.5,xshift=-3.5,right] {% + \ifthenelse{\equal{\cmdKV@karnaughmap@function}{}}{}{$\cmdKV@karnaughmap@function\colon$}}; + \path (identifier) node[above right, xshift=-2.5] {$\karnaughmapVarLabelA\karnaughmapVarLabelB$}; + \path (identifier) node[below left, yshift=0.5] {$\karnaughmapVarLabelC\karnaughmapVarLabelD$}; +\ifKV@karnaughmap@omitbinaries +\else + \ifthenelse{\equal{\karnaughmapNumCol}{2}}{% + \foreach \pos/\lab in {0.5/0, 1.5/1} {% + \path (\pos, \karnaughmapNumRow) node[above] {$\lab$};% + }% + }{}% + \ifthenelse{\equal{\karnaughmapNumCol}{4}}{% + \foreach \pos/\lab in {0.5/00, 1.5/01, 2.5/11, 3.5/10} {% + \path (\pos, \karnaughmapNumRow) node[above] {$\lab$};% + }% + }{}% + \ifthenelse{\equal{\karnaughmapNumCol}{8}}{% + \foreach \pos/\lab in {0.5/000, 1.5/001, 2.5/011, 3.5/010, 4.5/110, 5.5/111, 6.5/101, 7.5/100} {% + \path (\pos, \karnaughmapNumRow) node[above] {$\lab$};% + }% + }{}% + \ifthenelse{\equal{\karnaughmapNumCol}{16}}{% + \foreach \pos/\lab in {0.5/0000, 1.5/0001, 2.5/0011, 3.5/0010, 4.5/0110, 5.5/0111, 6.5/0101, 7.5/0100, + 8.5/1100, 9.5/1101,10.5/1111,11.5/1110,12.5/1010,13.5/1011,14.5/1001,15.5/1000} {% + \path (\pos, \karnaughmapNumRow) node[above] {$\lab$};% + }% + }{}% + \ifthenelse{\equal{\karnaughmapNumRow}{2}}{% + \foreach \pos/\lab in {0.5/0, 1.5/1} {% + \path (0, \karnaughmapNumRow-\pos) node[left] {$\lab$};% + }% + }{}% + \ifthenelse{\equal{\karnaughmapNumRow}{4}}{% + \foreach \pos/\lab in {0.5/00, 1.5/01, 2.5/11, 3.5/10} {% + \path (0, \karnaughmapNumRow-\pos) node[left] {$\lab$};% + }% + }{}% + \ifthenelse{\equal{\karnaughmapNumRow}{8}}{% + \foreach \pos/\lab in {0.5/000, 1.5/001, 2.5/011, 3.5/010, 4.5/110, 5.5/111, 6.5/101, 7.5/100} {% + \path (-0.125, \karnaughmapNumRow-\pos) node[left] {$\lab$};% + }% + }{}% + \ifthenelse{\equal{\karnaughmapNumRow}{16}}{% + \foreach \pos/\lab in {0.5/0000, 1.5/0001, 2.5/0011, 3.5/0010, 4.5/0110, 5.5/0111, 6.5/0101, 7.5/0100, + 8.5/1100, 9.5/1101,10.5/1111,11.5/1110,12.5/1010,13.5/1011,14.5/1001,15.5/1000} {% + \path (-0.1875, \karnaughmapNumRow-\pos) node[left] {$\lab$};% + }% + }{}% +\fi +\def\karnaughmapVariableBaseBias{0.2} +\ifKV@karnaughmap@omitbinaries + \def\karnaughmapVariableTopBias{0} + \def\karnaughmapVariableLeftBias{0} +\else + \def\karnaughmapVariableTopBias{0.3} + \ifthenelse{\equal{\karnaughmapVarLabelD}{}}{% + \def\karnaughmapVariableLeftBias{0.2} + }{% + \def\karnaughmapVariableLeftBias{0.4} + } +\fi +\ifKV@karnaughmap@omitvariables +\else + \ifthenelse{\equal{\karnaughmapVarLabelA}{}}{% + }{% + \ifthenelse{\equal{\karnaughmapVarLabelB}{}}{% + \draw (1.1, \karnaughmapNumRow + \karnaughmapVariableBaseBias + \karnaughmapVariableTopBias) + -- node[above] {$\karnaughmapVarLabelA$} ++(0.8, 0); + \ifKV@karnaughmap@omitnegated + \else + \draw (0.1, \karnaughmapNumRow + \karnaughmapVariableBaseBias + \karnaughmapVariableTopBias) + -- node[above] {$\overline{\karnaughmapVarLabelA}$} ++(0.8, 0); + \fi + }{% + \draw (2.1, \karnaughmapNumRow + \karnaughmapVariableBaseBias + \karnaughmapVariableTopBias) + -- node[above] {$\karnaughmapVarLabelA$} ++(1.8, 0); + \draw (1.1, -\karnaughmapVariableBaseBias) + -- node[below] {$\karnaughmapVarLabelB$} ++(1.8, 0); + \ifKV@karnaughmap@omitnegated + \else + \draw (0.1, \karnaughmapNumRow + \karnaughmapVariableBaseBias + \karnaughmapVariableTopBias) + -- node[above] {$\overline{\karnaughmapVarLabelA}$} ++(1.8, 0); + \draw (0.1, -\karnaughmapVariableBaseBias) + -- node[below] {$\overline{\karnaughmapVarLabelB}$} ++(0.8, 0); + \draw (3.1, -\karnaughmapVariableBaseBias) + -- node[below] {$\overline{\karnaughmapVarLabelB}$} ++(0.8, 0); + \fi + } + } + \ifthenelse{\equal{\karnaughmapVarLabelC}{}}{% + }{% + \ifthenelse{\equal{\karnaughmapVarLabelD}{}}{% + \draw (-\karnaughmapVariableBaseBias -\karnaughmapVariableLeftBias, 0.1) + -- node[left] {$\karnaughmapVarLabelC$} ++(0, 0.8); + \ifKV@karnaughmap@omitnegated + \else + \draw (-\karnaughmapVariableBaseBias -\karnaughmapVariableLeftBias, 1.1) + -- node[left] {$\overline{\karnaughmapVarLabelC}$} ++(0, 0.8); + \fi + }{% + \draw (-\karnaughmapVariableBaseBias -\karnaughmapVariableLeftBias, 0.1) + -- node[left] {$\karnaughmapVarLabelC$} ++(0, 1.8); + \draw (\karnaughmapNumCol + \karnaughmapVariableBaseBias, 1.1) + -- node[right] {$\karnaughmapVarLabelD$} ++(0, 1.8); + \ifKV@karnaughmap@omitnegated + \else + \draw (-\karnaughmapVariableBaseBias -\karnaughmapVariableLeftBias, 2.1) + -- node[left] {$\overline{\karnaughmapVarLabelC}$} ++(0, 1.8); + \draw (\karnaughmapNumCol + \karnaughmapVariableBaseBias, 0.1) + -- node[right] {$\overline{\karnaughmapVarLabelD}$} ++(0, 0.8); + \draw (\karnaughmapNumCol + \karnaughmapVariableBaseBias, 3.1) + -- node[right] {$\overline{\karnaughmapVarLabelD}$} ++(0, 0.8); + \fi + } + } +\fi +\ifKV@karnaughmap@omitidx +\else + \karnaughmapPrintCellContents[anchor=west]{0.0}{-0.2}{\karnaughmapSize}{\karnaughmapNumRow}{\karnaughmapPrintIndex[\karnaughmapNumVar]} +\fi +\karnaughmapPrintCellContents{0.5}{-0.5}{\karnaughmapSize}{\karnaughmapNumRow}{\karnaughmapPrintValue{\karnaughmapCellEntries}} + \end{scope} +} +\newcommand{\karnaughmapcolorfield}[4][]{% +\setkeys{karnaughmap}{fill,opacity}% +\ifthenelse{\equal{#1}{}}{}{\setkeys*{karnaughmap}{#1}}% +\ifthenelse{\equal{#3}{}}{}{% +\StrSplit{#3}{1}{\karnaughmapColorfieldCur}{\karnaughmapColorfieldRem} +\ifthenelse{\equal{#2}{2}}{% +\karnaughmapShadeMapfieldTWO[\XKV@rm]{\karnaughmapColorfieldCur}{#4} +}{} +\ifthenelse{\equal{#2}{3}}{% +\karnaughmapShadeMapfieldTHREE[\XKV@rm]{\karnaughmapColorfieldCur}{#4} +}{} +\ifthenelse{\equal{#2}{4}}{% +\karnaughmapShadeMapfieldFOUR[\XKV@rm]{\karnaughmapColorfieldCur}{#4} +}{} +\karnaughmapcolorfield[#1]{#2}{\karnaughmapColorfieldRem}{#4} +} +} +\endinput +%% +%% End of file `karnaughmap.sty'. diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check index c16a512b3ac..f1908b64ace 100755 --- a/Master/tlpkg/bin/tlpkg-ctan-check +++ b/Master/tlpkg/bin/tlpkg-ctan-check @@ -296,7 +296,7 @@ my @TLP_working = qw( jfontmaps jknapltx jlabels jmlr jneurosci jpsj jsclasses jslectureplanner jumplines junicode jura juraabbrev jurabib juramisc jurarsp js-misc jvlisting - kantlipsum karnaugh kastrup kdgdocs kerkis kerntest + kantlipsum karnaugh karnaughmap kastrup kdgdocs kerkis kerntest keycommand keyreader keystroke keyval2e kix kixfont knitting knittingpattern knuth knuth-lib knuth-local koma-moderncvclassic koma-script koma-script-examples koma-script-sfs diff --git a/Master/tlpkg/tlpsrc/collection-science.tlpsrc b/Master/tlpkg/tlpsrc/collection-science.tlpsrc index 43b4b8d6df9..5b87367e09b 100644 --- a/Master/tlpkg/tlpsrc/collection-science.tlpsrc +++ b/Master/tlpkg/tlpsrc/collection-science.tlpsrc @@ -47,6 +47,7 @@ depend hepparticles depend hepthesis depend hepunits depend karnaugh +depend karnaughmap depend matlab-prettifier depend mhchem depend miller diff --git a/Master/tlpkg/tlpsrc/karnaughmap.tlpsrc b/Master/tlpkg/tlpsrc/karnaughmap.tlpsrc new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/Master/tlpkg/tlpsrc/karnaughmap.tlpsrc |