[Tex/LaTex] Drawing Karnaugh Map – Modification in karnaugh-map package

karnaughtikz-pgf

I need to draw Karnaugh Map for a book. package mentioned in this answer Drawing Karnaugh's maps in LaTeX is excellent. I have two questions

  1. How to turn colouring On.
  2. Can we shift position of x,y,z as shown in the alternate answer

.

\documentclass{memoir}    
\usepackage{tikz,xcolor}
\usepackage{karnaugh-map}
\begin{document}
    \begin{karnaugh-map}*[4][2][1][$yz$][$x$]
        \maxterms{0,2,3}
        \minterms{1,4,5,6,7}
        \autoterms[X]
        \implicant{4}{6}
        \implicant{1}{5}
    \end{karnaugh-map}
\end{document}

Best Answer

  1. According to the documentation (see here) removing the star at the start of the karnaugh-map environment is the right way. It should be \begin{karnaugh-map}[4][2][1][$yz$][$x$] then.

  2. Without making changes to the source code of the package itself this does not seem to be possible as the positions for the labels are "hardcoded" (source code). If you comment out lines 250 to 268 inside karnaugh-map.sty you could play a little bit based on this code:

    \documentclass{standalone}
    \usepackage{karnaugh-map}
    \begin{document}
        \begin{karnaugh-map}[4][2][1][$yz$][$x$]
            \maxterms{0,2,3}
            \minterms{1,4,5,6,7}
            \autoterms[X]
            \implicant{4}{6}
            \implicant{1}{5}
            \node at (-0.25,2.5) {$yz$};           % row name
            \node at (-0.6,2.25) {$x$};            % column name
            \draw[ultra thin] (0,2) -- (-1,2.75);  % diagonal line
        \end{karnaugh-map}
    \end{document}