| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (C) 2015 by Michael Vonbun <[email protected]> |
| 4 |
% --------------------------------------------------------- |
| 5 |
% |
| 6 |
% This file may be distributed and/or modified under the |
| 7 |
% conditions of the LaTeX Project Public License, either version 1.2 |
| 8 |
% of this license or (at your option) any later version. |
| 9 |
% The latest version of this license is in: |
| 10 |
% |
| 11 |
% http://www.latex-project.org/lppl.txt |
| 12 |
% |
| 13 |
% and version 1.2 or later is part of all distributions of LaTeX |
| 14 |
% version 1999/12/01 or later. |
| 15 |
% |
| 16 |
% \fi |
| 17 |
% |
| 18 |
% \iffalse |
| 19 |
%<*driver> |
| 20 |
\ProvidesFile{karnaughmap.dtx} |
| 21 |
%</driver> |
| 22 |
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01] |
| 23 |
%<package>\ProvidesPackage{karnaughmap} |
| 24 |
%<*package> |
| 25 |
[2015/04/20 v2.0 draw karnaugh maps using tikz] |
| 26 |
%</package> |
| 27 |
% |
| 28 |
%<*driver> |
| 29 |
\documentclass{ltxdoc} |
| 30 |
\usepackage{xkvview} |
| 31 |
\usepackage{hyperref} |
| 32 |
\usepackage{karnaughmap}[2013/12/06] |
| 33 |
\EnableCrossrefs |
| 34 |
\CodelineIndex |
| 35 |
\RecordChanges |
| 36 |
\begin{document} |
| 37 |
\DocInput{karnaughmap.dtx} |
| 38 |
\PrintChanges |
| 39 |
\PrintIndex |
| 40 |
\end{document} |
| 41 |
%</driver> |
| 42 |
% \fi |
| 43 |
% |
| 44 |
% \CheckSum{751} |
| 45 |
% |
| 46 |
% \CharacterTable |
| 47 |
% {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 |
| 48 |
% 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 |
| 49 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 50 |
% Exclamation \! Double quote \" Hash (number) \# |
| 51 |
% Dollar \$ Percent \% Ampersand \& |
| 52 |
% Acute accent \' Left paren \( Right paren \) |
| 53 |
% Asterisk \* Plus \+ Comma \, |
| 54 |
% Minus \- Point \. Solidus \/ |
| 55 |
% Colon \: Semicolon \; Less than \< |
| 56 |
% Equals \= Greater than \> Question mark \? |
| 57 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 58 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 59 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 60 |
% Right brace \} Tilde \~} |
| 61 |
% |
| 62 |
% |
| 63 |
% \changes{v1.0}{2013/08/29}{Initial version} |
| 64 |
% \changes{v1.0a}{2013/08/29}{Added a to do section} |
| 65 |
% \changes{v1.1}{2013/08/29}{Added binary indices} |
| 66 |
% \changes{v1.2}{2013/08/30}{Added negated labels |
| 67 |
% and adjusted the positioning of variable and function labels.} |
| 68 |
% \changes{v1.3}{2013/09/04}{Made the table color adjustable.} |
| 69 |
% \changes{v1.4}{2013/12/06}{Added a colored box highlight macro.} |
| 70 |
% \changes{v2.0}{2015/04/20}{Minor touchup for publication.} |
| 71 |
% |
| 72 |
% \GetFileInfo{karnaughmap.dtx} |
| 73 |
% |
| 74 |
% \DoNotIndex{\newcommand,\newenvironment,\else,\fi} |
| 75 |
% |
| 76 |
% |
| 77 |
% \title{The \textsf{karnaughmap} package\thanks{This document |
| 78 |
% corresponds to \textsf{karnaughmap}~\fileversion, dated \filedate.}} |
| 79 |
% \author{Michael Vonbun \\ \texttt{[email protected]}} |
| 80 |
% |
| 81 |
% \maketitle |
| 82 |
% |
| 83 |
% \section{Introduction}% \iffalse TODO: SEC:Intoduction \fi |
| 84 |
% |
| 85 |
% This package uses TikZ to typeset Karnaugh maps in an easy way. |
| 86 |
% Though the map size is restricted to four variables (as for \fileversion), |
| 87 |
% it is easier and customizable compared to \textsf{karnaugh.tex}. |
| 88 |
% |
| 89 |
% \section{Installation}% \iffalse TODO: SEC:Installation \fi |
| 90 |
% |
| 91 |
% Install this package like any other \LaTeX~package.\\ |
| 92 |
% |
| 93 |
% \noindent |
| 94 |
% The end of this file contains the installation file (.ins) code in case |
| 95 |
% the provided ins-file got lost.\\ |
| 96 |
% |
| 97 |
% \noindent |
| 98 |
% For style creation run |latex karnaughmap.ins|. |
| 99 |
% For doc/manual creation run |latex karnaughmap.dtx| afterwards. |
| 100 |
% |
| 101 |
% \section{Dependencies}% \iffalse TODO: SEC:Dependencies \fi |
| 102 |
% |
| 103 |
% As of \textsf{karnaughmap}~\fileversion~this package depends on |
| 104 |
% \begin{itemize} |
| 105 |
% \item \textsf{tikz} |
| 106 |
% \item \textsf{xkeyval} |
| 107 |
% \item \textsf{ifthen} |
| 108 |
% \item \textsf{xstring} |
| 109 |
% \end{itemize} |
| 110 |
% |
| 111 |
% \section{Usage}% \iffalse TODO: SEC:Usage \fi |
| 112 |
% |
| 113 |
% \subsection{Karnaugh Map Macros}% \iffalse TODO: SUBSEC:Karnaugh Map Macros \fi |
| 114 |
% |
| 115 |
% \DescribeMacro{\karnaughmap} |\karnaughmap|\oarg{key=value}\marg{entries} |
| 116 |
% |
| 117 |
% Use this macro inside of a |tikzpicture|-environment to typeset a Karnaugh map |
| 118 |
% of a corresponding truth table.\\ |
| 119 |
% |
| 120 |
% \paragraph{Example} |
| 121 |
% Assume the truth table with inputs $a$ and $b$ and output $z$ is |
| 122 |
% \begin{center} |
| 123 |
% \begin{tabular}{ccc} |
| 124 |
% $a$ & $b$ & $z$ \\\hline |
| 125 |
% 0 & 0 & 0 \\ |
| 126 |
% 0 & 1 & 0 \\ |
| 127 |
% 1 & 0 & * \\ |
| 128 |
% 1 & 1 & 1 |
| 129 |
% \end{tabular} |
| 130 |
% \end{center} |
| 131 |
% |
| 132 |
% \begin{minipage}[t]{0.45\textwidth}% |
| 133 |
% Then, the corresponding Karnaugh map with default layout is:\\ |
| 134 |
% \begin{tikzpicture}[thick] |
| 135 |
% \karnaughmap{00*1} |
| 136 |
% \end{tikzpicture}\\ |
| 137 |
% \end{minipage} |
| 138 |
% \hfill |
| 139 |
% \begin{minipage}[t]{0.45\textwidth}% |
| 140 |
% Which was typeset using:\\ |
| 141 |
% |\begin{tikzpicture}[thick] |\\ |
| 142 |
% | \karnaughmap{00*1} |\\ |
| 143 |
% |\end{tikzpicture} | |
| 144 |
% \end{minipage} |
| 145 |
% |
| 146 |
% To produce empty maps, there are two possibilities. |
| 147 |
% First is to use the key |defaultmap| described later and omit the mandatory input, |
| 148 |
% the second is by providing a scalar mandatory argument that is equal the number of cells desired, |
| 149 |
% i.e. 4,8, or 16. |
| 150 |
% |
| 151 |
% \begin{minipage}[t]{0.45\textwidth}% |
| 152 |
% \begin{center} |
| 153 |
% |\karnaughmap{4}|\\ |
| 154 |
% \begin{tikzpicture}[thick] |
| 155 |
% \karnaughmap{4} |
| 156 |
% \end{tikzpicture}\\ |
| 157 |
% \end{center} |
| 158 |
% \end{minipage} |
| 159 |
% \hfill |
| 160 |
% \begin{minipage}[t]{0.45\textwidth}% |
| 161 |
% \begin{center} |
| 162 |
% |\karnaughmap[defaultmap=4]{}|\\ |
| 163 |
% \begin{tikzpicture}[thick] |
| 164 |
% \karnaughmap[defaultmap=4]{} |
| 165 |
% \end{tikzpicture}\\ |
| 166 |
% \end{center} |
| 167 |
% \end{minipage}\\ |
| 168 |
% |
| 169 |
% \medskip |
| 170 |
% |
| 171 |
% Note that it is also possible to provide the input string with blanks: |
| 172 |
% |
| 173 |
% \noindent |
| 174 |
% |\begin{tikzpicture}[thick]|\\ |
| 175 |
% | \karnaughmap{1100 0101}|\\ |
| 176 |
% |\end{tikzpicture}|\\ |
| 177 |
% |
| 178 |
% \begin{center} |
| 179 |
% \begin{tikzpicture}[thick] |
| 180 |
% \karnaughmap{1100 0101} |
| 181 |
% \end{tikzpicture}\\ |
| 182 |
% \end{center} |
| 183 |
% |
| 184 |
% This is especially useful when larger maps are typeset as it increases |
| 185 |
% readability of the \LaTeXe code.\\ |
| 186 |
% |
| 187 |
% |
| 188 |
% \DescribeMacro{\karnaughmapcolorfield} |\karnaughmapcolorfield|\oarg{key=value}\marg{map size}\marg{field string}\marg{color} |
| 189 |
% |
| 190 |
% Use this macro inside of a |tikzpicture|-environment to color a Karnaugh map of size |map size|. |
| 191 |
% Use hexadecimal values to address a certain field of the map in the |field string|.\\ |
| 192 |
% |
| 193 |
% \noindent |
| 194 |
% |\begin{tikzpicture}[thick]|\\ |
| 195 |
% |\karnaughmapcolorfield{2}{01}{teal!50}%|\\ |
| 196 |
% |\karnaughmapcolorfield{2}{3}{violet!50}%|\\ |
| 197 |
% |\karnaughmap{4}|\\ |
| 198 |
% |\end{tikzpicture}|\\ |
| 199 |
% |
| 200 |
% \begin{center} |
| 201 |
% \begin{tikzpicture}[thick] |
| 202 |
% \karnaughmapcolorfield{2}{01}{teal!50}% |
| 203 |
% \karnaughmapcolorfield{2}{3}{violet!50}% |
| 204 |
% \karnaughmap{4} |
| 205 |
% \end{tikzpicture}\\ |
| 206 |
% \end{center}% |
| 207 |
% |
| 208 |
% The keys for this macro allow for two different styles: |
| 209 |
% \emph{filled} |fill| and \emph{outlined} |outline|. |
| 210 |
% The default is filled. |
| 211 |
% In addition, TikZ keys are forwarded to the |\draw| or |\fill| command, |
| 212 |
% allowing a good adjustment of styles.\\ |
| 213 |
% |
| 214 |
% \noindent |
| 215 |
% |\begin{tikzpicture}[thick]|\\ |
| 216 |
% |\karnaughmapcolorfield[outline]{2}{01}{teal!50}%|\\ |
| 217 |
% |\karnaughmapcolorfield[outline,ultra thick]{2}{3}{violet!50}%|\\ |
| 218 |
% |\karnaughmap{4}|\\ |
| 219 |
% |\end{tikzpicture}|\\ |
| 220 |
% |
| 221 |
% \begin{center} |
| 222 |
% \begin{tikzpicture}[thick] |
| 223 |
% \karnaughmapcolorfield[outline]{2}{01}{teal!50}% |
| 224 |
% \karnaughmapcolorfield[outline,ultra thick]{2}{3}{violet!50}% |
| 225 |
% \karnaughmap{4} |
| 226 |
% \end{tikzpicture}\\ |
| 227 |
% \end{center}% |
| 228 |
% |
| 229 |
% |
| 230 |
% |
| 231 |
% |
| 232 |
% |
| 233 |
% |
| 234 |
% |
| 235 |
% \subsection{Style Customizations}% \iffalse TODO: SUBSEC:Style Customizations \fi |
| 236 |
% |
| 237 |
% For style customization a key-value system is provided. |
| 238 |
% |
| 239 |
% \DescribeMacro{\setkarnaughmap} |\setkarnaughmap|\oarg{key=value} |
| 240 |
% This is the interface function for setting the keys. |
| 241 |
% To restore the defaults call |\setkarnaughmap|. |
| 242 |
% |
| 243 |
% The defaults are\\ |
| 244 |
% | \setkarnaughmap[omitzeros, defaultmap=16, |\\ |
| 245 |
% | function=z, variables=abcd, dontcare=*]|. |
| 246 |
% |
| 247 |
% \paragraph{Key-Value List} The following table is an overview over all options provided. |
| 248 |
% The exact behavior and description of the keys are described below. |
| 249 |
% |
| 250 |
% \xkvview{family=karnaughmap} |
| 251 |
% |
| 252 |
% \paragraph{Selective Entry Printing} |
| 253 |
% The following keys control the printing of different types of Karnaugh map cell entries. |
| 254 |
% |
| 255 |
% \DescribeMacro{omitzeros} |omitzeros|\oarg{=\textbf{true}/false} |
| 256 |
% Toggle between printing and omitting zero-valued entries in the Karnaugh map. |
| 257 |
% \begin{center} |
| 258 |
% |\karnaughmap[omitzeros=false]{00*1}|\\ |
| 259 |
% \begin{tikzpicture}[thick] |
| 260 |
% \karnaughmap[omitzeros=false]{00*1} |
| 261 |
% \end{tikzpicture}\\ |
| 262 |
% \end{center} |
| 263 |
% |
| 264 |
% \DescribeMacro{omitones} |omitones|\oarg{=true/\textbf{false}} |
| 265 |
% Toggle between printing and omitting one-valued entries in the Karnaugh map. |
| 266 |
% \begin{center} |
| 267 |
% |\karnaughmap[omitzeros=false,omitones]{00*1}|\\ |
| 268 |
% \begin{tikzpicture}[thick] |
| 269 |
% \karnaughmap[omitzeros=false,omitones]{00*1} |
| 270 |
% \end{tikzpicture}\\ |
| 271 |
% \end{center} |
| 272 |
% |
| 273 |
% \DescribeMacro{omitdontcares} |omitdontcares|\oarg{=true/\textbf{false}} |
| 274 |
% Toggle between printing and omitting don't care entries in the Karnaugh map. |
| 275 |
% \begin{center} |
| 276 |
% |\karnaughmap[omitzeros=false,omitdontcares]{00*1}|\\ |
| 277 |
% \begin{tikzpicture}[thick] |
| 278 |
% \karnaughmap[omitzeros=false,omitdontcares]{00*1} |
| 279 |
% \end{tikzpicture}\\ |
| 280 |
% \end{center} |
| 281 |
% |
| 282 |
% \paragraph{Karnaugh Map Style} |
| 283 |
% The following keys control the printing of different types of Karnaugh map labels. |
| 284 |
% |
| 285 |
% \DescribeMacro{omitbinaries} |omitbinaries|\oarg{true/\textbf{false}} |
| 286 |
% Toggle between printing and omitting the binary encoding on top and left of the Karnaugh map. |
| 287 |
% \begin{center} |
| 288 |
% |\karnaughmap[omitbinaries]{00*1}|\\ |
| 289 |
% \begin{tikzpicture}[thick] |
| 290 |
% \karnaughmap[omitbinaries]{00*1} |
| 291 |
% \end{tikzpicture}\\ |
| 292 |
% \end{center} |
| 293 |
% |
| 294 |
% \DescribeMacro{omitvariables} |omitvariables|\oarg{=true/\textbf{false}} |
| 295 |
% Toggle between printing and omitting the variable labeling of rows and columns around the Karnaugh map. |
| 296 |
% \begin{center} |
| 297 |
% |\karnaughmap[omitvariables]{00*1}|\\ |
| 298 |
% \begin{tikzpicture}[thick] |
| 299 |
% \karnaughmap[omitvariables]{00*1} |
| 300 |
% \end{tikzpicture}\\ |
| 301 |
% \end{center} |
| 302 |
% |
| 303 |
% \DescribeMacro{omitidx} |omitidx|\oarg{=true/\textbf{false}} |
| 304 |
% Toggle between printing and omitting index values besides the cell entries in the Karnaugh map. |
| 305 |
% \begin{center} |
| 306 |
% |\karnaughmap[omitidx]{00*1}|\\ |
| 307 |
% \begin{tikzpicture}[thick] |
| 308 |
% \karnaughmap[omitidx]{00*1} |
| 309 |
% \end{tikzpicture}\\ |
| 310 |
% \end{center} |
| 311 |
% |
| 312 |
% \DescribeMacro{binaryidx} |binaryidx|\oarg{=true/\textbf{false}} |
| 313 |
% Toggle between decimal and binary indices. |
| 314 |
% \begin{center} |
| 315 |
% |\karnaughmap[binaryidx]{00*1}|\\ |
| 316 |
% \begin{tikzpicture}[thick] |
| 317 |
% \karnaughmap[binaryidx]{00*1} |
| 318 |
% \end{tikzpicture}\\ |
| 319 |
% \end{center} |
| 320 |
% |
| 321 |
% \DescribeMacro{omitnegated} |omitnegated|\oarg{=\textbf{true}/false} |
| 322 |
% Toggle between typesetting the negated in addition to the non-negated variable labels. |
| 323 |
% \begin{center} |
| 324 |
% |\karnaughmap[omitnegated=false]{00*1}|\\ |
| 325 |
% \begin{tikzpicture}[thick] |
| 326 |
% \karnaughmap[omitnegated=false]{00*1} |
| 327 |
% \end{tikzpicture}\\ |
| 328 |
% \end{center} |
| 329 |
% |
| 330 |
% \paragraph{Map Customizations} |
| 331 |
% The following keys can be used to customize the Karnaugh maps in various ways. |
| 332 |
% |
| 333 |
% \DescribeMacro{defaultmap} |defaultmap|\oarg{=\textbf{16}} |
| 334 |
% Set the default map size (4,8, or 16), i.e. this map size is used if the mandatory argument of |
| 335 |
% |\karnaughmap{}| is empty. Thus, empty maps can be produced. |
| 336 |
% \begin{center} |
| 337 |
% |\karnaughmap[defaultmap=4]{}|, |\karnaughmap[defaultmap=8]{}|\\ |
| 338 |
% \begin{tikzpicture}[thick] |
| 339 |
% \karnaughmap[defaultmap=4]{} |
| 340 |
% \end{tikzpicture} |
| 341 |
% \begin{tikzpicture}[thick] |
| 342 |
% \karnaughmap[defaultmap=8]{} |
| 343 |
% \end{tikzpicture}\\ |
| 344 |
% \end{center} |
| 345 |
% Note that the same functionality can be achieved by providing a scalar mandatory input |
| 346 |
% \begin{center} |
| 347 |
% |\karnaughmap{4}|, |\karnaughmap[defaultmap=8]{}|\\ |
| 348 |
% \begin{tikzpicture}[thick] |
| 349 |
% \karnaughmap{4} |
| 350 |
% \end{tikzpicture} |
| 351 |
% \begin{tikzpicture}[thick] |
| 352 |
% \karnaughmap{8} |
| 353 |
% \end{tikzpicture}\\ |
| 354 |
% \end{center} |
| 355 |
% |
| 356 |
% \DescribeMacro{function} |function|\oarg{=\textbf{z}} |
| 357 |
% Set the function label used to label the Karnaugh map. |
| 358 |
% \begin{center} |
| 359 |
% |\karnaughmap[function={f(a,b)}]{00*1}|\\ |
| 360 |
% \begin{tikzpicture}[thick] |
| 361 |
% \karnaughmap[function={f(a,b)}]{00*1} |
| 362 |
% \end{tikzpicture}\\ |
| 363 |
% \end{center} |
| 364 |
% \begin{center} |
| 365 |
% |\karnaughmap[function=]{00*1}|\\ |
| 366 |
% \begin{tikzpicture}[thick] |
| 367 |
% \karnaughmap[function=]{00*1} |
| 368 |
% \end{tikzpicture}\\ |
| 369 |
% \end{center} |
| 370 |
% |
| 371 |
% \DescribeMacro{variables} |variables|\oarg{=\textbf{abcd}} |
| 372 |
% Set the variable names used in the Karnaugh map. |
| 373 |
% Note that you have to provide a single string of variables |
| 374 |
% or variables embraced by curly braces. |
| 375 |
% \begin{center} |
| 376 |
% |\karnaughmap[variables=kl]{00*1}|\\ |
| 377 |
% \begin{tikzpicture}[thick] |
| 378 |
% \karnaughmap[variables=kl]{00*1} |
| 379 |
% \end{tikzpicture}\\ |
| 380 |
% \end{center} |
| 381 |
% |
| 382 |
% \begin{center} |
| 383 |
% |\karnaughmap[variables={{s_2}{s_1}{s_0}{a}}]{01** 10** 0101 **00}|\\ |
| 384 |
% \begin{tikzpicture}[thick] |
| 385 |
% \karnaughmap[variables={{s_2}{s_1}{s_0}{a}}]{01** 10** 0101 **00} |
| 386 |
% \end{tikzpicture}\\ |
| 387 |
% \end{center} |
| 388 |
% |
| 389 |
% |
| 390 |
% |
| 391 |
% \DescribeMacro{dontcare} |dontcare|\oarg{=\textbf{*}} |
| 392 |
% Set the don't care character. |
| 393 |
% This is only needed if you provide the |omitdontcares| key and use |
| 394 |
% don't care characters other than |*| in the |\karnaughmap{x}| inputstring. |
| 395 |
% \begin{center} |
| 396 |
% |\karnaughmap[dontcare=X,omitdontcares,omitzeros=false]{00X1}|\\ |
| 397 |
% \begin{tikzpicture}[thick] |
| 398 |
% \karnaughmap[dontcare=X,omitdontcares,omitzeros=false]{00X1} |
| 399 |
% \end{tikzpicture}\\ |
| 400 |
% \end{center} |
| 401 |
% |
| 402 |
% \DescribeMacro{color} |color|\oarg{=\textbf{black}} |
| 403 |
% Set the color of the \emph{entire} Karnaugh map, including labels, entries, etc. |
| 404 |
% \begin{center} |
| 405 |
% |\karnaughmap[color=teal]{00*1}|\\ |
| 406 |
% \begin{tikzpicture}[thick] |
| 407 |
% \karnaughmap[color=teal]{00*1} |
| 408 |
% \end{tikzpicture}\\ |
| 409 |
% \end{center} |
| 410 |
% |
| 411 |
% \DescribeMacro{draw} |draw|\oarg{=\textbf{same as color}} |
| 412 |
% Set the color of the Karnaugh map \emph{only}, i.e. the lines that are drawn. |
| 413 |
% The labels are not affected. |
| 414 |
% \begin{center} |
| 415 |
% |\karnaughmap[draw=teal]{00*1}|\\ |
| 416 |
% \begin{tikzpicture}[thick] |
| 417 |
% \karnaughmap[draw=teal]{00*1} |
| 418 |
% \end{tikzpicture}\\ |
| 419 |
% \end{center} |
| 420 |
% |
| 421 |
% \DescribeMacro{labelcolor} |labelcolor|\oarg{=\textbf{same as color}} |
| 422 |
% Set the color of the labels of the Karnaugh map \emph{only}. |
| 423 |
% The lines are not affected. |
| 424 |
% \begin{center} |
| 425 |
% |\karnaughmap[labelcolor=teal]{00*1}|\\ |
| 426 |
% \begin{tikzpicture}[thick] |
| 427 |
% \karnaughmap[labelcolor=teal]{00*1} |
| 428 |
% \end{tikzpicture}\\ |
| 429 |
% \end{center} |
| 430 |
% |
| 431 |
% \paragraph{Multiple Karnaugh Maps in one TikZ Picture} |
| 432 |
% To typeset more than one Karnaugh map into one TikZ Picture, |
| 433 |
% use |xshift| and |yshift|, just as usual n TikZ. |
| 434 |
% |
| 435 |
% \DescribeMacro{xshift} |xshift|\oarg{=\textbf{0}} |
| 436 |
% Shift the Karnaugh map in x-direction within the TikZ picture. |
| 437 |
% \begin{center} |
| 438 |
% |\karnaughmap{4}\karnaughmap[xshift=5cm]{4}|\\ |
| 439 |
% \begin{tikzpicture}[thick] |
| 440 |
% \karnaughmap{4} |
| 441 |
% \karnaughmap[xshift=5cm]{4} |
| 442 |
% \end{tikzpicture}\\ |
| 443 |
% \end{center} |
| 444 |
% |
| 445 |
% \DescribeMacro{yshift} |yshift|\oarg{=\textbf{0}} |
| 446 |
% Shift the Karnaugh map in x-direction within the TikZ picture. |
| 447 |
% \begin{center} |
| 448 |
% |\karnaughmap{4}\karnaughmap[yshift=5cm]{4}|\\ |
| 449 |
% \begin{tikzpicture}[thick] |
| 450 |
% \karnaughmap{4} |
| 451 |
% \karnaughmap[yshift=5cm]{4} |
| 452 |
% \end{tikzpicture}\\ |
| 453 |
% \end{center} |
| 454 |
% |
| 455 |
% \section{Examples}% \iffalse TODO: SEC:Examples \fi |
| 456 |
% \subsection{Basic Usage Examples:}% \iffalse TODO: SUBSEC:Basic Examples \fi |
| 457 |
% \begin{center} |
| 458 |
% |\karnaughmap[defaultmap=16,binaryidx,omitnegated=false]{}|\\ |
| 459 |
% \begin{tikzpicture}[thick] |
| 460 |
% \karnaughmap[defaultmap=16,binaryidx,omitnegated=false,function={f(a,b,c,d)}]{} |
| 461 |
% \end{tikzpicture}\\ |
| 462 |
% \end{center} |
| 463 |
% |
| 464 |
% \begin{center} |
| 465 |
% |\karnaughmap[defaultmap=4,binaryidx,omitnegated=false,color=teal]{}|\\ |
| 466 |
% \begin{tikzpicture}[thick] |
| 467 |
% \karnaughmap[defaultmap=4,binaryidx,omitnegated=false,color=teal]{} |
| 468 |
% \end{tikzpicture}\\ |
| 469 |
% \end{center} |
| 470 |
% |
| 471 |
% |
| 472 |
% \noindent |
| 473 |
% |\karnaughmap{4}| |
| 474 |
% \begin{center} |
| 475 |
% \begin{tikzpicture}[thick] |
| 476 |
% \karnaughmap{4} |
| 477 |
% \end{tikzpicture}\\ |
| 478 |
% \end{center} |
| 479 |
% |
| 480 |
% |
| 481 |
% \subsection{Field coloring}% \iffalse TODO: SUBSEC:Field Coloring \fi |
| 482 |
% \noindent |
| 483 |
% |\begin{tikzpicture}[thick]|\\ |
| 484 |
% |\foreach \x [count=\xi] in {0,1,2,3} {%|\\ |
| 485 |
% | \pgfmathparse{-20+30*\xi}%|\\ |
| 486 |
% | \karnaughmapcolorfield{2}{\x}{teal!\pgfmathresult}%|\\ |
| 487 |
% |}%|\\ |
| 488 |
% |\karnaughmap{2}|\\ |
| 489 |
% |\end{tikzpicture}|\\ |
| 490 |
% |
| 491 |
% \begin{center} |
| 492 |
% \begin{tikzpicture}[thick] |
| 493 |
% \foreach \x [count=\xi] in {0,1,2,3} {% |
| 494 |
% \pgfmathparse{-20+30*\xi} |
| 495 |
% \karnaughmapcolorfield{2}{\x}{teal!\pgfmathresult}% |
| 496 |
% }% |
| 497 |
% \karnaughmap{4} |
| 498 |
% \end{tikzpicture}\\ |
| 499 |
% \end{center} |
| 500 |
% |
| 501 |
% |
| 502 |
% \noindent |
| 503 |
% |\begin{tikzpicture}[thick]|\\ |
| 504 |
% |\foreach \x [count=\xi] in {0,1,2,3} {%|\\ |
| 505 |
% | \pgfmathparse{-20+30*\xi}%|\\ |
| 506 |
% | \karnaughmapcolorfield{3}{\x}{teal!\pgfmathresult}%|\\ |
| 507 |
% |}%|\\ |
| 508 |
% |\foreach \x [count=\xi] in {4,5,6,7} {%|\\ |
| 509 |
% | \pgfmathparse{-20+30*\xi}%|\\ |
| 510 |
% | \karnaughmapcolorfield{3}{\x}{purple!\pgfmathresult}%|\\ |
| 511 |
% |}%|\\ |
| 512 |
% |\karnaughmap{8}|\\ |
| 513 |
% |\end{tikzpicture}|\\ |
| 514 |
% |
| 515 |
% \begin{center} |
| 516 |
% \begin{tikzpicture}[thick] |
| 517 |
% \foreach \x [count=\xi] in {0,1,2,3} {% |
| 518 |
% \pgfmathparse{-20+30*\xi}% |
| 519 |
% \karnaughmapcolorfield{3}{\x}{teal!\pgfmathresult}% |
| 520 |
% }% |
| 521 |
% \foreach \x [count=\xi] in {4,5,6,7} {% |
| 522 |
% \pgfmathparse{-20+30*\xi}% |
| 523 |
% \karnaughmapcolorfield{3}{\x}{purple!\pgfmathresult}% |
| 524 |
% }% |
| 525 |
% \karnaughmap{8} |
| 526 |
% \end{tikzpicture}\\ |
| 527 |
% \end{center} |
| 528 |
% |
| 529 |
% |
| 530 |
% \noindent |
| 531 |
% |\begin{tikzpicture}[thick]|\\ |
| 532 |
% |\foreach \x [count=\xi] in {0,1,2,3} {%|\\ |
| 533 |
% | \pgfmathparse{-20+30*\xi}%|\\ |
| 534 |
% | \karnaughmapcolorfield{4}{\x}{teal!\pgfmathresult}%|\\ |
| 535 |
% |}%|\\ |
| 536 |
% |\foreach \x [count=\xi] in {4,5,6,7} {%|\\ |
| 537 |
% | \pgfmathparse{-20+30*\xi}%|\\ |
| 538 |
% | \karnaughmapcolorfield{4}{\x}{purple!\pgfmathresult}%|\\ |
| 539 |
% |}%|\\ |
| 540 |
% |\foreach \x [count=\xi] in {8,9,a,b} {%|\\ |
| 541 |
% | \pgfmathparse{-20+30*\xi}%|\\ |
| 542 |
% | \karnaughmapcolorfield{4}{\x}{olive!\pgfmathresult}%|\\ |
| 543 |
% |}%|\\ |
| 544 |
% |\foreach \x [count=\xi] in {c,d,e,f} {%|\\ |
| 545 |
% | \pgfmathparse{-20+30*\xi}%|\\ |
| 546 |
% | \karnaughmapcolorfield{4}{\x}{violet!\pgfmathresult}%|\\ |
| 547 |
% |}%|\\ |
| 548 |
% |\karnaughmap[defaultmap=16]{}%|\\ |
| 549 |
% |\end{tikzpicture}|\\ |
| 550 |
% |
| 551 |
% \begin{center} |
| 552 |
% \begin{tikzpicture}[thick] |
| 553 |
% \foreach \x [count=\xi] in {0,1,2,3} {% |
| 554 |
% \pgfmathparse{-20+30*\xi}% |
| 555 |
% \karnaughmapcolorfield{4}{\x}{teal!\pgfmathresult}% |
| 556 |
% }% |
| 557 |
% \foreach \x [count=\xi] in {4,5,6,7} {% |
| 558 |
% \pgfmathparse{-20+30*\xi}% |
| 559 |
% \karnaughmapcolorfield{4}{\x}{purple!\pgfmathresult}% |
| 560 |
% }% |
| 561 |
% \foreach \x [count=\xi] in {8,9,a,b} {% |
| 562 |
% \pgfmathparse{-20+30*\xi}% |
| 563 |
% \karnaughmapcolorfield{4}{\x}{olive!\pgfmathresult}% |
| 564 |
% }% |
| 565 |
% \foreach \x [count=\xi] in {c,d,e,f} {% |
| 566 |
% \pgfmathparse{-20+30*\xi}% |
| 567 |
% \karnaughmapcolorfield{4}{\x}{violet!\pgfmathresult}% |
| 568 |
% }% |
| 569 |
% \karnaughmap[defaultmap=16]{} |
| 570 |
% \end{tikzpicture}\\ |
| 571 |
% \end{center} |
| 572 |
% |
| 573 |
% |
| 574 |
% \section{Field Allocation Reference}\iffalse TODO: SEC: Field Alloc Reference \fi |
| 575 |
% This package provides maps with full control up to \emph{4} variables, |
| 576 |
% which is equivalent to a map size of \emph{16} fields.\\ |
| 577 |
% For bigger maps, the package provides just basic typesetting, |
| 578 |
% i.e. just the column and row encoding and the, possibly filled matrix.\\ |
| 579 |
% However, the biggest map supported yet has 256 fields.\\ |
| 580 |
% |
| 581 |
% The reference can be read as follows: |
| 582 |
% the first row contains the value of the rows, |
| 583 |
% the columns are then likewise enumerated. |
| 584 |
% By this procedure, you can check if everything went right (debugging) |
| 585 |
% and got an easy reference. |
| 586 |
% |
| 587 |
% \subsection{2 Variables -- 4 Fields} |
| 588 |
% \noindent |
| 589 |
% |\begin{tikzpicture}[thick]|\\ |
| 590 |
% | \karnaughmap[variables=ab]{o1 11 }|\\ |
| 591 |
% |\end{tikzpicture}| |
| 592 |
% |
| 593 |
% \begin{tikzpicture}[thick] |
| 594 |
% \karnaughmap[variables=ab]{o1 11 } |
| 595 |
% \end{tikzpicture} |
| 596 |
% |
| 597 |
% |
| 598 |
% \subsection{3 Variables -- 8 Fields} |
| 599 |
% \noindent |
| 600 |
% |\begin{tikzpicture}[thick]|\\ |
| 601 |
% | \karnaughmap[variables=abc]{o1 11 21 31 }|\\ |
| 602 |
% |\end{tikzpicture}| |
| 603 |
% |
| 604 |
% \begin{tikzpicture}[thick] |
| 605 |
% \karnaughmap[variables=abc]{o1 11 21 31 } |
| 606 |
% \end{tikzpicture} |
| 607 |
% |
| 608 |
% |
| 609 |
% \subsection{4 Variables -- 16 Fields} |
| 610 |
% \noindent |
| 611 |
% |\begin{tikzpicture}[thick]|\\ |
| 612 |
% | \karnaughmap[variables=abcd]{o123 1123 2123 3123 }|\\ |
| 613 |
% |\end{tikzpicture}| |
| 614 |
% |
| 615 |
% \begin{tikzpicture}[thick] |
| 616 |
% \karnaughmap[variables=abcd]{o123 1123 2123 3123 } |
| 617 |
% \end{tikzpicture} |
| 618 |
% |
| 619 |
% |
| 620 |
% \subsection{5 Variables -- 32 Fields} |
| 621 |
% \noindent |
| 622 |
% |\begin{tikzpicture}[thick]|\\ |
| 623 |
% | \karnaughmap[variables=abcde]{0000 0001 0010 0011 0100 0101 0110 1111}|\\ |
| 624 |
% |\end{tikzpicture}| |
| 625 |
% |
| 626 |
% \begin{tikzpicture}[thick] |
| 627 |
% \karnaughmap[variables=abcde]{o123 1123 2123 3123 4123 5123 6123 7123} |
| 628 |
% \end{tikzpicture} |
| 629 |
% |
| 630 |
% |
| 631 |
% \subsection{6 Variables -- 64 Fields} |
| 632 |
% \noindent |
| 633 |
% |\begin{tikzpicture}[thick]|\\ |
| 634 |
% | \karnaughmap[variables=abcdef]{o1234567 11234567 21234567 31234567 |\\ |
| 635 |
% | 41234567 51234567 61234567 71234567 }|\\ |
| 636 |
% |\end{tikzpicture}| |
| 637 |
% |
| 638 |
% \begin{tikzpicture}[thick] |
| 639 |
% \karnaughmap[variables=abcdef]{o1234567 11234567 21234567 31234567 |
| 640 |
% 41234567 51234567 61234567 71234567 } |
| 641 |
% \end{tikzpicture} |
| 642 |
% |
| 643 |
% |
| 644 |
% \subsection{7 Variables -- 128 Fields} |
| 645 |
% \noindent |
| 646 |
% |\begin{tikzpicture}[thick]|\\ |
| 647 |
% | \karnaughmap[variables=abcdefg]{o1234567 11234567 21234567 31234567 |\\ |
| 648 |
% | 41234567 51234567 61234567 71234567 |\\ |
| 649 |
% | 81234567 91234567 a1234567 b1234567 |\\ |
| 650 |
% | c1234567 d1234567 e1234567 f1234567 }|\\ |
| 651 |
% |\end{tikzpicture}| |
| 652 |
% |
| 653 |
% \hspace*{-4cm} |
| 654 |
% \begin{tikzpicture}[thick] |
| 655 |
% \karnaughmap[variables=abcdefg]{o1234567 11234567 21234567 31234567 |
| 656 |
% 41234567 51234567 61234567 71234567 |
| 657 |
% 81234567 91234567 a1234567 b1234567 |
| 658 |
% c1234567 d1234567 e1234567 f1234567 } |
| 659 |
% \end{tikzpicture} |
| 660 |
% |
| 661 |
% |
| 662 |
% \subsection{8 Variables -- 256 Fields} |
| 663 |
% \noindent |
| 664 |
% |\begin{tikzpicture}[thick]|\\ |
| 665 |
% | \karnaughmap[variables=abcdefg]{o123456789abcdef 1123456789abcdef |\\ |
| 666 |
% | 2123456789abcdef 3123456789abcdef |\\ |
| 667 |
% | 4123456789abcdef 5123456789abcdef |\\ |
| 668 |
% | 6123456789abcdef 7123456789abcdef |\\ |
| 669 |
% | 8123456789abcdef 9123456789abcdef |\\ |
| 670 |
% | a123456789abcdef b123456789abcdef |\\ |
| 671 |
% | c123456789abcdef d123456789abcdef |\\ |
| 672 |
% | e123456789abcdef f123456789abcdef }|\\ |
| 673 |
% |\end{tikzpicture}| |
| 674 |
% |
| 675 |
% \hspace*{-4cm} |
| 676 |
% \begin{tikzpicture}[thick] |
| 677 |
% \karnaughmap[variables=abcdefg]{o123456789abcdef 1123456789abcdef 2123456789abcdef 3123456789abcdef |
| 678 |
% 4123456789abcdef 5123456789abcdef 6123456789abcdef 7123456789abcdef |
| 679 |
% 8123456789abcdef 9123456789abcdef a123456789abcdef b123456789abcdef |
| 680 |
% c123456789abcdef d123456789abcdef e123456789abcdef f123456789abcdef } |
| 681 |
% \end{tikzpicture} |
| 682 |
% |
| 683 |
% |
| 684 |
% |
| 685 |
% |
| 686 |
% |
| 687 |
% |
| 688 |
% \section{Macros for Internal Usage}% \iffalse TODO: SEC:Macros for Internal Usage \fi |
| 689 |
% These macros are not intended to be used by the user, |
| 690 |
% rather these are auxiliary functions invoked by the main macro |\karnaughmap{x}|. |
| 691 |
% |
| 692 |
% Nevertheless, for documentation these macros are described here briefly. |
| 693 |
% |
| 694 |
% |
| 695 |
% \StopEventually{} |
| 696 |
% |
| 697 |
% \section{Implementation}% \iffalse TODO: SEC:Implementation \fi |
| 698 |
% |
| 699 |
% \subsection{Load Dependencies}% \iffalse TODO: SUBSEC:Load Dependencies \fi |
| 700 |
% \begin{macrocode} |
| 701 |
\RequirePackage{tikz} |
| 702 |
\RequirePackage{xkeyval} |
| 703 |
\RequirePackage{ifthen} |
| 704 |
\RequirePackage{xstring} |
| 705 |
% \end{macrocode} |
| 706 |
% |
| 707 |
% \subsection{Allocate Counters}% \iffalse TODO: SUBSEC:Allocate Counters \fi |
| 708 |
% \begin{macrocode} |
| 709 |
\newcounter{karnaughmapIdxCounter} |
| 710 |
\newcounter{karnaughmapStrCounter} |
| 711 |
\setcounter{karnaughmapIdxCounter}{0} |
| 712 |
\setcounter{karnaughmapStrCounter}{0} |
| 713 |
% \end{macrocode} |
| 714 |
% |
| 715 |
% \subsection{Key-Val Interface}% \iffalse TODO: SUBSEC:Key-Val Interface \fi |
| 716 |
% \paragraph{Switches} |
| 717 |
% Simple switches are used to control basic layout options of the Karnaugh map.\\ |
| 718 |
% |
| 719 |
% These boolean switches control if specific entries |
| 720 |
% -- i.e. zeros, ones, and don't cares -- are printed or not (omitted). |
| 721 |
% \begin{macrocode} |
| 722 |
\define@boolkeys{karnaughmap}{omitzeros, omitones, omitdontcares}[true] |
| 723 |
% \end{macrocode} |
| 724 |
% |
| 725 |
% These boolean switches control the layout of the Karnaugh map. |
| 726 |
% The |omitbinaries| switch is used to control if binary encoding is typeset left and on top of the Karnaugh map. |
| 727 |
% The |omitvariables| switch is used to control if the Karnaugh map is labeled with the variables. |
| 728 |
% The |omitidx| switch controls the typesetting of decimal indices within the cells of the Karnaugh map. |
| 729 |
% The |binaryidx| switch controls whether the indices are decimal or binary. |
| 730 |
% The |omitnegated| switch controls whether the negated variable labels are typeset as well. |
| 731 |
% \begin{macrocode} |
| 732 |
\define@boolkeys{karnaughmap}{omitbinaries, omitvariables, omitidx, binaryidx, omitnegated}[true] |
| 733 |
% \end{macrocode} |
| 734 |
% |
| 735 |
% These boolean switches control the behavior of the highlighting function. |
| 736 |
% |
| 737 |
% \begin{macrocode} |
| 738 |
\define@boolkey{karnaughmap}{outline}[true]{\setkeys{karnaughmap}{fill=false}} |
| 739 |
\define@boolkeys{karnaughmap}{fill}[true] |
| 740 |
\define@cmdkey{karnaughmap}{opacity}[0.5]{} |
| 741 |
% \end{macrocode} |
| 742 |
% |
| 743 |
% \paragraph{Customizations} |
| 744 |
% In contrast to the boolean switches these keys are used to customize the Karnaugh map.\\ |
| 745 |
% |
| 746 |
% This key controls the default size of the Karnaugh map. |
| 747 |
% It is set to 16, i.e. a 4 variable map is typeset. |
| 748 |
% \begin{macrocode} |
| 749 |
\define@cmdkey{karnaughmap}{defaultmap}[16]{} |
| 750 |
% \end{macrocode} |
| 751 |
% |
| 752 |
% This key controls the Karnaugh map function label. |
| 753 |
% The default is 'z'. |
| 754 |
% \begin{macrocode} |
| 755 |
\define@cmdkey{karnaughmap}{function}[z]{} |
| 756 |
% \end{macrocode} |
| 757 |
% |
| 758 |
% This key controls the variables. |
| 759 |
% Provide the variables as a string. |
| 760 |
% Maybe more control over variables will be added in a later version. |
| 761 |
% The default is 'abcd' |
| 762 |
% \begin{macrocode} |
| 763 |
\define@cmdkey{karnaughmap}{variables}[abcd]{} |
| 764 |
% \end{macrocode} |
| 765 |
% |
| 766 |
% Define the standard "`Don't Care"' character. |
| 767 |
% The default is '*'. |
| 768 |
% \begin{macrocode} |
| 769 |
\define@cmdkey{karnaughmap}{dontcare}[*]{} |
| 770 |
% \end{macrocode} |
| 771 |
% |
| 772 |
% Define the color. |
| 773 |
% For desired functionality both the draw and color have to be set. |
| 774 |
% \begin{macrocode} |
| 775 |
\define@key{karnaughmap}{color}[black]{% |
| 776 |
\colorlet{karnaughmapColor}{#1}% |
| 777 |
\colorlet{karnaughmapMapColor}{#1}} |
| 778 |
% \end{macrocode} |
| 779 |
% |
| 780 |
% Define the draw color, i.e. the color of the map itself. |
| 781 |
% Default is the same as color. |
| 782 |
% \begin{macrocode} |
| 783 |
\define@key{karnaughmap}{draw}[karnaughmapColor]{\colorlet{karnaughmapMapColor}{#1}} |
| 784 |
% \end{macrocode} |
| 785 |
% |
| 786 |
% Define the label color. |
| 787 |
% By setting the color only, the draw remains unchanged. |
| 788 |
% \begin{macrocode} |
| 789 |
\define@key{karnaughmap}{labelcolor}[karnaughmapColor]{% |
| 790 |
\colorlet{karnaughmapColor}{#1}} |
| 791 |
% \end{macrocode} |
| 792 |
% |
| 793 |
% Define the shifts. |
| 794 |
% \begin{macrocode} |
| 795 |
\define@cmdkeys{karnaughmap}{xshift,yshift}[0] |
| 796 |
% \end{macrocode} |
| 797 |
% |
| 798 |
% \paragraph{Set Key Defaults} |
| 799 |
% The default is a map with full information, |
| 800 |
% i.e. binary and variable labels as well as decimal indices. |
| 801 |
% The zeros are omitted by default.\\ |
| 802 |
% |
| 803 |
% \begin{macro}{\setkarnaughmap} |
| 804 |
% Simple interface function. |
| 805 |
% \begin{macrocode} |
| 806 |
\newcommand{\setkarnaughmap}[1][]{% |
| 807 |
\ifthenelse{\equal{#1}{}}{% |
| 808 |
% \end{macrocode} |
| 809 |
% |
| 810 |
% Change the default behavior by uncommenting the specific key. |
| 811 |
% \begin{macrocode} |
| 812 |
\setkeys{karnaughmap}{% |
| 813 |
% \end{macrocode} |
| 814 |
% omitones, |
| 815 |
% omitdontcares, |
| 816 |
% omitbinaries, |
| 817 |
% omitvariables, |
| 818 |
% omitidx, |
| 819 |
% binaryidx |
| 820 |
% \begin{macrocode} |
| 821 |
omitzeros, omitnegated} |
| 822 |
% \end{macrocode} |
| 823 |
% |
| 824 |
% The key-definition defaults are assigned here. |
| 825 |
% See the definition of the keys above for the defaults. |
| 826 |
% \begin{macrocode} |
| 827 |
\setkeys{karnaughmap}{defaultmap, function, variables, dontcare, color, draw, labelcolor, xshift, yshift} |
| 828 |
% \end{macrocode} |
| 829 |
% |
| 830 |
% If the optional input is provided set the keys accordingly. |
| 831 |
% \begin{macrocode} |
| 832 |
}{ |
| 833 |
\setkeys{karnaughmap}{#1} |
| 834 |
}} |
| 835 |
% \end{macrocode} |
| 836 |
% \end{macro} |
| 837 |
% |
| 838 |
% Assign the defaults during style file call. |
| 839 |
% \begin{macrocode} |
| 840 |
\setkarnaughmap |
| 841 |
% \end{macrocode} |
| 842 |
% |
| 843 |
% |
| 844 |
% |
| 845 |
% \subsection{Auxiliary Functions}% \iffalse TODO: SUBSEC:Auxiliary Functions \fi |
| 846 |
% These function are called by the main function to facilitate code execution. |
| 847 |
% |
| 848 |
% \begin{macro}{\karnaughmapPrintIndex} |
| 849 |
% |\karnaughmapPrintIndex|\oarg{numBits} |
| 850 |
% |
| 851 |
% This macro typesets the indices inside the cells. |
| 852 |
% If the switch |binaryidx| is true binary instead of decimal indices are typeset. |
| 853 |
% The number provided as optional argument is used to determine the number of bits used. |
| 854 |
% |
| 855 |
% Every time the macro is called, it prints the counter value |
| 856 |
% of counter |karnaughmapIdxCounter| and increments the counter thereafter. |
| 857 |
% |
| 858 |
% The size of the indices is very small (scriptsize). |
| 859 |
% \begin{macrocode} |
| 860 |
\newcommand{\karnaughmapPrintIndex}[1][4]{% |
| 861 |
\scriptsize% |
| 862 |
\ifKV@karnaughmap@binaryidx |
| 863 |
% \end{macrocode} |
| 864 |
% |
| 865 |
% Typeset binary indices. |
| 866 |
% \begin{macrocode} |
| 867 |
\ifthenelse{\equal{#1}{2}}{% |
| 868 |
\ifcase\value{karnaughmapIdxCounter}% |
| 869 |
00\or 01\or 10\or 11 |
| 870 |
\fi |
| 871 |
}{}% |
| 872 |
\ifthenelse{\equal{#1}{3}}{% |
| 873 |
\ifcase\value{karnaughmapIdxCounter}% |
| 874 |
000\or 001\or 010\or 011\or 100\or 101\or 110\or 111 |
| 875 |
\fi |
| 876 |
}{}% |
| 877 |
\ifthenelse{\equal{#1}{4}}{% |
| 878 |
\ifcase\value{karnaughmapIdxCounter}% |
| 879 |
0000\or 0001\or 0010\or 0011\or 0100\or 0101\or 0110\or 0111\or |
| 880 |
1000\or 1001\or 1010\or 1011\or 1100\or 1101\or 1110\or 1111 |
| 881 |
\fi |
| 882 |
}{}% |
| 883 |
\else |
| 884 |
% \end{macrocode} |
| 885 |
% |
| 886 |
% Typeset decimal indices. |
| 887 |
% \begin{macrocode} |
| 888 |
$\thekarnaughmapIdxCounter$% |
| 889 |
\fi |
| 890 |
\stepcounter{karnaughmapIdxCounter}% |
| 891 |
} |
| 892 |
% \end{macrocode} |
| 893 |
% \end{macro} |
| 894 |
% |
| 895 |
% \begin{macro}{\karnaughmapPrintValue} |
| 896 |
% |\karnaughmapPrintValue|\marg{inputstring} |
| 897 |
% |
| 898 |
% This macro typesets the entries of the Karnaugh map. |
| 899 |
% Every time the macro is called, it increments the counter |karnaughmapStrCounter| |
| 900 |
% and prints the character at position of the counter value of its mandatory input. |
| 901 |
% \begin{macrocode} |
| 902 |
\newcommand{\karnaughmapPrintValue}[2][]{% |
| 903 |
\stepcounter{karnaughmapStrCounter}% |
| 904 |
\StrChar{#2}{\thekarnaughmapStrCounter}} |
| 905 |
% \end{macrocode} |
| 906 |
% \end{macro} |
| 907 |
% |
| 908 |
% \begin{macro}{\karnaughmapPrintCellContents} |
| 909 |
% |\karnaughmapPrintCellContents|\oarg{node-position}\marg{x-offset}\marg{y-offset}\\ |
| 910 |
% \marg{size}\marg{rowsize}\marg{function} |
| 911 |
% |
| 912 |
% This macro is used to provide the positions of the cells of the map, |
| 913 |
% as they are not straight forward (e.g. order is 0-1-3-2 for first column of 4x4 maps). |
| 914 |
% It takes 5 mandatory and one optional arguments as specified above. |
| 915 |
% |
| 916 |
% By default, it evaluates |function| as contents of a node at the top left |
| 917 |
% of each cell of a Karnaugh map of size |size| with |rowsize| rows. |
| 918 |
% By providing the bias (x- and y-offset), the provided point is shifted accordingly. |
| 919 |
% The alignment of the node is controlled by the optional argument. |
| 920 |
% \begin{macrocode} |
| 921 |
\newcommand{\karnaughmapPrintCellContents}[6][]{% |
| 922 |
% \end{macrocode} |
| 923 |
% If map is 2x2, the order is pretty simple:\\ |
| 924 |
% 0 2 \\ |
| 925 |
% 1 3 |
| 926 |
% \begin{macrocode} |
| 927 |
\ifthenelse{\equal{#4}{4}}{% |
| 928 |
\def\karnaughmapPCCColumnSpecifier{++( 0,-1) node[#1] {#6}}% |
| 929 |
\path (0, #5) |
| 930 |
++(#2,#3) node[#1] {#6} |
| 931 |
\karnaughmapPCCColumnSpecifier |
| 932 |
++(+1,+1) node[#1] {#6} |
| 933 |
\karnaughmapPCCColumnSpecifier |
| 934 |
; |
| 935 |
}{} |
| 936 |
% \end{macrocode} |
| 937 |
% If map is 2x4, the order is more complex:\\ |
| 938 |
% 0 2 6 4 \\ |
| 939 |
% 1 3 7 5 |
| 940 |
% \begin{macrocode} |
| 941 |
\ifthenelse{\equal{#4}{8}}{% |
| 942 |
\def\karnaughmapPCCColumnSpecifier{++( 0,-1) node[#1] {#6}}% |
| 943 |
\path (0, #5) |
| 944 |
++(#2,#3) node[#1] {#6} |
| 945 |
\karnaughmapPCCColumnSpecifier |
| 946 |
++(+1,+1) node[#1] {#6} |
| 947 |
\karnaughmapPCCColumnSpecifier |
| 948 |
++(+2,+1) node[#1] {#6} |
| 949 |
\karnaughmapPCCColumnSpecifier |
| 950 |
++(-1,+1) node[#1] {#6} |
| 951 |
\karnaughmapPCCColumnSpecifier |
| 952 |
; |
| 953 |
}{} |
| 954 |
% \end{macrocode} |
| 955 |
% If map is 4x4, the same ordering as before is present in both x- and y-direction:\\ |
| 956 |
% 0 4 12 8 \\ |
| 957 |
% 1 5 13 9 \\ |
| 958 |
% 3 7 15 11 \\ |
| 959 |
% 2 6 14 10 |
| 960 |
% \begin{macrocode} |
| 961 |
\ifthenelse{\equal{#4}{16}}{% |
| 962 |
\def\karnaughmapPCCColumnSpecifier{% |
| 963 |
++( 0,-1) node[#1] {#6} |
| 964 |
++( 0,-2) node[#1] {#6} |
| 965 |
++( 0,+1) node[#1] {#6} |
| 966 |
}% |
| 967 |
\path (0, #5) |
| 968 |
++(#2,#3) node[#1] {#6} |
| 969 |
\karnaughmapPCCColumnSpecifier |
| 970 |
++(+1,+2) node[#1] {#6} |
| 971 |
\karnaughmapPCCColumnSpecifier |
| 972 |
++(+2,+2) node[#1] {#6} |
| 973 |
\karnaughmapPCCColumnSpecifier |
| 974 |
++(-1,+2) node[#1] {#6} |
| 975 |
\karnaughmapPCCColumnSpecifier |
| 976 |
; |
| 977 |
}{} |
| 978 |
% \end{macrocode} |
| 979 |
% |
| 980 |
% If map is 4x8, the ordering as before has to be extended in x-direction, |
| 981 |
% but from the middle in reverse order:\\ |
| 982 |
% 0 4 12 8 24 28 20 16 \\ |
| 983 |
% 1 5 13 9 25 29 21 17 \\ |
| 984 |
% 3 7 15 11 27 31 23 29 \\ |
| 985 |
% 2 6 14 10 26 30 22 18 |
| 986 |
% \begin{macrocode} |
| 987 |
\ifthenelse{\equal{#4}{32}}{% |
| 988 |
\def\karnaughmapPCCColumnSpecifier{% |
| 989 |
++( 0,-1) node[#1] {#6} |
| 990 |
++( 0,-2) node[#1] {#6} |
| 991 |
++( 0,+1) node[#1] {#6} |
| 992 |
}% |
| 993 |
\path (0, #5) |
| 994 |
++(#2,#3) node[#1] {#6} |
| 995 |
\karnaughmapPCCColumnSpecifier |
| 996 |
++(+1,+2) node[#1] {#6} |
| 997 |
\karnaughmapPCCColumnSpecifier |
| 998 |
++(+2,+2) node[#1] {#6} |
| 999 |
\karnaughmapPCCColumnSpecifier |
| 1000 |
++(-1,+2) node[#1] {#6} |
| 1001 |
\karnaughmapPCCColumnSpecifier |
| 1002 |
++(+5,+2) node[#1] {#6} |
| 1003 |
\karnaughmapPCCColumnSpecifier |
| 1004 |
++(-1,+2) node[#1] {#6} |
| 1005 |
\karnaughmapPCCColumnSpecifier |
| 1006 |
++(-2,+2) node[#1] {#6} |
| 1007 |
\karnaughmapPCCColumnSpecifier |
| 1008 |
++(+1,+2) node[#1] {#6} |
| 1009 |
\karnaughmapPCCColumnSpecifier |
| 1010 |
; |
| 1011 |
}{} |
| 1012 |
% \end{macrocode} |
| 1013 |
% |
| 1014 |
% If map is 8x8, the ordering as before has to be extended in y-direction, too.\\ |
| 1015 |
% 0 8 24 16 48 56 40 32 \\ |
| 1016 |
% 1 9 25 17 49 57 41 33 \\ |
| 1017 |
% 3 11 27 19 51 59 43 35 \\ |
| 1018 |
% 2 10 26 18 50 58 42 34 \\ |
| 1019 |
% 6 14 30 22 54 62 46 38 \\ |
| 1020 |
% 7 15 31 23 55 63 47 39 \\ |
| 1021 |
% 5 13 29 21 53 61 45 37 \\ |
| 1022 |
% 4 12 28 20 52 60 44 36 |
| 1023 |
% \begin{macrocode} |
| 1024 |
\ifthenelse{\equal{#4}{64}}{% |
| 1025 |
\def\karnaughmapPCCColumnSpecifier{% |
| 1026 |
++( 0,-1) node[#1] {#6} |
| 1027 |
++( 0,-2) node[#1] {#6} |
| 1028 |
++( 0,+1) node[#1] {#6} |
| 1029 |
++( 0,-5) node[#1] {#6} |
| 1030 |
++( 0,+1) node[#1] {#6} |
| 1031 |
++( 0,+2) node[#1] {#6} |
| 1032 |
++( 0,-1) node[#1] {#6} |
| 1033 |
}% |
| 1034 |
\path (0, #5) |
| 1035 |
++(#2,#3) node[#1] {#6} |
| 1036 |
\karnaughmapPCCColumnSpecifier |
| 1037 |
++(+1,+5) node[#1] {#6} |
| 1038 |
\karnaughmapPCCColumnSpecifier |
| 1039 |
++(+2,+5) node[#1] {#6} |
| 1040 |
\karnaughmapPCCColumnSpecifier |
| 1041 |
++(-1,+5) node[#1] {#6} |
| 1042 |
\karnaughmapPCCColumnSpecifier |
| 1043 |
++(+5,+5) node[#1] {#6} |
| 1044 |
\karnaughmapPCCColumnSpecifier |
| 1045 |
++(-1,+5) node[#1] {#6} |
| 1046 |
\karnaughmapPCCColumnSpecifier |
| 1047 |
++(-2,+5) node[#1] {#6} |
| 1048 |
\karnaughmapPCCColumnSpecifier |
| 1049 |
++(+1,+5) node[#1] {#6} |
| 1050 |
\karnaughmapPCCColumnSpecifier |
| 1051 |
; |
| 1052 |
}{} |
| 1053 |
% \end{macrocode} |
| 1054 |
% |
| 1055 |
% If map is 8x16, the ordering is:\\ |
| 1056 |
% 0 8 24 16 48 56 40 32 \\ |
| 1057 |
% 1 9 25 17 49 57 41 33 \\ |
| 1058 |
% 3 11 27 19 51 59 43 35 \\ |
| 1059 |
% 2 10 26 18 50 58 42 34 \\ |
| 1060 |
% 6 14 30 22 54 62 46 38 \\ |
| 1061 |
% 7 15 31 23 55 63 47 39 \\ |
| 1062 |
% 5 13 29 21 53 61 45 37 \\ |
| 1063 |
% 4 12 28 20 52 60 44 36 |
| 1064 |
% \begin{macrocode} |
| 1065 |
\ifthenelse{\equal{#4}{128}}{% |
| 1066 |
\def\karnaughmapPCCColumnSpecifier{% |
| 1067 |
++( 0,-1) node[#1] {#6} |
| 1068 |
++( 0,-2) node[#1] {#6} |
| 1069 |
++( 0,+1) node[#1] {#6} |
| 1070 |
++( 0,-5) node[#1] {#6} |
| 1071 |
++( 0,+1) node[#1] {#6} |
| 1072 |
++( 0,+2) node[#1] {#6} |
| 1073 |
++( 0,-1) node[#1] {#6} |
| 1074 |
}% |
| 1075 |
\path (0, #5) |
| 1076 |
++(#2,#3) node[#1] {#6} |
| 1077 |
\karnaughmapPCCColumnSpecifier |
| 1078 |
++(+1,+5) node[#1] {#6} |
| 1079 |
\karnaughmapPCCColumnSpecifier |
| 1080 |
++(+2,+5) node[#1] {#6} |
| 1081 |
\karnaughmapPCCColumnSpecifier |
| 1082 |
++(-1,+5) node[#1] {#6} |
| 1083 |
\karnaughmapPCCColumnSpecifier |
| 1084 |
++(+5,+5) node[#1] {#6} |
| 1085 |
\karnaughmapPCCColumnSpecifier |
| 1086 |
++(-1,+5) node[#1] {#6} |
| 1087 |
\karnaughmapPCCColumnSpecifier |
| 1088 |
++(-2,+5) node[#1] {#6} |
| 1089 |
\karnaughmapPCCColumnSpecifier |
| 1090 |
++(+1,+5) node[#1] {#6} |
| 1091 |
\karnaughmapPCCColumnSpecifier |
| 1092 |
++(+10,+5) node[#1] {#6} |
| 1093 |
\karnaughmapPCCColumnSpecifier |
| 1094 |
++(-1,+5) node[#1] {#6} |
| 1095 |
\karnaughmapPCCColumnSpecifier |
| 1096 |
++(-2,+5) node[#1] {#6} |
| 1097 |
\karnaughmapPCCColumnSpecifier |
| 1098 |
++(+1,+5) node[#1] {#6} |
| 1099 |
\karnaughmapPCCColumnSpecifier |
| 1100 |
++(-5,+5) node[#1] {#6} |
| 1101 |
\karnaughmapPCCColumnSpecifier |
| 1102 |
++(+1,+5) node[#1] {#6} |
| 1103 |
\karnaughmapPCCColumnSpecifier |
| 1104 |
++(+2,+5) node[#1] {#6} |
| 1105 |
\karnaughmapPCCColumnSpecifier |
| 1106 |
++(-1,+5) node[#1] {#6} |
| 1107 |
\karnaughmapPCCColumnSpecifier |
| 1108 |
; |
| 1109 |
}{} |
| 1110 |
% \end{macrocode} |
| 1111 |
% |
| 1112 |
% If map is 16x16, the ordering is:\\ |
| 1113 |
% 0 8 24 16 48 56 40 32 \\ |
| 1114 |
% 1 9 25 17 49 57 41 33 \\ |
| 1115 |
% 3 11 27 19 51 59 43 35 \\ |
| 1116 |
% 2 10 26 18 50 58 42 34 \\ |
| 1117 |
% 6 14 30 22 54 62 46 38 \\ |
| 1118 |
% 7 15 31 23 55 63 47 39 \\ |
| 1119 |
% 5 13 29 21 53 61 45 37 \\ |
| 1120 |
% 4 12 28 20 52 60 44 36 |
| 1121 |
% \begin{macrocode} |
| 1122 |
\ifthenelse{\equal{#4}{256}}{% |
| 1123 |
\def\karnaughmapPCCColumnSpecifier{% |
| 1124 |
++( 0,-1) node[#1] {#6} |
| 1125 |
++( 0,-2) node[#1] {#6} |
| 1126 |
++( 0,+1) node[#1] {#6} |
| 1127 |
++( 0,-5) node[#1] {#6} |
| 1128 |
++( 0,+1) node[#1] {#6} |
| 1129 |
++( 0,+2) node[#1] {#6} |
| 1130 |
++( 0,-1) node[#1] {#6} |
| 1131 |
|
| 1132 |
++( 0,-10) node[#1] {#6} |
| 1133 |
++( 0,+1) node[#1] {#6} |
| 1134 |
++( 0,+2) node[#1] {#6} |
| 1135 |
++( 0,-1) node[#1] {#6} |
| 1136 |
++( 0,+5) node[#1] {#6} |
| 1137 |
++( 0,-1) node[#1] {#6} |
| 1138 |
++( 0,-2) node[#1] {#6} |
| 1139 |
++( 0,+1) node[#1] {#6} |
| 1140 |
}% |
| 1141 |
\path (0, #5) |
| 1142 |
++(#2,#3) node[#1] {#6} |
| 1143 |
\karnaughmapPCCColumnSpecifier |
| 1144 |
++(+1,+10) node[#1] {#6} |
| 1145 |
\karnaughmapPCCColumnSpecifier |
| 1146 |
++(+2,+10) node[#1] {#6} |
| 1147 |
\karnaughmapPCCColumnSpecifier |
| 1148 |
++(-1,+10) node[#1] {#6} |
| 1149 |
\karnaughmapPCCColumnSpecifier |
| 1150 |
++(+5,+10) node[#1] {#6} |
| 1151 |
\karnaughmapPCCColumnSpecifier |
| 1152 |
++(-1,+10) node[#1] {#6} |
| 1153 |
\karnaughmapPCCColumnSpecifier |
| 1154 |
++(-2,+10) node[#1] {#6} |
| 1155 |
\karnaughmapPCCColumnSpecifier |
| 1156 |
++(+1,+10) node[#1] {#6} |
| 1157 |
\karnaughmapPCCColumnSpecifier |
| 1158 |
++(+10,+10) node[#1] {#6} |
| 1159 |
\karnaughmapPCCColumnSpecifier |
| 1160 |
++(-1,+10) node[#1] {#6} |
| 1161 |
\karnaughmapPCCColumnSpecifier |
| 1162 |
++(-2,+10) node[#1] {#6} |
| 1163 |
\karnaughmapPCCColumnSpecifier |
| 1164 |
++(+1,+10) node[#1] {#6} |
| 1165 |
\karnaughmapPCCColumnSpecifier |
| 1166 |
++(-5,+10) node[#1] {#6} |
| 1167 |
\karnaughmapPCCColumnSpecifier |
| 1168 |
++(+1,+10) node[#1] {#6} |
| 1169 |
\karnaughmapPCCColumnSpecifier |
| 1170 |
++(+2,+10) node[#1] {#6} |
| 1171 |
\karnaughmapPCCColumnSpecifier |
| 1172 |
++(-1,+10) node[#1] {#6} |
| 1173 |
\karnaughmapPCCColumnSpecifier |
| 1174 |
; |
| 1175 |
}{} |
| 1176 |
} |
| 1177 |
% \end{macrocode} |
| 1178 |
% \end{macro} |
| 1179 |
% |
| 1180 |
|
| 1181 |
% \begin{macro}{\karnaughmapHighlightField} |
| 1182 |
% Macro that defines the highlighting. |
| 1183 |
% |\karnaughmapHighlightField|\oarg{key=value}\marg{coordinates}\marg{color name} |
| 1184 |
% |
| 1185 |
% |
| 1186 |
% \end{macro} |
| 1187 |
% \begin{macrocode} |
| 1188 |
\newcommand{\karnaughmapHighlightField}[3][]{% |
| 1189 |
\ifKV@karnaughmap@fill |
| 1190 |
\path[fill=#3,opacity=\cmdKV@karnaughmap@opacity,#1] (#2) rectangle ++(1,1);% |
| 1191 |
\fi |
| 1192 |
\ifKV@karnaughmap@outline |
| 1193 |
\draw[#3,#1] (#2) ++ (0.1,0.1) rectangle ++(0.8,0.8);% |
| 1194 |
\fi |
| 1195 |
} |
| 1196 |
% \end{macrocode} |
| 1197 |
% \begin{macro}{\karnaughmapShadeMapfieldTWO} |
| 1198 |
% Macro to shade square two input karnaugh map fields.\\ |
| 1199 |
% |\karnaughmapShadeMapfieldTWO|\oarg{key=value}\marg{decimal field number}\marg{color name} |
| 1200 |
% |
| 1201 |
% Optional macro is used as key-val interface for option processing, |
| 1202 |
% mandatory ones specify the color used for highlighting and |
| 1203 |
% the fields that are to be highlighted as decimal integers from $1$ to $2^{\textrm{map size}}-1$. |
| 1204 |
% \begin{macrocode} |
| 1205 |
\newcommand{\karnaughmapShadeMapfieldTWO}[3][]{% |
| 1206 |
\begin{scope}[scale=1] |
| 1207 |
\ifthenelse{\equal{#2}{0}}{\karnaughmapHighlightField[#1]{0,1}{#3}}{}% |
| 1208 |
\ifthenelse{\equal{#2}{1}}{\karnaughmapHighlightField[#1]{0,0}{#3}}{}% |
| 1209 |
\ifthenelse{\equal{#2}{2}}{\karnaughmapHighlightField[#1]{1,1}{#3}}{}% |
| 1210 |
\ifthenelse{\equal{#2}{3}}{\karnaughmapHighlightField[#1]{1,0}{#3}}{}% |
| 1211 |
\end{scope} |
| 1212 |
} |
| 1213 |
% \end{macrocode} |
| 1214 |
% \end{macro} |
| 1215 |
% |
| 1216 |
% \begin{macro}{\karnaughmapShadeMapfieldTHREE} |
| 1217 |
% Macro to shade three input karnaugh map fields.\\ |
| 1218 |
% |\karnaughmapShadeMapfieldTHREE|\oarg{key=value}\marg{decimal field number}\marg{color name} |
| 1219 |
% |
| 1220 |
% Optional macro is used as key-val interface for option processing, |
| 1221 |
% mandatory ones specify the color used for highlighting and |
| 1222 |
% the fields that are to be highlighted as decimal integers from $1$ to $2^{\textrm{map size}}-1$. |
| 1223 |
% \begin{macrocode} |
| 1224 |
\newcommand{\karnaughmapShadeMapfieldTHREE}[3][]{% |
| 1225 |
\begin{scope}[scale=1] |
| 1226 |
\ifthenelse{\equal{#2}{0}}{\karnaughmapHighlightField[#1]{0,1}{#3}}{}% |
| 1227 |
\ifthenelse{\equal{#2}{1}}{\karnaughmapHighlightField[#1]{0,0}{#3}}{}% |
| 1228 |
\ifthenelse{\equal{#2}{2}}{\karnaughmapHighlightField[#1]{1,1}{#3}}{}% |
| 1229 |
\ifthenelse{\equal{#2}{3}}{\karnaughmapHighlightField[#1]{1,0}{#3}}{}% |
| 1230 |
\ifthenelse{\equal{#2}{4}}{\karnaughmapHighlightField[#1]{3,1}{#3}}{}% |
| 1231 |
\ifthenelse{\equal{#2}{5}}{\karnaughmapHighlightField[#1]{3,0}{#3}}{}% |
| 1232 |
\ifthenelse{\equal{#2}{6}}{\karnaughmapHighlightField[#1]{2,1}{#3}}{}% |
| 1233 |
\ifthenelse{\equal{#2}{7}}{\karnaughmapHighlightField[#1]{2,0}{#3}}{}% |
| 1234 |
\end{scope} |
| 1235 |
} |
| 1236 |
% \end{macrocode} |
| 1237 |
% \end{macro} |
| 1238 |
% |
| 1239 |
% \begin{macro}{\karnaughmapShadeMapfieldFOUR} |
| 1240 |
% Macro to shade square four input karnaugh map fields.\\ |
| 1241 |
% |\karnaughmapShadeMapfieldFOUR|\oarg{key=value}\marg{decimal field number}\marg{color name} |
| 1242 |
% |
| 1243 |
% Optional macro is used as key-val interface for option processing, |
| 1244 |
% mandatory ones specify the color used for highlighting and |
| 1245 |
% the fields that are to be highlighted as decimal integers from $1$ to $2^{\textrm{map size}}-1$. |
| 1246 |
% \begin{macrocode} |
| 1247 |
\newcommand{\karnaughmapShadeMapfieldFOUR}[3][]{% |
| 1248 |
\begin{scope}[scale=1]% |
| 1249 |
% \end{macrocode} |
| 1250 |
% 1st column |
| 1251 |
% \begin{macrocode} |
| 1252 |
\ifthenelse{\equal{#2}{0}}{\karnaughmapHighlightField[#1]{0,3}{#3}}{}% |
| 1253 |
\ifthenelse{\equal{#2}{1}}{\karnaughmapHighlightField[#1]{0,2}{#3}}{}% |
| 1254 |
\ifthenelse{\equal{#2}{2}}{\karnaughmapHighlightField[#1]{0,0}{#3}}{}% |
| 1255 |
\ifthenelse{\equal{#2}{3}}{\karnaughmapHighlightField[#1]{0,1}{#3}}{}% |
| 1256 |
% \end{macrocode} |
| 1257 |
% 2nd column |
| 1258 |
% \begin{macrocode} |
| 1259 |
\ifthenelse{\equal{#2}{4}}{\karnaughmapHighlightField[#1]{1,3}{#3}}{}% |
| 1260 |
\ifthenelse{\equal{#2}{5}}{\karnaughmapHighlightField[#1]{1,2}{#3}}{}% |
| 1261 |
\ifthenelse{\equal{#2}{6}}{\karnaughmapHighlightField[#1]{1,0}{#3}}{}% |
| 1262 |
\ifthenelse{\equal{#2}{7}}{\karnaughmapHighlightField[#1]{1,1}{#3}}{}% |
| 1263 |
% \end{macrocode} |
| 1264 |
% 4th column |
| 1265 |
% \begin{macrocode} |
| 1266 |
\ifthenelse{\equal{#2}{8}}{\karnaughmapHighlightField[#1]{3,3}{#3}}{}% |
| 1267 |
\ifthenelse{\equal{#2}{9}}{\karnaughmapHighlightField[#1]{3,2}{#3}}{}% |
| 1268 |
\ifthenelse{\equal{#2}{a}\OR\equal{#2}{A}}{\karnaughmapHighlightField[#1]{3,0}{#3}}{}% |
| 1269 |
\ifthenelse{\equal{#2}{b}\OR\equal{#2}{B}}{\karnaughmapHighlightField[#1]{3,1}{#3}}{}% |
| 1270 |
% \end{macrocode} |
| 1271 |
% 3rd column |
| 1272 |
% \begin{macrocode} |
| 1273 |
\ifthenelse{\equal{#2}{c}\OR\equal{#2}{C}}{\karnaughmapHighlightField[#1]{2,3}{#3}}{}% |
| 1274 |
\ifthenelse{\equal{#2}{d}\OR\equal{#2}{D}}{\karnaughmapHighlightField[#1]{2,2}{#3}}{}% |
| 1275 |
\ifthenelse{\equal{#2}{e}\OR\equal{#2}{E}}{\karnaughmapHighlightField[#1]{2,0}{#3}}{}% |
| 1276 |
\ifthenelse{\equal{#2}{f}\OR\equal{#2}{F}}{\karnaughmapHighlightField[#1]{2,1}{#3}}{}% |
| 1277 |
\end{scope} |
| 1278 |
} |
| 1279 |
% \end{macrocode} |
| 1280 |
% \end{macro} |
| 1281 |
% |
| 1282 |
% |
| 1283 |
% |
| 1284 |
% \subsection{Main Functions}% \iffalse TODO: SUBSEC:Main Functions \fi |
| 1285 |
% |
| 1286 |
% Here come the main functions to typeset the map |
| 1287 |
% and to mark certain cells (not implemented yet). |
| 1288 |
% |
| 1289 |
% \begin{macro}{\karnaughmap} |
| 1290 |
% The main macro takes one mandatory and one optional argument:\\ |
| 1291 |
% \oarg{key=value}\marg{inputstring}. |
| 1292 |
% |
| 1293 |
% The optional is used as key-val inteface, |
| 1294 |
% the mandatory is empty or holds the entry-pattern (inputstring) |
| 1295 |
% according to the corresponding ordered truth table |
| 1296 |
% of the desired logic function. |
| 1297 |
% \begin{macrocode} |
| 1298 |
\newcommand{\karnaughmap}[2][]{% |
| 1299 |
% \end{macrocode} |
| 1300 |
% |
| 1301 |
% If the optional input is not empty, assign the key-val. |
| 1302 |
% \begin{macrocode} |
| 1303 |
\ifthenelse{\equal{#1}{}}{}{\setkeys{karnaughmap}{#1}} |
| 1304 |
% \end{macrocode} |
| 1305 |
% |
| 1306 |
% For easy access store the mandatory argument as variable |\karnaughmapCellEntries|. |
| 1307 |
% \begin{macrocode} |
| 1308 |
\def\karnaughmapCellEntries{#2}% |
| 1309 |
% \end{macrocode} |
| 1310 |
% |
| 1311 |
% Check length of mandatory argument and store the result in |\karnaughmapSize|. |
| 1312 |
% |
| 1313 |
% If the mandatory argument is empty, |
| 1314 |
% use the default map size provided by the key-val interface (|defaultmap| key). |
| 1315 |
% \begin{macrocode} |
| 1316 |
\ifthenelse{\equal{#2}{}}{% |
| 1317 |
\def\karnaughmapSize{\cmdKV@karnaughmap@defaultmap} |
| 1318 |
}{% |
| 1319 |
% \end{macrocode} |
| 1320 |
% |
| 1321 |
% Else, determine the length of the input string to determine the map size. |
| 1322 |
% |
| 1323 |
% Before calculating the string length, remove any blanks in the input string. |
| 1324 |
% Usage of blanks in the input string can increase readability, |
| 1325 |
% e.g. when groups of four are provided. |
| 1326 |
% \begin{macrocode} |
| 1327 |
\IfSubStr{\karnaughmapCellEntries}{ }{% |
| 1328 |
\StrDel[0]{\karnaughmapCellEntries}{ }[\karnaughmapCellEntries] |
| 1329 |
}{} |
| 1330 |
% \end{macrocode} |
| 1331 |
% |
| 1332 |
% Now, calculate the string length. |
| 1333 |
% This is the old version. |
| 1334 |
% |\StrLen{#2}[\karnaughmapSize]%| |
| 1335 |
% \begin{macrocode} |
| 1336 |
\StrLen{\karnaughmapCellEntries}[\karnaughmapSize]% |
| 1337 |
% \end{macrocode} |
| 1338 |
% |
| 1339 |
% If the input is a scalar number, i.e. it is < 1000 (decimal), |
| 1340 |
% it is treated as number and is used to determine the map size. |
| 1341 |
% In this case adapt the variable |\karnaughmapCellEntries| accordingly. |
| 1342 |
% |\ifthenelse{\equal{\karnaughmapSize}{1}}{%| |
| 1343 |
% \begin{macrocode} |
| 1344 |
\ifthenelse{\karnaughmapSize < 4}{% |
| 1345 |
\def\karnaughmapSize{#2}\def\karnaughmapCellEntries{}}{}% |
| 1346 |
} |
| 1347 |
% \end{macrocode} |
| 1348 |
% |
| 1349 |
% |
| 1350 |
% Parse the input string and omit printing of '0', '1', or '*' entries |
| 1351 |
% if the switches say so. |
| 1352 |
% \begin{macrocode} |
| 1353 |
\ifKV@karnaughmap@omitzeros |
| 1354 |
\StrSubstitute[0]{\karnaughmapCellEntries}{0}{ }[\karnaughmapCellEntries] |
| 1355 |
\fi |
| 1356 |
\ifKV@karnaughmap@omitones |
| 1357 |
\StrSubstitute[0]{\karnaughmapCellEntries}{1}{ }[\karnaughmapCellEntries] |
| 1358 |
\fi |
| 1359 |
\ifKV@karnaughmap@omitdontcares |
| 1360 |
\StrSubstitute[0]{\karnaughmapCellEntries}{\cmdKV@karnaughmap@dontcare}{ }[\karnaughmapCellEntries] |
| 1361 |
\fi |
| 1362 |
% \end{macrocode} |
| 1363 |
% |
| 1364 |
% Initialize internal counters. |
| 1365 |
% \begin{macrocode} |
| 1366 |
\setcounter{karnaughmapIdxCounter}{0} |
| 1367 |
\setcounter{karnaughmapStrCounter}{0} |
| 1368 |
% \end{macrocode} |
| 1369 |
% |
| 1370 |
% Extract the map variables and alloc row and col sizes. |
| 1371 |
% In addition, store the number of variables in variable |\karnaughmapNumVar|. |
| 1372 |
% \begin{macrocode} |
| 1373 |
\ifthenelse{\karnaughmapSize = 4}{% |
| 1374 |
\StrChar{\cmdKV@karnaughmap@variables}{1}[\karnaughmapVarLabelA] |
| 1375 |
\def\karnaughmapVarLabelB{} |
| 1376 |
\StrChar{\cmdKV@karnaughmap@variables}{2}[\karnaughmapVarLabelC] |
| 1377 |
\def\karnaughmapVarLabelD{} |
| 1378 |
\def\karnaughmapNumRow{2} |
| 1379 |
\def\karnaughmapNumCol{2} |
| 1380 |
\def\karnaughmapNumVar{2} |
| 1381 |
}{} |
| 1382 |
\ifthenelse{\karnaughmapSize = 8}{% |
| 1383 |
\StrChar{\cmdKV@karnaughmap@variables}{1}[\karnaughmapVarLabelA] |
| 1384 |
\StrChar{\cmdKV@karnaughmap@variables}{2}[\karnaughmapVarLabelB] |
| 1385 |
\StrChar{\cmdKV@karnaughmap@variables}{3}[\karnaughmapVarLabelC] |
| 1386 |
\def\karnaughmapVarLabelD{} |
| 1387 |
\def\karnaughmapNumRow{2} |
| 1388 |
\def\karnaughmapNumCol{4} |
| 1389 |
\def\karnaughmapNumVar{3} |
| 1390 |
}{} |
| 1391 |
\ifthenelse{\karnaughmapSize = 16}{% |
| 1392 |
\StrChar{\cmdKV@karnaughmap@variables}{1}[\karnaughmapVarLabelA] |
| 1393 |
\StrChar{\cmdKV@karnaughmap@variables}{2}[\karnaughmapVarLabelB] |
| 1394 |
\StrChar{\cmdKV@karnaughmap@variables}{3}[\karnaughmapVarLabelC] |
| 1395 |
\StrChar{\cmdKV@karnaughmap@variables}{4}[\karnaughmapVarLabelD] |
| 1396 |
\def\karnaughmapNumRow{4} |
| 1397 |
\def\karnaughmapNumCol{4} |
| 1398 |
\def\karnaughmapNumVar{4} |
| 1399 |
}{} |
| 1400 |
% \end{macrocode} |
| 1401 |
% |
| 1402 |
% The bigger karnaugh maps, i.e. 32, 64, 128 and 512, lack finer control possibilities. |
| 1403 |
% Rather, the variables are set such that they can be used as map descriptors, |
| 1404 |
% but not for some fancy stuff like indicating the variable blocks. |
| 1405 |
% This means, that we force to omit printing of the the indices (omitidx=true) |
| 1406 |
% and we force to omit printing of the variables.\\ |
| 1407 |
% For the variable macros to work, we set the B and D macro to empty |
| 1408 |
% and put the remaining variables in the A for column and C for row variables. |
| 1409 |
% \begin{macrocode} |
| 1410 |
\ifthenelse{\karnaughmapSize = 32}{% |
| 1411 |
\setkeys{karnaughmap}{omitidx=true, omitvariables=true} |
| 1412 |
\StrMid{\cmdKV@karnaughmap@variables}{1}{3}[\karnaughmapVarLabelA] |
| 1413 |
\def\karnaughmapVarLabelB{} |
| 1414 |
\StrMid{\cmdKV@karnaughmap@variables}{4}{5}[\karnaughmapVarLabelC] |
| 1415 |
\def\karnaughmapVarLabelD{} |
| 1416 |
\def\karnaughmapNumRow{4} |
| 1417 |
\def\karnaughmapNumCol{8} |
| 1418 |
\def\karnaughmapNumVar{5} |
| 1419 |
}{} |
| 1420 |
\ifthenelse{\karnaughmapSize = 64}{% |
| 1421 |
\setkeys{karnaughmap}{omitidx=true, omitvariables=true} |
| 1422 |
\StrMid{\cmdKV@karnaughmap@variables}{1}{3}[\karnaughmapVarLabelA] |
| 1423 |
\def\karnaughmapVarLabelB{} |
| 1424 |
\StrMid{\cmdKV@karnaughmap@variables}{4}{6}[\karnaughmapVarLabelC] |
| 1425 |
\def\karnaughmapVarLabelD{} |
| 1426 |
\def\karnaughmapNumRow{8} |
| 1427 |
\def\karnaughmapNumCol{8} |
| 1428 |
\def\karnaughmapNumVar{6} |
| 1429 |
}{} |
| 1430 |
\ifthenelse{\karnaughmapSize = 128}{% |
| 1431 |
\setkeys{karnaughmap}{omitidx=true, omitvariables=true} |
| 1432 |
\StrMid{\cmdKV@karnaughmap@variables}{1}{4}[\karnaughmapVarLabelA] |
| 1433 |
\def\karnaughmapVarLabelB{} |
| 1434 |
\StrMid{\cmdKV@karnaughmap@variables}{5}{7}[\karnaughmapVarLabelC] |
| 1435 |
\def\karnaughmapVarLabelD{} |
| 1436 |
\def\karnaughmapNumRow{8} |
| 1437 |
\def\karnaughmapNumCol{16} |
| 1438 |
\def\karnaughmapNumVar{7} |
| 1439 |
}{} |
| 1440 |
\ifthenelse{\karnaughmapSize = 256}{% |
| 1441 |
\setkeys{karnaughmap}{omitidx=true, omitvariables=true} |
| 1442 |
\StrMid{\cmdKV@karnaughmap@variables}{1}{4}[\karnaughmapVarLabelA] |
| 1443 |
\def\karnaughmapVarLabelB{} |
| 1444 |
\StrMid{\cmdKV@karnaughmap@variables}{5}{8}[\karnaughmapVarLabelC] |
| 1445 |
\def\karnaughmapVarLabelD{} |
| 1446 |
\def\karnaughmapNumRow{16} |
| 1447 |
\def\karnaughmapNumCol{16} |
| 1448 |
\def\karnaughmapNumVar{8} |
| 1449 |
}{} |
| 1450 |
% \end{macrocode} |
| 1451 |
% |
| 1452 |
% \paragraph{Basic table} Typeset the basic table. |
| 1453 |
% |
| 1454 |
% Embed the draw commands in a scope environment for style control. |
| 1455 |
% \begin{macrocode} |
| 1456 |
\begin{scope}[xshift=\cmdKV@karnaughmap@xshift, |
| 1457 |
yshift=\cmdKV@karnaughmap@yshift, |
| 1458 |
color=karnaughmapColor, |
| 1459 |
draw=karnaughmapMapColor ] |
| 1460 |
% \end{macrocode} |
| 1461 |
% |
| 1462 |
% Draw table boundaries. |
| 1463 |
% \begin{macrocode} |
| 1464 |
\draw (0,0) rectangle (\karnaughmapNumCol, \karnaughmapNumRow); |
| 1465 |
% \end{macrocode} |
| 1466 |
% |
| 1467 |
% Draw column seperators. |
| 1468 |
% \begin{macrocode} |
| 1469 |
\foreach \x in {1,2,...,\karnaughmapNumCol} {% |
| 1470 |
\ifthenelse{\equal{\x}{1}}{}{% |
| 1471 |
\draw (\x-1,0) -- ++(0,\karnaughmapNumRow);% |
| 1472 |
}% |
| 1473 |
}% |
| 1474 |
% \end{macrocode} |
| 1475 |
% |
| 1476 |
% Draw row seperators. |
| 1477 |
% \begin{macrocode} |
| 1478 |
\foreach \x in {1,2,...,\karnaughmapNumRow} {% |
| 1479 |
\ifthenelse{\equal{\x}{1}}{}{% |
| 1480 |
\draw (0,\x-1) -- ++(\karnaughmapNumCol,0);% |
| 1481 |
}% |
| 1482 |
}% |
| 1483 |
% \end{macrocode} |
| 1484 |
% |
| 1485 |
% Draw map labels; |
| 1486 |
% Diagonal line and anchor first. |
| 1487 |
% \begin{macrocode} |
| 1488 |
\draw (0,\karnaughmapNumRow) -- ++(-0.4,0.4) coordinate(identifier) |
| 1489 |
-- ++(-0.4,0.4) |
| 1490 |
% \end{macrocode} |
| 1491 |
% |
| 1492 |
% Function label at the top of the map, |
| 1493 |
% if the function label is non-empty the label is followed by a colon. |
| 1494 |
% \begin{macrocode} |
| 1495 |
node[yshift=7.5,xshift=-3.5,right] {% |
| 1496 |
\ifthenelse{\equal{\cmdKV@karnaughmap@function}{}}{}{$\cmdKV@karnaughmap@function\colon$}}; |
| 1497 |
% \end{macrocode} |
| 1498 |
% |
| 1499 |
% Variable label right and below the diagonal. |
| 1500 |
% \begin{macrocode} |
| 1501 |
\path (identifier) node[above right, xshift=-2.5] {$\karnaughmapVarLabelA\karnaughmapVarLabelB$}; |
| 1502 |
\path (identifier) node[below left, yshift=0.5] {$\karnaughmapVarLabelC\karnaughmapVarLabelD$}; |
| 1503 |
% \end{macrocode} |
| 1504 |
% |
| 1505 |
% Typeset binaries if |omitbinaries| switch is false; |
| 1506 |
% \begin{macrocode} |
| 1507 |
\ifKV@karnaughmap@omitbinaries |
| 1508 |
\else |
| 1509 |
% \end{macrocode} |
| 1510 |
% |
| 1511 |
% 2 columns: anchors are above the top row |\karnaughmapNumRow| |
| 1512 |
% and in the middle of the cells at 0.5 and 1.5. |
| 1513 |
% \begin{macrocode} |
| 1514 |
\ifthenelse{\equal{\karnaughmapNumCol}{2}}{% |
| 1515 |
\foreach \pos/\lab in {0.5/0, 1.5/1} {% |
| 1516 |
\path (\pos, \karnaughmapNumRow) node[above] {$\lab$};% |
| 1517 |
}% |
| 1518 |
}{}% |
| 1519 |
% \end{macrocode} |
| 1520 |
% |
| 1521 |
% 4 columns: anchors are above the top row |\karnaughmapNumRow| |
| 1522 |
% and in the middle of the cells at 0.5 ... 3.5. |
| 1523 |
% \begin{macrocode} |
| 1524 |
\ifthenelse{\equal{\karnaughmapNumCol}{4}}{% |
| 1525 |
\foreach \pos/\lab in {0.5/00, 1.5/01, 2.5/11, 3.5/10} {% |
| 1526 |
\path (\pos, \karnaughmapNumRow) node[above] {$\lab$};% |
| 1527 |
}% |
| 1528 |
}{}% |
| 1529 |
% \end{macrocode} |
| 1530 |
% |
| 1531 |
% 8 columns: anchors are above the top row |\karnaughmapNumRow| |
| 1532 |
% and in the middle of the cells at 0.5 ... 7.5. |
| 1533 |
% \begin{macrocode} |
| 1534 |
\ifthenelse{\equal{\karnaughmapNumCol}{8}}{% |
| 1535 |
\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} {% |
| 1536 |
\path (\pos, \karnaughmapNumRow) node[above] {$\lab$};% |
| 1537 |
}% |
| 1538 |
}{}% |
| 1539 |
% \end{macrocode} |
| 1540 |
% |
| 1541 |
% 16 columns: anchors are above the top row |\karnaughmapNumRow| |
| 1542 |
% and in the middle of the cells at 0.5 ... 15.5. |
| 1543 |
% \begin{macrocode} |
| 1544 |
\ifthenelse{\equal{\karnaughmapNumCol}{16}}{% |
| 1545 |
\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, |
| 1546 |
8.5/1100, 9.5/1101,10.5/1111,11.5/1110,12.5/1010,13.5/1011,14.5/1001,15.5/1000} {% |
| 1547 |
\path (\pos, \karnaughmapNumRow) node[above] {$\lab$};% |
| 1548 |
}% |
| 1549 |
}{}% |
| 1550 |
% \end{macrocode} |
| 1551 |
% |
| 1552 |
% 2 rows: anchors are left of the first column with coordinate (0, x) |
| 1553 |
% and in the middle of the cells at 0.5 and 1.5. |
| 1554 |
% \begin{macrocode} |
| 1555 |
\ifthenelse{\equal{\karnaughmapNumRow}{2}}{% |
| 1556 |
\foreach \pos/\lab in {0.5/0, 1.5/1} {% |
| 1557 |
\path (0, \karnaughmapNumRow-\pos) node[left] {$\lab$};% |
| 1558 |
}% |
| 1559 |
}{}% |
| 1560 |
% \end{macrocode} |
| 1561 |
% |
| 1562 |
% 4 rows: anchors are left of the first column with coordinate (0, x) |
| 1563 |
% and in the middle of the cells at 0.5 ... 3.5. |
| 1564 |
% \begin{macrocode} |
| 1565 |
\ifthenelse{\equal{\karnaughmapNumRow}{4}}{% |
| 1566 |
\foreach \pos/\lab in {0.5/00, 1.5/01, 2.5/11, 3.5/10} {% |
| 1567 |
\path (0, \karnaughmapNumRow-\pos) node[left] {$\lab$};% |
| 1568 |
}% |
| 1569 |
}{}% |
| 1570 |
% \end{macrocode} |
| 1571 |
% |
| 1572 |
% 8 rows: anchors are left of the first column with coordinate (0, x) |
| 1573 |
% and in the middle of the cells at 0.5 ... 7.5. |
| 1574 |
% \begin{macrocode} |
| 1575 |
\ifthenelse{\equal{\karnaughmapNumRow}{8}}{% |
| 1576 |
\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} {% |
| 1577 |
\path (-0.125, \karnaughmapNumRow-\pos) node[left] {$\lab$};% |
| 1578 |
}% |
| 1579 |
}{}% |
| 1580 |
% \end{macrocode} |
| 1581 |
% |
| 1582 |
% 16 rows: anchors are left of the first column with coordinate (0, x) |
| 1583 |
% and in the middle of the cells at 0.5 ... 15.5. |
| 1584 |
% \begin{macrocode} |
| 1585 |
\ifthenelse{\equal{\karnaughmapNumRow}{16}}{% |
| 1586 |
\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, |
| 1587 |
8.5/1100, 9.5/1101,10.5/1111,11.5/1110,12.5/1010,13.5/1011,14.5/1001,15.5/1000} {% |
| 1588 |
\path (-0.1875, \karnaughmapNumRow-\pos) node[left] {$\lab$};% |
| 1589 |
}% |
| 1590 |
}{}% |
| 1591 |
\fi |
| 1592 |
% \end{macrocode} |
| 1593 |
% |
| 1594 |
% Typeset binary labels above and left of the map if switch |omitbinaries| is false. |
| 1595 |
% |
| 1596 |
% Set base bias of variable labels; |
| 1597 |
% the top and left bias is modified depending on if the binary labels are set or not. |
| 1598 |
% \begin{macrocode} |
| 1599 |
\def\karnaughmapVariableBaseBias{0.2} |
| 1600 |
\ifKV@karnaughmap@omitbinaries |
| 1601 |
% \end{macrocode} |
| 1602 |
% |
| 1603 |
% Set bias to 0 if binaries are not typeset. |
| 1604 |
% \begin{macrocode} |
| 1605 |
\def\karnaughmapVariableTopBias{0} |
| 1606 |
\def\karnaughmapVariableLeftBias{0} |
| 1607 |
\else |
| 1608 |
% \end{macrocode} |
| 1609 |
% |
| 1610 |
% Set bias accordingly if binaries have 1 or 2 characters. |
| 1611 |
% \begin{macrocode} |
| 1612 |
\def\karnaughmapVariableTopBias{0.3} |
| 1613 |
\ifthenelse{\equal{\karnaughmapVarLabelD}{}}{% |
| 1614 |
\def\karnaughmapVariableLeftBias{0.2} |
| 1615 |
}{% |
| 1616 |
\def\karnaughmapVariableLeftBias{0.4} |
| 1617 |
} |
| 1618 |
\fi |
| 1619 |
% \end{macrocode} |
| 1620 |
% |
| 1621 |
% Typeset the variable labels around the map if switch |omitvariables| is false. |
| 1622 |
% \begin{macrocode} |
| 1623 |
\ifKV@karnaughmap@omitvariables |
| 1624 |
\else |
| 1625 |
\ifthenelse{\equal{\karnaughmapVarLabelA}{}}{% |
| 1626 |
}{% |
| 1627 |
\ifthenelse{\equal{\karnaughmapVarLabelB}{}}{% |
| 1628 |
\draw (1.1, \karnaughmapNumRow + \karnaughmapVariableBaseBias + \karnaughmapVariableTopBias) |
| 1629 |
-- node[above] {$\karnaughmapVarLabelA$} ++(0.8, 0); |
| 1630 |
\ifKV@karnaughmap@omitnegated |
| 1631 |
\else |
| 1632 |
\draw (0.1, \karnaughmapNumRow + \karnaughmapVariableBaseBias + \karnaughmapVariableTopBias) |
| 1633 |
-- node[above] {$\overline{\karnaughmapVarLabelA}$} ++(0.8, 0); |
| 1634 |
\fi |
| 1635 |
}{% |
| 1636 |
\draw (2.1, \karnaughmapNumRow + \karnaughmapVariableBaseBias + \karnaughmapVariableTopBias) |
| 1637 |
-- node[above] {$\karnaughmapVarLabelA$} ++(1.8, 0); |
| 1638 |
\draw (1.1, -\karnaughmapVariableBaseBias) |
| 1639 |
-- node[below] {$\karnaughmapVarLabelB$} ++(1.8, 0); |
| 1640 |
\ifKV@karnaughmap@omitnegated |
| 1641 |
\else |
| 1642 |
\draw (0.1, \karnaughmapNumRow + \karnaughmapVariableBaseBias + \karnaughmapVariableTopBias) |
| 1643 |
-- node[above] {$\overline{\karnaughmapVarLabelA}$} ++(1.8, 0); |
| 1644 |
\draw (0.1, -\karnaughmapVariableBaseBias) |
| 1645 |
-- node[below] {$\overline{\karnaughmapVarLabelB}$} ++(0.8, 0); |
| 1646 |
\draw (3.1, -\karnaughmapVariableBaseBias) |
| 1647 |
-- node[below] {$\overline{\karnaughmapVarLabelB}$} ++(0.8, 0); |
| 1648 |
\fi |
| 1649 |
} |
| 1650 |
} |
| 1651 |
\ifthenelse{\equal{\karnaughmapVarLabelC}{}}{% |
| 1652 |
}{% |
| 1653 |
\ifthenelse{\equal{\karnaughmapVarLabelD}{}}{% |
| 1654 |
\draw (-\karnaughmapVariableBaseBias -\karnaughmapVariableLeftBias, 0.1) |
| 1655 |
-- node[left] {$\karnaughmapVarLabelC$} ++(0, 0.8); |
| 1656 |
\ifKV@karnaughmap@omitnegated |
| 1657 |
\else |
| 1658 |
\draw (-\karnaughmapVariableBaseBias -\karnaughmapVariableLeftBias, 1.1) |
| 1659 |
-- node[left] {$\overline{\karnaughmapVarLabelC}$} ++(0, 0.8); |
| 1660 |
\fi |
| 1661 |
}{% |
| 1662 |
\draw (-\karnaughmapVariableBaseBias -\karnaughmapVariableLeftBias, 0.1) |
| 1663 |
-- node[left] {$\karnaughmapVarLabelC$} ++(0, 1.8); |
| 1664 |
\draw (\karnaughmapNumCol + \karnaughmapVariableBaseBias, 1.1) |
| 1665 |
-- node[right] {$\karnaughmapVarLabelD$} ++(0, 1.8); |
| 1666 |
\ifKV@karnaughmap@omitnegated |
| 1667 |
\else |
| 1668 |
\draw (-\karnaughmapVariableBaseBias -\karnaughmapVariableLeftBias, 2.1) |
| 1669 |
-- node[left] {$\overline{\karnaughmapVarLabelC}$} ++(0, 1.8); |
| 1670 |
\draw (\karnaughmapNumCol + \karnaughmapVariableBaseBias, 0.1) |
| 1671 |
-- node[right] {$\overline{\karnaughmapVarLabelD}$} ++(0, 0.8); |
| 1672 |
\draw (\karnaughmapNumCol + \karnaughmapVariableBaseBias, 3.1) |
| 1673 |
-- node[right] {$\overline{\karnaughmapVarLabelD}$} ++(0, 0.8); |
| 1674 |
\fi |
| 1675 |
} |
| 1676 |
} |
| 1677 |
\fi |
| 1678 |
% \end{macrocode} |
| 1679 |
% |
| 1680 |
% Typeset decimal index if switch |omitidx| is false. |
| 1681 |
% \begin{macrocode} |
| 1682 |
\ifKV@karnaughmap@omitidx |
| 1683 |
\else |
| 1684 |
\karnaughmapPrintCellContents[anchor=west]{0.0}{-0.2}{\karnaughmapSize}{\karnaughmapNumRow}{\karnaughmapPrintIndex[\karnaughmapNumVar]} |
| 1685 |
\fi |
| 1686 |
% \end{macrocode} |
| 1687 |
% |
| 1688 |
% Typeset the cell entries. |
| 1689 |
% \begin{macrocode} |
| 1690 |
\karnaughmapPrintCellContents{0.5}{-0.5}{\karnaughmapSize}{\karnaughmapNumRow}{\karnaughmapPrintValue{\karnaughmapCellEntries}} |
| 1691 |
% \end{macrocode} |
| 1692 |
% |
| 1693 |
% Close the scope |
| 1694 |
% \begin{macrocode} |
| 1695 |
\end{scope} |
| 1696 |
% \end{macrocode} |
| 1697 |
% |
| 1698 |
% Finishing macro bracket. |
| 1699 |
% \begin{macrocode} |
| 1700 |
} |
| 1701 |
% \end{macrocode} |
| 1702 |
% \end{macro} |
| 1703 |
% |
| 1704 |
% \begin{macro}{\karnaughmapcolorfield} |
| 1705 |
% The coloring macro takes two mandatory and one optional argument:\\ |
| 1706 |
% \oarg{key=value}\marg{map size}\marg{fields}\marg{color}. |
| 1707 |
% \begin{macrocode} |
| 1708 |
\newcommand{\karnaughmapcolorfield}[4][]{% |
| 1709 |
\setkeys{karnaughmap}{fill,opacity}% |
| 1710 |
\ifthenelse{\equal{#1}{}}{}{\setkeys*{karnaughmap}{#1}}% |
| 1711 |
\ifthenelse{\equal{#3}{}}{}{% |
| 1712 |
\StrSplit{#3}{1}{\karnaughmapColorfieldCur}{\karnaughmapColorfieldRem} |
| 1713 |
\ifthenelse{\equal{#2}{2}}{% |
| 1714 |
\karnaughmapShadeMapfieldTWO[\XKV@rm]{\karnaughmapColorfieldCur}{#4} |
| 1715 |
}{} |
| 1716 |
\ifthenelse{\equal{#2}{3}}{% |
| 1717 |
\karnaughmapShadeMapfieldTHREE[\XKV@rm]{\karnaughmapColorfieldCur}{#4} |
| 1718 |
}{} |
| 1719 |
\ifthenelse{\equal{#2}{4}}{% |
| 1720 |
\karnaughmapShadeMapfieldFOUR[\XKV@rm]{\karnaughmapColorfieldCur}{#4} |
| 1721 |
}{} |
| 1722 |
\karnaughmapcolorfield[#1]{#2}{\karnaughmapColorfieldRem}{#4} |
| 1723 |
} |
| 1724 |
} |
| 1725 |
% \end{macrocode} |
| 1726 |
% \end{macro} |
| 1727 |
% |
| 1728 |
% |
| 1729 |
% |
| 1730 |
% |
| 1731 |
% |
| 1732 |
% |
| 1733 |
% |
| 1734 |
% |
| 1735 |
% \section{To Do}% \iffalse TODO: SEC:To Do \fi |
| 1736 |
% \begin{itemize} |
| 1737 |
% \item Adjust the map label positions as well as the function label to fit the negated variant. |
| 1738 |
% \item Increase supported karnaugh map size: 5 and 6 variables should be feasible in a single karnaugh map |
| 1739 |
% \item Provide the possibility to permute the karnaugh map |
| 1740 |
% \end{itemize} |
| 1741 |
% |
| 1742 |
% |
| 1743 |
% |
| 1744 |
% \iffalse ins meta-comment |
| 1745 |
% |
| 1746 |
% For convenience, the corresponding .ins file is provided here. |
| 1747 |
% Just copy this in a file called karnaughmap.ins and run it through latex. |
| 1748 |
% |
| 1749 |
% %% |
| 1750 |
% %% Copyright (C) 2013 by Michael Vonbun <[email protected]> |
| 1751 |
% %% |
| 1752 |
% %% This file may be distributed and/or modified under the conditions of |
| 1753 |
% %% the LaTeX Project Public License, either version 1.2 of this license |
| 1754 |
% %% or (at your option) any later version. The latest version of this |
| 1755 |
% %% license is in: |
| 1756 |
% %% |
| 1757 |
% %% http://www.latex-project.org/lppl.txt |
| 1758 |
% %% |
| 1759 |
% %% and version 1.2 or later is part of all distributions of LaTeX version |
| 1760 |
% %% 1999/12/01 or later. |
| 1761 |
% %% |
| 1762 |
% |
| 1763 |
% \input docstrip.tex |
| 1764 |
% \keepsilent |
| 1765 |
% |
| 1766 |
% \usedir{tex/latex/lisstyles/karnaughmap} |
| 1767 |
% |
| 1768 |
% \preamble |
| 1769 |
% |
| 1770 |
% This is a generated file. |
| 1771 |
% |
| 1772 |
% Copyright (C) 2013 by Michael Vonbun <[email protected]> |
| 1773 |
% |
| 1774 |
% This file may be distributed and/or modified under the conditions of |
| 1775 |
% the LaTeX Project Public License, either version 1.2 of this license |
| 1776 |
% or (at your option) any later version. The latest version of this |
| 1777 |
% license is in: |
| 1778 |
% |
| 1779 |
% http://www.latex-project.org/lppl.txt |
| 1780 |
% |
| 1781 |
% and version 1.2 or later is part of all distributions of LaTeX version |
| 1782 |
% 1999/12/01 or later. |
| 1783 |
% |
| 1784 |
% \endpreamble |
| 1785 |
% |
| 1786 |
% \generate{\file{karnaughmap.sty}{\from{karnaughmap.dtx}{package}}} |
| 1787 |
% |
| 1788 |
% \obeyspaces |
| 1789 |
% \Msg{*************************************************************} |
| 1790 |
% \Msg{* *} |
| 1791 |
% \Msg{* To finish the installation you have to move the following *} |
| 1792 |
% \Msg{* file into a directory searched by TeX: *} |
| 1793 |
% \Msg{* *} |
| 1794 |
% \Msg{* karnaughmap.sty *} |
| 1795 |
% \Msg{* *} |
| 1796 |
% \Msg{* To produce the documentation run the file karnaughmap.dtx *} |
| 1797 |
% \Msg{* through LaTeX/pdfLaTeX. *} |
| 1798 |
% \Msg{* To produce the changelog, run *} |
| 1799 |
% \Msg{* makeindex -s gind.ist -o karnaughmap.ind karnaughmap.idx *} |
| 1800 |
% \Msg{* To produce the index, run *} |
| 1801 |
% \Msg{* makeindex -s gglo.ist -o karnaughmap.gls karnaughmap.glo *} |
| 1802 |
% \Msg{* *} |
| 1803 |
% \Msg{* gglo.ist and gind.ist are shipped with the doc-package *} |
| 1804 |
% \Msg{* *} |
| 1805 |
% \Msg{* Happy TeXing! *} |
| 1806 |
% \Msg{* *} |
| 1807 |
% \Msg{*************************************************************} |
| 1808 |
% |
| 1809 |
% \endbatchfile |
| 1810 |
% |
| 1811 |
% \fi |
| 1812 |
% |
| 1813 |
% \setcounter{IndexColumns}{2} |
| 1814 |
% \Finale \PrintChanges \PrintIndex |
| 1815 |
\endinput |