# Drawing 4-variable Karnaugh map: concerns related to karnaugh-map package and tikzpicture

I am not very familiar with both packages, mainly the karnaugh-map package. I am trying to make a Karnaugh Map of 4 variables and using two different approaches I could get the results partially in one and partially in another.

Using the karnaugh-map package:

\begin{karnaugh-map}*[4][4][1][][]
\maxterms{0,1,2,3,4,5,6}
\minterms{7}
\autoterms[X]
\implicant{7}{15}
\end{karnaugh-map}


Using tikzpicture:

\begin{tikzpicture}[thick]
\karnaughmap
[omitidx,omitbinaries,
omitnegated=false,
variables={{Q_1}{Q_0}{Q_3}{Q_2}},
function=J_3]
{00XX 00XX 00XX 01XX}
\end{tikzpicture}



The final map I want to accomplish is equal to the second map, but has the square of the first map (\implicant{7}{15}), using the package you can easily set the groups. But I don't want the binaries presented in the first map. I would like the variables visible as the second map, but the value 0 is not shown and I couldn't draw the square. On the other hand, it has the functions omitidx and omitbinaries.

I am not sure if there's another package or way to accomplish it. Using the karnaugh-map package the \implicant  function makes it way easy to drawn the squares and show the groups, but it is harder using tikzpicture.

In the first scope is your (second) code with two lines added. The first one is the option omitzeros=false which shows the zeros, and the second is a \draw command that draws the desired rectangle with tikz. I also show a second scope with an additional example.

\documentclass{standalone}
\usepackage{karnaughmap}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[thick]
\begin{scope} % first map
\karnaughmap
[omitidx,omitbinaries,
omitnegated=false,
omitzeros=false, % to show the zeros
variables={{Q_1}{Q_0}{Q_3}{Q_2}},
function=J_3]
{00XX 00XX 00XX 01XX}
\draw [red, rounded corners] (2.1,1.1) rectangle (2.9,2.9);
\end{scope}
\begin{scope}[shift={(7,0)}] % second map
\karnaughmap
[omitidx,omitbinaries,
omitnegated=false,
omitzeros=false, % to show the zeros
variables={{Q_1}{Q_0}{Q_3}{Q_2}},
function=J_3']
{10XX 00XX 00XX 00XX}
\draw[red, rounded corners] (0.1,0) -- (0.1,0.9) -| (0.9,0);
\draw[red, rounded corners] (0.1,4) -- (0.1,3.1) -| (0.9,4);
\end{scope}
\end{tikzpicture}
\end{document}