Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 35 additions & 4 deletions karnaugh-map.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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@);
Expand Down Expand Up @@ -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}
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions test/expected/karnaugh-option-omit-tikzpicture.pdf
Binary file not shown.
17 changes: 17 additions & 0 deletions test/karnaugh-221-label-omit-tikzpicture-global-option.tex
Original file line number Diff line number Diff line change
@@ -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}
17 changes: 17 additions & 0 deletions test/karnaugh-221-label-omit-tikzpicture.tex
Original file line number Diff line number Diff line change
@@ -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}
42 changes: 42 additions & 0 deletions test/karnaugh-option-omit-tikzpicture-default.tex
Original file line number Diff line number Diff line change
@@ -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}
42 changes: 42 additions & 0 deletions test/karnaugh-option-omit-tikzpicture.tex
Original file line number Diff line number Diff line change
@@ -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}
105 changes: 105 additions & 0 deletions test/karnaugh-terms-omit-tikzpicture.tex
Original file line number Diff line number Diff line change
@@ -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}