You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
tex-compiler/texmf-dist/tex/latex/lwarp/lwarp-karnaugh-map.sty

163 lines
12 KiB

%%
%% This is file `lwarp-karnaugh-map.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% lwarp.dtx (with options: `karnaugh-map')
%% This is a generated file.
%% Copyright 2016-2020 Brian Dunn
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% 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.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
\LWR@ProvidesPackagePass{karnaugh-map}[2017/02/20]
\RenewDocumentEnvironment{karnaugh-map}{s O{4} O{4} O{1} O{$X_1X_0$} O{$X_3X_2$} O{$X_5X_4$}} {%
\begingroup
% store map size {[START]
\renewcommand{\@karnaughmap@var@mapsizex@}{#2}%
\renewcommand{\@karnaughmap@var@mapsizey@}{#3}%
\renewcommand{\@karnaughmap@var@mapsizez@}{#4}%
% [END]}
% determinate if markings should be color or black and white
\IfBooleanTF{#1}{%
% should be black and white
\renewcommand{\@karnaughmap@var@bw@}{1}%
}{%
% should be color
\renewcommand{\@karnaughmap@var@bw@}{0}%
}%
%
% find matching matrix template and alignment parameters {[START]
\newcommand{\@karnaughmap@local@matrixtemplate@}{0}% '0' is considered as missing matrix template
\newcommand{\@karnaughmap@local@maprealignmentx@}{0}%
\newcommand{\@karnaughmap@local@maprealignmenty@}{0}%
\ifnum\@karnaughmap@var@mapsizex@\@karnaughmap@var@mapsizey@\@karnaughmap@var@mapsizez@=221
\renewcommand{\@karnaughmap@local@matrixtemplate@}{%
\& 0 \& 1 \& \phantom{0} \\
0 \& |(000000)| \phantom{0} \& |(000001)| \phantom{0} \& \\
1 \& |(000010)| \phantom{0} \& |(000011)| \phantom{0} \& \\
\phantom{0} \& \& \& \\
}%
\fi
\ifnum\@karnaughmap@var@mapsizex@\@karnaughmap@var@mapsizey@\@karnaughmap@var@mapsizez@=241
\renewcommand{\@karnaughmap@local@matrixtemplate@}{%
\& 0 \& 1 \& \phantom{00} \\
00 \& |(000000)| \phantom{0} \& |(000001)| \phantom{0} \& \\
01 \& |(000010)| \phantom{0} \& |(000011)| \phantom{0} \& \\
11 \& |(000110)| \phantom{0} \& |(000111)| \phantom{0} \& \\
10 \& |(000100)| \phantom{0} \& |(000101)| \phantom{0} \& \\
\phantom{00} \& \& \& \\
}%
\fi
\ifnum\@karnaughmap@var@mapsizex@\@karnaughmap@var@mapsizey@\@karnaughmap@var@mapsizez@=421
\renewcommand{\@karnaughmap@local@matrixtemplate@}{%
\& 00 \& 01 \& 11 \& 10 \& \phantom{00} \\
0 \& |(000000)| \phantom{0} \& |(000001)| \phantom{0} \& |(000011)| \phantom{0} \& |(000010)| \phantom{0} \& \\
1 \& |(000100)| \phantom{0} \& |(000101)| \phantom{0} \& |(000111)| \phantom{0} \& |(000110)| \phantom{0} \& \\
\phantom{00} \& \& \& \& \& \\
}%
\fi
\ifnum\@karnaughmap@var@mapsizex@\@karnaughmap@var@mapsizey@\@karnaughmap@var@mapsizez@=441
\renewcommand{\@karnaughmap@local@matrixtemplate@}{%
\& 00 \& 01 \& 11 \& 10 \& \phantom{00} \\
00 \& |(000000)| \phantom{0} \& |(000001)| \phantom{0} \& |(000011)| \phantom{0} \& |(000010)| \phantom{0} \& \\
01 \& |(000100)| \phantom{0} \& |(000101)| \phantom{0} \& |(000111)| \phantom{0} \& |(000110)| \phantom{0} \& \\
11 \& |(001100)| \phantom{0} \& |(001101)| \phantom{0} \& |(001111)| \phantom{0} \& |(001110)| \phantom{0} \& \\
10 \& |(001000)| \phantom{0} \& |(001001)| \phantom{0} \& |(001011)| \phantom{0} \& |(001010)| \phantom{0} \& \\
\phantom{00} \& \& \& \& \& \\
}%
\fi
\ifnum\@karnaughmap@var@mapsizex@\@karnaughmap@var@mapsizey@\@karnaughmap@var@mapsizez@=442
\renewcommand{\@karnaughmap@local@matrixtemplate@}{%
\& 00 \& 01 \& 11 \& 10 \& \phantom{00} \& 00 \& 01 \& 11 \& 10 \& \phantom{00} \\
00 \& |(000000)| \phantom{0} \& |(000001)| \phantom{0} \& |(000011)| \phantom{0} \& |(000010)| \phantom{0} \& \& |(010000)| \phantom{0} \& |(010001)| \phantom{0} \& |(010011)| \phantom{0} \& |(010010)| \phantom{0} \& \\
01 \& |(000100)| \phantom{0} \& |(000101)| \phantom{0} \& |(000111)| \phantom{0} \& |(000110)| \phantom{0} \& \& |(010100)| \phantom{0} \& |(010101)| \phantom{0} \& |(010111)| \phantom{0} \& |(010110)| \phantom{0} \& \\
11 \& |(001100)| \phantom{0} \& |(001101)| \phantom{0} \& |(001111)| \phantom{0} \& |(001110)| \phantom{0} \& \& |(011100)| \phantom{0} \& |(011101)| \phantom{0} \& |(011111)| \phantom{0} \& |(011110)| \phantom{0} \& \\
10 \& |(001000)| \phantom{0} \& |(001001)| \phantom{0} \& |(001011)| \phantom{0} \& |(001010)| \phantom{0} \& \& |(011000)| \phantom{0} \& |(011001)| \phantom{0} \& |(011011)| \phantom{0} \& |(011010)| \phantom{0} \& \\
\phantom{00} \& \& \& \& \& \& \& \& \& \& \\
}%
\renewcommand{\@karnaughmap@local@maprealignmentx@}{2.5}%
\fi
\ifnum\@karnaughmap@var@mapsizex@\@karnaughmap@var@mapsizey@\@karnaughmap@var@mapsizez@=444
\renewcommand{\@karnaughmap@local@matrixtemplate@}{%
\& 00 \& 01 \& 11 \& 10 \& \phantom{00} \& 00 \& 01 \& 11 \& 10 \& \phantom{00} \\
00 \& |(000000)| \phantom{0} \& |(000001)| \phantom{0} \& |(000011)| \phantom{0} \& |(000010)| \phantom{0} \& \& |(010000)| \phantom{0} \& |(010001)| \phantom{0} \& |(010011)| \phantom{0} \& |(010010)| \phantom{0} \& \\
01 \& |(000100)| \phantom{0} \& |(000101)| \phantom{0} \& |(000111)| \phantom{0} \& |(000110)| \phantom{0} \& \& |(010100)| \phantom{0} \& |(010101)| \phantom{0} \& |(010111)| \phantom{0} \& |(010110)| \phantom{0} \& \\
11 \& |(001100)| \phantom{0} \& |(001101)| \phantom{0} \& |(001111)| \phantom{0} \& |(001110)| \phantom{0} \& \& |(011100)| \phantom{0} \& |(011101)| \phantom{0} \& |(011111)| \phantom{0} \& |(011110)| \phantom{0} \& \\
10 \& |(001000)| \phantom{0} \& |(001001)| \phantom{0} \& |(001011)| \phantom{0} \& |(001010)| \phantom{0} \& \& |(011000)| \phantom{0} \& |(011001)| \phantom{0} \& |(011011)| \phantom{0} \& |(011010)| \phantom{0} \& \\
\phantom{00} \& \& \& \& \& \& \& \& \& \& \\
00 \& |(100000)| \phantom{0} \& |(100001)| \phantom{0} \& |(100011)| \phantom{0} \& |(100010)| \phantom{0} \& \& |(110000)| \phantom{0} \& |(110001)| \phantom{0} \& |(110011)| \phantom{0} \& |(110010)| \phantom{0} \& \\
01 \& |(100100)| \phantom{0} \& |(100101)| \phantom{0} \& |(100111)| \phantom{0} \& |(100110)| \phantom{0} \& \& |(110100)| \phantom{0} \& |(110101)| \phantom{0} \& |(110111)| \phantom{0} \& |(110110)| \phantom{0} \& \\
11 \& |(101100)| \phantom{0} \& |(101101)| \phantom{0} \& |(101111)| \phantom{0} \& |(101110)| \phantom{0} \& \& |(111100)| \phantom{0} \& |(111101)| \phantom{0} \& |(111111)| \phantom{0} \& |(111110)| \phantom{0} \& \\
10 \& |(101000)| \phantom{0} \& |(101001)| \phantom{0} \& |(101011)| \phantom{0} \& |(101010)| \phantom{0} \& \& |(111000)| \phantom{0} \& |(111001)| \phantom{0} \& |(111011)| \phantom{0} \& |(111010)| \phantom{0} \& \\
\phantom{00} \& \& \& \& \& \& \& \& \& \& \\
}%
\renewcommand{\@karnaughmap@local@maprealignmentx@}{2.5}%
\renewcommand{\@karnaughmap@local@maprealignmenty@}{-2.5}%
\fi
% [END]}
% test if a matrix template is found or not(aka "\@karnaughmap@local@matrixtemplate@" equals to '0')
\ifdefstring{\@karnaughmap@local@matrixtemplate@}{0}{% lwarp
% print error if no template could be found
\PackageError{lwarp-karnaugh-map}{%
Can not find a template fitting your specification (\@karnaughmap@var@mapsizex@\space x \@karnaughmap@var@mapsizey@\space x \@karnaughmap@var@mapsizez@)%
}{%
Existing templates have the following dimensions: 2x2x1, 2x4x1, 4x2x1, 4x4x1, 4x4x2, and 4x4x4.
}%
}{}% lwarp
\begin{tikzpicture}
% grid
% for all dimensions
\draw[color=black, ultra thin] (0,0) grid (\@karnaughmap@var@mapsizex@,\@karnaughmap@var@mapsizey@);
% when there are 2 sub maps
\ifnum\@karnaughmap@var@mapsizez@=2
\draw[color=black, ultra thin] (5,0) grid (9,4);
\fi
% when there are 4 sub maps
\ifnum\@karnaughmap@var@mapsizez@=4
\draw[color=black, ultra thin] (5,0) grid (9,4);
\draw[color=black, ultra thin] (0,-5) grid (4,-1);
\draw[color=black, ultra thin] (5,-5) grid (9,-1);
\fi
% labels
% for all dimensions
\node[above] at (\@karnaughmap@var@mapsizex@*0.5,\@karnaughmap@var@mapsizey@+0.9) {\small{#5}};
\node[left] at (-0.9,\@karnaughmap@var@mapsizey@*0.5) {\small{#6}};
% when there are 2 sub maps
\ifnum\@karnaughmap@var@mapsizez@=2
\node[above] at (7,4.9) {\small{#5}};
% extra sub maps labels
\node[below] at (2,-0.1) {\small{#7$=0$}};
\node[below] at (7,-0.1) {\small{#7$=1$}};
\fi
% when there are 4 sub maps
\ifnum\@karnaughmap@var@mapsizez@=4
\node[above] at (7,4.9) {\small{#5}};
\node[left] at (-0.9,-3) {\small{#6}};
% extra sub maps labels
\node[below] at (2,-0.1) {\small{#7$=00$}};
\node[below] at (7,-0.1) {\small{#7$=01$}};
\node[below] at (2,-5.1) {\small{#7$=10$}};
\node[below] at (7,-5.1) {\small{#7$=11$}};
\fi
% data
\matrix[
matrix of nodes,
ampersand replacement=\&,
column sep={1cm,between origins},
row sep={1cm,between origins},
] at (\@karnaughmap@var@mapsizex@*0.5+\@karnaughmap@local@maprealignmentx@,\@karnaughmap@var@mapsizey@*0.5+\@karnaughmap@local@maprealignmenty@) {
\@karnaughmap@local@matrixtemplate@%
};
}{
\end{tikzpicture}
\endgroup
}
\endinput
%%
%% End of file `lwarp-karnaugh-map.sty'.