diff options
author | Karl Berry <karl@freefriends.org> | 2018-03-19 21:47:34 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-03-19 21:47:34 +0000 |
commit | 41dc4d99ad2c865b3bf572e85cb20bc58daaa660 (patch) | |
tree | bab57ee9996866d254c664e90093066be3cd15e9 /Master/texmf-dist/tex/latex/tikz-karnaugh | |
parent | e9b1ff9415ab811c9f3ae12bbe70b9778aaa6741 (diff) |
tikz-karnaugh (19mar18)
git-svn-id: svn://tug.org/texlive/trunk@47026 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/tikz-karnaugh')
-rw-r--r-- | Master/texmf-dist/tex/latex/tikz-karnaugh/tikzlibrarykarnaugh.code.tex | 97 |
1 files changed, 51 insertions, 46 deletions
diff --git a/Master/texmf-dist/tex/latex/tikz-karnaugh/tikzlibrarykarnaugh.code.tex b/Master/texmf-dist/tex/latex/tikz-karnaugh/tikzlibrarykarnaugh.code.tex index ad49dbd4284..5ff82dab66f 100644 --- a/Master/texmf-dist/tex/latex/tikz-karnaugh/tikzlibrarykarnaugh.code.tex +++ b/Master/texmf-dist/tex/latex/tikz-karnaugh/tikzlibrarykarnaugh.code.tex @@ -1,18 +1,18 @@ %% This is file `tikzlibrarykarnaugh.code.tex' formerly known as `tikz-karnaugh.tex', -%% Version 1.1 of 10 January 2018 +%% Version: 1.2 +%% Version date: 2018-03-19 %% -%% Copyright (C) 2017 by Luis Paulo Laus, laus@utfpr.edu.br +%% Copyright (C) 2018 by Luis Paulo Laus, laus@utfpr.edu.br %% %% This package can be redistributed and/or modified under the terms %% of the LaTeX Project Public License distributed from CTAN %% archives in directory macros/latex/base/lppl.txt; either %% version 1 of the License, or (at your option) any later version, -%% with `The Package' referring to the software `tikzlibrarykarnaugh.code.tex' and its -%% accompanying documentation and `The Copyright Holder' referring to the -%% person Luis Paulo Laus. +%% with `The Package' referring to the software +%% `tikzlibrarykarnaugh.code.tex' +%% and its accompanying documentation and `The Copyright Holder' +%% referring to the person Luis Paulo Laus. %% -%% This software is based on Andreas W. Wieland's kvmacros.tex to whom -%% the author wished to express his gratitude. %% %% IMPORTANT NOTICE: %% @@ -20,10 +20,9 @@ %% versions send mail to: %% laus@utfpr.edu.br %% -%% \typeout{} \typeout{Macros for typesetting Karnaugh maps} -\typeout{Version 1.1 of 10 January 2018} +\typeout{Version 1.2 of 19 March 2018} \typeout{by Luis Paulo Laus, laus@utfpr.edu.br} \typeout{} %% @@ -33,36 +32,35 @@ %% options in the identifiers and values lists. New vertical mode. %% New keys to enable indices and disable bars. Macro file renamed %% to proper tikz library file name. -%% -%% +%% 1.2: 19 March 2018: stop using \pgftransformshift, new kmindexpos +%% (kmindexposx and kmindexposy) to control index position, cell +%% typesetting order switched (first content then index), parameter +%% names changed to include ``km'' letters, new binary index mode %% %% Setting up some TikZ parameters for Karnaugh Maps %% \tikzset{ karnaugh/.style={ - kmbar/.style={black,|-|,thin}, - kmbar label/.style={black}, - bar sep/.style={kmbar sep={##1}}, - bar top sep/.style={kmbar top sep={##1}}, - bar left sep/.style={kmbar left sep={##1}}, + disable bars/.is if=disablebars, + kmbar/.style={|-|}, + kmbar label/.style={}, + kmbar sep/.initial=0.2\kmunitlength, + kmbar top sep/.initial=1\kmunitlength, + kmbar left sep/.initial=1\kmunitlength, + enable indices/.is if=enableindices, kmindex/.style={red,font=\tiny}, - karnaugh index/.style={kmindex/.style={##1}}, - kmcell/.style={black}, - kmvar/.style={black}, - kmbox/.style={thin}, - kmlines/.style={thin}, + kmindexposx/.initial=0.2\kmunitlength, + kmindexposy/.initial=0.8\kmunitlength, + kmindexpos/.style 2 args={kmindexposx={##1\kmunitlength},kmindexposy={##2\kmunitlength}}, + binary index/.is if=indexbin, + kmcell/.style={}, + kmvar/.style={}, + kmbox/.style={}, + kmlines/.style={}, every karnaugh/.try, - enable indices/.is if=enableindices, - disable bars/.is if=disablebars, } } -\pgfkeys{/pgf/.cd, - kmbar sep/.initial=0.2\kmunitlength, - kmbar top sep/.initial=1\kmunitlength, - kmbar left sep/.initial=1\kmunitlength, -} - %% %% New ifs for the options above %% @@ -70,6 +68,8 @@ \enableindicesfalse \newif\ifdisablebars \disablebarsfalse +\newif\ifindexbin +\indexbinfalse %% %% We need a fixed dimension for a single field in a Karnaugh map %% and also an auxiliary dimension to place the bars. @@ -81,7 +81,7 @@ %% First, we have to introduce some counters: %% %% \kmrecursiondepth is used to control the recursion of the -%% \karnaughmakemap. +%% \karnaughmakemap macro. %% \newcount\kmrecursiondepth %% @@ -110,8 +110,13 @@ %% Single cells in a diagram should be indexed, which makes the map easier to %% use (ok, not really, but it might be useful). %% -\def\kmcurrentindex{% +\def\kmcurrentindex{\kmcurrentindexdec} +\def\kmcurrentindexdec{% \the\kmindexcounter\global\advance\kmindexcounter by 1}% + +\def\kmcurrentindexbin{% +\pgfmathdectobase\mynumber{\the\kmindexcounter}{2} \mynumber\global\advance\kmindexcounter by 1}% + %% %% We need a macro that computes the powers of two: %% @@ -194,12 +199,12 @@ \karnaughmakemap{\kmrecursiondepth}{0}{\tempx}{\tempys}% \fi \else + \kmsetoptstr{} % reads argument as <[opt]>str + \node[kmcell,kmtempsty,shift={(0.5\kmunitlength,0.5\kmunitlength)}] at (#3\kmunitlength,#4\kmunitlength){\kmstr};% \ifenableindices - \node[kmindex,shift={(-0.3\kmunitlength,0.3\kmunitlength)}] + \node[kmindex,shift={(\pgfkeysvalueof{/tikz/kmindexposx},\pgfkeysvalueof{/tikz/kmindexposy})}] at (#3\kmunitlength,#4\kmunitlength) {\kmcurrentindex}; \fi - \kmsetoptstr{} % reads argument as <[opt]>str - \node[kmcell,kmtempsty] at (#3\kmunitlength,#4\kmunitlength){\kmstr};% \fi}}% %% %% \karnaughmaketopbar typesets the variable bars of a Karnaugh map that are @@ -219,9 +224,9 @@ % The highest-order variable bar needs a special treatment: \ifnum\kmbarnum=0\kmbarnum=1\divide\kmbarlength by 2\fi \advance\kmbarmove by \kmbarstart - \kmtemplength=\pgfkeysvalueof{/pgf/kmbar top sep} + \kmtemplength=\pgfkeysvalueof{/tikz/kmbar top sep} \multiply \kmtemplength by \kmxvarno - \advance \kmtemplength by \pgfkeysvalueof{/pgf/kmbar sep} + \advance \kmtemplength by \pgfkeysvalueof{/tikz/kmbar sep} \advance \kmtemplength by \kmysize\kmunitlength \kmsetoptstr % reads argument as <[opt]>str \ifnum\kmbarnum=1 @@ -252,9 +257,9 @@ %The highest-order variable bar needs a special treatment: \ifnum\kmbarnum=0\kmbarstart=0\kmbarnum=1\divide\kmbarlength by 2\fi \advance\kmbarmove by \kmbarstart - \kmtemplength=-\pgfkeysvalueof{/pgf/kmbar left sep} + \kmtemplength=-\pgfkeysvalueof{/tikz/kmbar left sep} \multiply \kmtemplength by \kmyvarno - \advance \kmtemplength by -\pgfkeysvalueof{/pgf/kmbar sep} + \advance \kmtemplength by -\pgfkeysvalueof{/tikz/kmbar sep} \kmsetoptstr % reads argument as <[opt]>str \ifnum\kmbarnum=1 \draw[kmbar,yshift=\kmbarstart\kmunitlength,xshift=\kmtemplength,kmtempsty] @@ -297,6 +302,7 @@ %% #5 a possibly empty set of TikZ commands that will be drown before %% the function values so the values will appear on top of them %% + \ifenableindices\ifindexbin\gdef\kmcurrentindex{\kmcurrentindexbin}\pgfmathsetbasenumberlength{#1}\else\gdef\kmcurrentindex{\kmcurrentindexdec}\fi\fi \kmvarno=#1 % \kmvarno is the total number of variables \kmyvarno=#1 % \kmyvarno is the number of variable bars at the left \divide\kmyvarno by 2 @@ -323,7 +329,6 @@ \kmargumentstring{#3} \karnaughmakebars \fi - \pgftransformshift{\pgfpoint{0.5\kmunitlength}{0.5\kmunitlength}} \kmvarno=#1 % \kmvarno is the total number of variables \kmindexcounter=0 \kmargumentstring{#4} @@ -332,7 +337,6 @@ \divide\kmxsize by 2 \karnaughmakemap{\the\kmysize}{1}{\the\kmxsize}{0} \fi - \pgftransformreset }% %% Vertical Mode %% The next three macros are similar to the ones for normal mode. @@ -389,12 +393,12 @@ \karnaughmakemapvert{\kmrecursiondepth}{0}{\tempx}{\tempys}% \fi \else + \kmsetoptstr{} % reads argument as <[opt]>str + \node[kmcell,kmtempsty,shift={(0.5\kmunitlength,0.5\kmunitlength)}] at (#3\kmunitlength,#4\kmunitlength){\kmstr}; \ifenableindices - \node[kmindex,shift={(-0.3\kmunitlength,0.3\kmunitlength)}] - at (#3\kmunitlength,#4\kmunitlength) {\kmcurrentindex};% + \node[kmindex,shift={(\pgfkeysvalueof{/tikz/kmindexposx},\pgfkeysvalueof{/tikz/kmindexposy})}] + at (#3\kmunitlength,#4\kmunitlength) {\kmcurrentindex}; \fi - \kmsetoptstr{} % reads argument as <[opt]>str - \node[kmcell,kmtempsty] at (#3\kmunitlength,#4\kmunitlength){\kmstr};% \fi}}% %% %% \karnaughmakebarsvert calls \karnaughmaketopbar or \karnaughmakeleftbar @@ -429,6 +433,7 @@ %% #5 a possibly empty set of TikZ commands that will be drown before %% the function values so the values will appear on top of them %% + \ifenableindices\ifindexbin\gdef\kmcurrentindex{\kmcurrentindexbin}\pgfmathsetbasenumberlength{#1}\else\gdef\kmcurrentindex{\kmcurrentindexdec}\fi\fi \kmvarno=#1 % \kmvarno is the total number of variables \kmxvarno=#1 % \kmxvarno is the number of variable bars on top \divide\kmxvarno by 2 @@ -455,7 +460,6 @@ \kmargumentstring{#3} \karnaughmakebarsvert \fi - \pgftransformshift{\pgfpoint{0.5\kmunitlength}{0.5\kmunitlength}} \kmvarno=#1 % \kmvarno is the total number of variables \kmindexcounter=0 \kmargumentstring{#4} @@ -466,5 +470,6 @@ \else \karnaughmakemapvert{\the\kmxsize}{0}{0}{0} \fi - \pgftransformreset }% + +\endinput
\ No newline at end of file |