diff --git a/karnaugh-map.dtx b/karnaugh-map.dtx index 7c19d13..5137c22 100644 --- a/karnaugh-map.dtx +++ b/karnaugh-map.dtx @@ -244,11 +244,17 @@ \DeclareStringOption[middle]{label}[middle] \DeclareStringOption[]{implicantcolors}[] \DeclareBoolOption[false]{linestyles} +\DeclareBoolOption[false]{omittikzpicture} \ProcessKeyvalOptions* %% environment options \define@key{karnaugh-map}{label}[middle]{\renewcommand{\@karnaughmap@option@label}{#1}} \define@key{karnaugh-map}{implicantcolors}[]{\renewcommand{\@karnaughmap@option@implicantcolors}{#1}} -\define@key{karnaugh-map}{linestyles}[false]{\@karnaughmap@option@linestylestrue} +\define@key{karnaugh-map}{linestyles}[true]{% + \csname @karnaughmap@option@linestyles#1\endcsname +} +\define@key{karnaugh-map}{omittikzpicture}[true]{% + \csname @karnaughmap@option@omittikzpicture#1\endcsname +} %% render in black and white or color default to '0'(false/color) \newcommand{\@karnaughmap@var@bw@}{0} @@ -333,6 +339,14 @@ % parse environment options \setkeys{karnaugh-map}{#1}% % + % check if the user wants us to omit begin/end{tikzpicture} + \if@karnaughmap@option@omittikzpicture + \begin{scope} + \else + % wrap in tikzpicture for the user + \begin{tikzpicture} + \fi + % % check if implicant colors are specified \IfStrEq{\@karnaughmap@option@implicantcolors}{}{}{% % ensure no empty colors are specified @@ -366,9 +380,15 @@ % to parse remaining arguments and finish initialization. \@karnaughmap@func@karnaughstart@% }{ - \end{tikzpicture} + % end tikzpicture if the user did not want us to omit it + \if@karnaughmap@option@omittikzpicture + \end{scope} + \else + \end{tikzpicture} + \fi \endgroup } + \DeclareDocumentCommand{\@karnaughmap@func@karnaughstart@}{oooooo} {% % parse label args {[START] % try to maintain backwards compatibility with v1 while enabling users to separatly @@ -564,14 +584,14 @@ Existing templates have the following dimensions: 2x2x1, 2x4x1, 4x2x1, 4x4x1, 4x4x2, and 4x4x4. }% \fi - \begin{tikzpicture}[ + \tikzset{ LineStyleA/.style={semithick,solid}, LineStyleB/.style={semithick,dash dot dot}, LineStyleC/.style={thin,double distance=0.8pt}, LineStyleD/.style={ultra thick}, LineStyleE/.style={semithick,dashed}, LineStyleF/.style={semithick,densely dotted}, - ] + } % grid {[START] % for all dimensions \draw[color=black, ultra thin] (0,0) grid (\@karnaughmap@var@mapsizex@,\@karnaughmap@var@mapsizey@); @@ -1462,6 +1482,17 @@ % \end{karnaugh-map} % \end{figure} % +% \texttt{omittikzpicture}: By default, the |karnaugh-map| environment creates its own |tikzpicture| environment. This option disables this behavior, and it would be expected that the user wraps the |karnaugh-map| environment in a |tikzpicture| environment. This option makes it possible to use the |tikzexternal| package with |karnaugh-map|, or to integrate |karnaugh-map| into a larger |tikzpicture|. +% +% \begin{verbatim} +% \begin{tikzpicture} +% \begin{karnaugh-map}(omittikzpicture) +% \minterms{0,1,2,3} +% \end{karnaugh-map} +% % Additional tikz code in the same picture +% \end{tikzpicture}} +% \end{verbatim} +% % \newpage % \section{Examples} % \begin{multicols}{2} diff --git a/test/expected/karnaugh-221-label-omit-tikzpicture-global-option.pdf b/test/expected/karnaugh-221-label-omit-tikzpicture-global-option.pdf new file mode 100644 index 0000000..e691e40 Binary files /dev/null and b/test/expected/karnaugh-221-label-omit-tikzpicture-global-option.pdf differ diff --git a/test/expected/karnaugh-221-label-omit-tikzpicture.pdf b/test/expected/karnaugh-221-label-omit-tikzpicture.pdf new file mode 100644 index 0000000..e691e40 Binary files /dev/null and b/test/expected/karnaugh-221-label-omit-tikzpicture.pdf differ diff --git a/test/expected/karnaugh-option-omit-tikzpicture-default.pdf b/test/expected/karnaugh-option-omit-tikzpicture-default.pdf new file mode 100644 index 0000000..e299c12 Binary files /dev/null and b/test/expected/karnaugh-option-omit-tikzpicture-default.pdf differ diff --git a/test/expected/karnaugh-option-omit-tikzpicture.pdf b/test/expected/karnaugh-option-omit-tikzpicture.pdf new file mode 120000 index 0000000..c06d3b4 --- /dev/null +++ b/test/expected/karnaugh-option-omit-tikzpicture.pdf @@ -0,0 +1 @@ +karnaugh-option-omit-tikzpicture-default.pdf \ No newline at end of file diff --git a/test/expected/karnaugh-terms-omit-tikzpicture.pdf b/test/expected/karnaugh-terms-omit-tikzpicture.pdf new file mode 100644 index 0000000..3d9db86 Binary files /dev/null and b/test/expected/karnaugh-terms-omit-tikzpicture.pdf differ diff --git a/test/karnaugh-221-label-omit-tikzpicture-global-option.tex b/test/karnaugh-221-label-omit-tikzpicture-global-option.tex new file mode 100644 index 0000000..e3bd9f9 --- /dev/null +++ b/test/karnaugh-221-label-omit-tikzpicture-global-option.tex @@ -0,0 +1,17 @@ +\documentclass{standalone} +\usepackage[omittikzpicture]{../karnaugh-map} +\begin{document} + % v1/v2 label + \begin{tikzpicture} + \begin{karnaugh-map}[2][2][1] + \end{karnaugh-map} + \end{tikzpicture} + \begin{tikzpicture} + \begin{karnaugh-map}[2][2][1][$a$] + \end{karnaugh-map} + \end{tikzpicture} + \begin{tikzpicture} + \begin{karnaugh-map}[2][2][1][$a$][$b$] + \end{karnaugh-map} + \end{tikzpicture} +\end{document} diff --git a/test/karnaugh-221-label-omit-tikzpicture.tex b/test/karnaugh-221-label-omit-tikzpicture.tex new file mode 100644 index 0000000..4c1e604 --- /dev/null +++ b/test/karnaugh-221-label-omit-tikzpicture.tex @@ -0,0 +1,17 @@ +\documentclass{standalone} +\usepackage{../karnaugh-map} +\begin{document} + % v1/v2 label + \begin{tikzpicture} + \begin{karnaugh-map}(omittikzpicture)[2][2][1] + \end{karnaugh-map} + \end{tikzpicture} + \begin{tikzpicture} + \begin{karnaugh-map}(omittikzpicture)[2][2][1][$a$] + \end{karnaugh-map} + \end{tikzpicture} + \begin{tikzpicture} + \begin{karnaugh-map}(omittikzpicture)[2][2][1][$a$][$b$] + \end{karnaugh-map} + \end{tikzpicture} +\end{document} diff --git a/test/karnaugh-option-omit-tikzpicture-default.tex b/test/karnaugh-option-omit-tikzpicture-default.tex new file mode 100644 index 0000000..9e87f10 --- /dev/null +++ b/test/karnaugh-option-omit-tikzpicture-default.tex @@ -0,0 +1,42 @@ +\documentclass{standalone} +\usepackage[omittikzpicture]{../karnaugh-map} +\begin{document} + \begin{tikzpicture} + \begin{karnaugh-map}[4][4][1] + \implicant{0}{0} + \implicant{1}{1} + \implicant{2}{2} + \implicant{3}{3} + \implicant{4}{4} + \implicant{5}{5} + \implicant{6}{6} + \implicant{7}{7} + \implicant{8}{8} + \implicant{9}{9} + \implicant{10}{10} + \implicant{11}{11} + \implicant{12}{12} + \implicant{13}{13} + \implicant{14}{14} + \implicant{15}{15} + \end{karnaugh-map} + \end{tikzpicture} + \begin{karnaugh-map}(omittikzpicture=false)[4][4][1] + \implicant{0}{0} + \implicant{1}{1} + \implicant{2}{2} + \implicant{3}{3} + \implicant{4}{4} + \implicant{5}{5} + \implicant{6}{6} + \implicant{7}{7} + \implicant{8}{8} + \implicant{9}{9} + \implicant{10}{10} + \implicant{11}{11} + \implicant{12}{12} + \implicant{13}{13} + \implicant{14}{14} + \implicant{15}{15} + \end{karnaugh-map} +\end{document} diff --git a/test/karnaugh-option-omit-tikzpicture.tex b/test/karnaugh-option-omit-tikzpicture.tex new file mode 100644 index 0000000..0015848 --- /dev/null +++ b/test/karnaugh-option-omit-tikzpicture.tex @@ -0,0 +1,42 @@ +\documentclass{standalone} +\usepackage{../karnaugh-map} +\begin{document} + \begin{tikzpicture} + \begin{karnaugh-map}(omittikzpicture)[4][4][1] + \implicant{0}{0} + \implicant{1}{1} + \implicant{2}{2} + \implicant{3}{3} + \implicant{4}{4} + \implicant{5}{5} + \implicant{6}{6} + \implicant{7}{7} + \implicant{8}{8} + \implicant{9}{9} + \implicant{10}{10} + \implicant{11}{11} + \implicant{12}{12} + \implicant{13}{13} + \implicant{14}{14} + \implicant{15}{15} + \end{karnaugh-map} + \end{tikzpicture} + \begin{karnaugh-map}[4][4][1] + \implicant{0}{0} + \implicant{1}{1} + \implicant{2}{2} + \implicant{3}{3} + \implicant{4}{4} + \implicant{5}{5} + \implicant{6}{6} + \implicant{7}{7} + \implicant{8}{8} + \implicant{9}{9} + \implicant{10}{10} + \implicant{11}{11} + \implicant{12}{12} + \implicant{13}{13} + \implicant{14}{14} + \implicant{15}{15} + \end{karnaugh-map} +\end{document} diff --git a/test/karnaugh-terms-omit-tikzpicture.tex b/test/karnaugh-terms-omit-tikzpicture.tex new file mode 100644 index 0000000..ec2e4d5 --- /dev/null +++ b/test/karnaugh-terms-omit-tikzpicture.tex @@ -0,0 +1,105 @@ +\documentclass{standalone} +\usepackage{../karnaugh-map} +\begin{document} + % fill all fields (autoterms) + \begin{tikzpicture} + \begin{karnaugh-map}(omittikzpicture)[2][2][1] + \autoterms[-] + \end{karnaugh-map} + \end{tikzpicture} + \begin{tikzpicture} + \begin{karnaugh-map}(omittikzpicture)[2][4][1] + \autoterms[-] + \end{karnaugh-map} + \end{tikzpicture} + \begin{tikzpicture} + \begin{karnaugh-map}(omittikzpicture)[4][2][1] + \autoterms[-] + \end{karnaugh-map} + \end{tikzpicture} + \begin{tikzpicture} + \begin{karnaugh-map}(omittikzpicture)[4][4][1] + \autoterms[-] + \end{karnaugh-map} + \end{tikzpicture} + \begin{tikzpicture} + \begin{karnaugh-map}(omittikzpicture)[4][4][2] + \autoterms[-] + \end{karnaugh-map} + \end{tikzpicture} + \begin{tikzpicture} + \begin{karnaugh-map}(omittikzpicture)[4][4][4] + \autoterms[-] + \end{karnaugh-map} + \end{tikzpicture} + % fill remaining after '\indeterminants' '\manualterms' '\maxterms' and '\minterms' + \begin{tikzpicture} + \begin{karnaugh-map}(omittikzpicture)[2][2][1] + \manualterms{m} + \indeterminants{1} + \maxterms{2} + \minterms{3} + \autoterms[a] + \end{karnaugh-map} + \end{tikzpicture} + \begin{tikzpicture} + \begin{karnaugh-map}(omittikzpicture)[2][2][1] + \manualterms{m} + \terms{1}{T} + \indeterminants{1} + \maxterms{2} + \minterms{3} + \autoterms[a] + \end{karnaugh-map} + \end{tikzpicture} + \begin{tikzpicture} + \begin{karnaugh-map}(omittikzpicture)[2][4][1] + \manualterms{m} + \indeterminants{1} + \maxterms{2} + \minterms{3} + \terms{4}{T} + \autoterms[a] + \end{karnaugh-map} + \end{tikzpicture} + \begin{tikzpicture} + \begin{karnaugh-map}(omittikzpicture)[4][2][1] + \manualterms{m} + \indeterminants{1} + \maxterms{2} + \minterms{3} + \terms{4}{T} + \autoterms[a] + \end{karnaugh-map} + \end{tikzpicture} + \begin{tikzpicture} + \begin{karnaugh-map}(omittikzpicture)[4][4][1] + \manualterms{m,m} + \indeterminants{2,3} + \maxterms{4,5} + \minterms{6,7} + \terms{8,9}{T} + \autoterms[a] + \end{karnaugh-map} + \end{tikzpicture} + \begin{tikzpicture} + \begin{karnaugh-map}(omittikzpicture)[4][4][2] + \manualterms{m,m,m,m} + \indeterminants{4,5,6,7} + \maxterms{8,9,10,11} + \minterms{12,13,14,15} + \terms{16,17,18,19}{T} + \autoterms[a] + \end{karnaugh-map} + \end{tikzpicture} + \begin{tikzpicture} + \begin{karnaugh-map}(omittikzpicture)[4][4][4] + \manualterms{m,m,m,m} + \indeterminants{4,5,6,7} + \maxterms{8,9,10,11} + \minterms{12,13,14,15} + \terms{16,17,18,19}{T} + \autoterms[a] + \end{karnaugh-map} + \end{tikzpicture} +\end{document}