Debian Codegraph @

texmf-dist/tex/latex/lwarp/lwarp-karnaugh-map.sty

raw
1 %%
2 %% This is file `lwarp-karnaugh-map.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% lwarp.dtx (with options: `karnaugh-map')
8 %% This is a generated file.
9 %% Copyright 2016-2026 Brian Dunn
10 %%
11 %% This work may be distributed and/or modified under the
12 %% conditions of the LaTeX Project Public License, either version 1.3
13 %% of this license or (at your option) any later version.
14 %% The latest version of this license is in
15 %% http://www.latex-project.org/lppl.txt
16 %% and version 1.3 or later is part of all distributions of LaTeX
17 %% version 2005/12/01 or later.
18 \LWR@ProvidesPackagePass{karnaugh-map}[2017/02/20]
19 \VerifyEnvironment[lwarp][karnaugh-map]{karnaugh-map}
20 {FFA0270032620E79C8344E63AEDBF925}{08A76B622DBB34F033284513743C5F8C}
21
22 \RenewDocumentEnvironment{karnaugh-map}{s O{4} O{4} O{1} O{$X_1X_0$} O{$X_3X_2$} O{$X_5X_4$}} {%
23 \begingroup
24 % store map size {[START]
25 \renewcommand{\@karnaughmap@var@mapsizex@}{#2}%
26 \renewcommand{\@karnaughmap@var@mapsizey@}{#3}%
27 \renewcommand{\@karnaughmap@var@mapsizez@}{#4}%
28 % [END]}
29 % determinate if markings should be color or black and white
30 \IfBooleanTF{#1}{%
31 % should be black and white
32 \renewcommand{\@karnaughmap@var@bw@}{1}%
33 }{%
34 % should be color
35 \renewcommand{\@karnaughmap@var@bw@}{0}%
36 }%
37 %
38 % find matching matrix template and alignment parameters {[START]
39 \newcommand{\@karnaughmap@local@matrixtemplate@}{0}% '0' is considered as missing matrix template
40 \newcommand{\@karnaughmap@local@maprealignmentx@}{0}%
41 \newcommand{\@karnaughmap@local@maprealignmenty@}{0}%
42 \ifnum\@karnaughmap@var@mapsizex@\@karnaughmap@var@mapsizey@\@karnaughmap@var@mapsizez@=221
43 \renewcommand{\@karnaughmap@local@matrixtemplate@}{%
44 \& 0 \& 1 \& \phantom{0} \\
45 0 \& |(000000)| \phantom{0} \& |(000001)| \phantom{0} \& \\
46 1 \& |(000010)| \phantom{0} \& |(000011)| \phantom{0} \& \\
47 \phantom{0} \& \& \& \\
48 }%
49 \fi
50 \ifnum\@karnaughmap@var@mapsizex@\@karnaughmap@var@mapsizey@\@karnaughmap@var@mapsizez@=241
51 \renewcommand{\@karnaughmap@local@matrixtemplate@}{%
52 \& 0 \& 1 \& \phantom{00} \\
53 00 \& |(000000)| \phantom{0} \& |(000001)| \phantom{0} \& \\
54 01 \& |(000010)| \phantom{0} \& |(000011)| \phantom{0} \& \\
55 11 \& |(000110)| \phantom{0} \& |(000111)| \phantom{0} \& \\
56 10 \& |(000100)| \phantom{0} \& |(000101)| \phantom{0} \& \\
57 \phantom{00} \& \& \& \\
58 }%
59 \fi
60 \ifnum\@karnaughmap@var@mapsizex@\@karnaughmap@var@mapsizey@\@karnaughmap@var@mapsizez@=421
61 \renewcommand{\@karnaughmap@local@matrixtemplate@}{%
62 \& 00 \& 01 \& 11 \& 10 \& \phantom{00} \\
63 0 \& |(000000)| \phantom{0} \& |(000001)| \phantom{0} \& |(000011)| \phantom{0} \& |(000010)| \phantom{0} \& \\
64 1 \& |(000100)| \phantom{0} \& |(000101)| \phantom{0} \& |(000111)| \phantom{0} \& |(000110)| \phantom{0} \& \\
65 \phantom{00} \& \& \& \& \& \\
66 }%
67 \fi
68 \ifnum\@karnaughmap@var@mapsizex@\@karnaughmap@var@mapsizey@\@karnaughmap@var@mapsizez@=441
69 \renewcommand{\@karnaughmap@local@matrixtemplate@}{%
70 \& 00 \& 01 \& 11 \& 10 \& \phantom{00} \\
71 00 \& |(000000)| \phantom{0} \& |(000001)| \phantom{0} \& |(000011)| \phantom{0} \& |(000010)| \phantom{0} \& \\
72 01 \& |(000100)| \phantom{0} \& |(000101)| \phantom{0} \& |(000111)| \phantom{0} \& |(000110)| \phantom{0} \& \\
73 11 \& |(001100)| \phantom{0} \& |(001101)| \phantom{0} \& |(001111)| \phantom{0} \& |(001110)| \phantom{0} \& \\
74 10 \& |(001000)| \phantom{0} \& |(001001)| \phantom{0} \& |(001011)| \phantom{0} \& |(001010)| \phantom{0} \& \\
75 \phantom{00} \& \& \& \& \& \\
76 }%
77 \fi
78 \ifnum\@karnaughmap@var@mapsizex@\@karnaughmap@var@mapsizey@\@karnaughmap@var@mapsizez@=442
79 \renewcommand{\@karnaughmap@local@matrixtemplate@}{%
80 \& 00 \& 01 \& 11 \& 10 \& \phantom{00} \& 00 \& 01 \& 11 \& 10 \& \phantom{00} \\
81 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} \& \\
82 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} \& \\
83 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} \& \\
84 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} \& \\
85 \phantom{00} \& \& \& \& \& \& \& \& \& \& \\
86 }%
87 \renewcommand{\@karnaughmap@local@maprealignmentx@}{2.5}%
88 \fi
89 \ifnum\@karnaughmap@var@mapsizex@\@karnaughmap@var@mapsizey@\@karnaughmap@var@mapsizez@=444
90 \renewcommand{\@karnaughmap@local@matrixtemplate@}{%
91 \& 00 \& 01 \& 11 \& 10 \& \phantom{00} \& 00 \& 01 \& 11 \& 10 \& \phantom{00} \\
92 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} \& \\
93 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} \& \\
94 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} \& \\
95 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} \& \\
96 \phantom{00} \& \& \& \& \& \& \& \& \& \& \\
97 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} \& \\
98 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} \& \\
99 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} \& \\
100 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} \& \\
101 \phantom{00} \& \& \& \& \& \& \& \& \& \& \\
102 }%
103 \renewcommand{\@karnaughmap@local@maprealignmentx@}{2.5}%
104 \renewcommand{\@karnaughmap@local@maprealignmenty@}{-2.5}%
105 \fi
106 % [END]}
107 % test if a matrix template is found or not(aka "\@karnaughmap@local@matrixtemplate@" equals to '0')
108 \ifdefstring{\@karnaughmap@local@matrixtemplate@}{0}{% lwarp
109 % print error if no template could be found
110 \PackageError{lwarp-karnaugh-map}{%
111 Can not find a template fitting your specification
112 (\@karnaughmap@var@mapsizex@\space x \@karnaughmap@var@mapsizey@\space x
113 \@karnaughmap@var@mapsizez@)%
114 }{%
115 Existing templates have the following dimensions:
116 2x2x1, 2x4x1, 4x2x1, 4x4x1, 4x4x2, and 4x4x4.
117 }%
118 }{\relax}% lwarp
119 \begin{tikzpicture}
120 % grid
121 % for all dimensions
122 \draw[color=black, ultra thin] (0,0) grid (\@karnaughmap@var@mapsizex@,\@karnaughmap@var@mapsizey@);
123 % when there are 2 sub maps
124 \ifnum\@karnaughmap@var@mapsizez@=2
125 \draw[color=black, ultra thin] (5,0) grid (9,4);
126 \fi
127 % when there are 4 sub maps
128 \ifnum\@karnaughmap@var@mapsizez@=4
129 \draw[color=black, ultra thin] (5,0) grid (9,4);
130 \draw[color=black, ultra thin] (0,-5) grid (4,-1);
131 \draw[color=black, ultra thin] (5,-5) grid (9,-1);
132 \fi
133 % labels
134 % for all dimensions
135 \node[above] at (\@karnaughmap@var@mapsizex@*0.5,\@karnaughmap@var@mapsizey@+0.9) {\small{#5}};
136 \node[left] at (-0.9,\@karnaughmap@var@mapsizey@*0.5) {\small{#6}};
137 % when there are 2 sub maps
138 \ifnum\@karnaughmap@var@mapsizez@=2
139 \node[above] at (7,4.9) {\small{#5}};
140 % extra sub maps labels
141 \node[below] at (2,-0.1) {\small{#7$=0$}};
142 \node[below] at (7,-0.1) {\small{#7$=1$}};
143 \fi
144 % when there are 4 sub maps
145 \ifnum\@karnaughmap@var@mapsizez@=4
146 \node[above] at (7,4.9) {\small{#5}};
147 \node[left] at (-0.9,-3) {\small{#6}};
148 % extra sub maps labels
149 \node[below] at (2,-0.1) {\small{#7$=00$}};
150 \node[below] at (7,-0.1) {\small{#7$=01$}};
151 \node[below] at (2,-5.1) {\small{#7$=10$}};
152 \node[below] at (7,-5.1) {\small{#7$=11$}};
153 \fi
154 % data
155 \matrix[
156 matrix of nodes,
157 ampersand replacement=\&,
158 column sep={1cm,between origins},
159 row sep={1cm,between origins},
160 ] at (\@karnaughmap@var@mapsizex@*0.5+\@karnaughmap@local@maprealignmentx@,\@karnaughmap@var@mapsizey@*0.5+\@karnaughmap@local@maprealignmenty@) {
161 \@karnaughmap@local@matrixtemplate@%
162 };
163 }{
164 \end{tikzpicture}
165 \endgroup
166 }
167
168 \endinput
169 %%
170 %% End of file `lwarp-karnaugh-map.sty'.