更改 karnaughmap tikzpicture 的否定順序

更改 karnaughmap tikzpicture 的否定順序

我知道已經有很棒的卡諾問題了,但我的問題專門是關於重新排序地圖的否定karnaughmap

我目前正在使用karnaughmap-Michael Vonbun 提供的軟體包,但我不受此軟體包的約束。該軟體包非常易於使用,我已經能夠有點重現我想要的內容:

手繪 KV 圖的影像 TikZ KV 圖的影像

這是我的 LaTeX 程式碼:

\documentclass{article}
\usepackage{karnaughmap}

\begin{document}

    \begin{tikzpicture}[thick]
    \karnaughmapcolorfield{4}{028a}{violet!50}

    \karnaughmap
    [omitidx,omitbinaries,
    omitnegated=false,
    variables={{x_0}{x_2}{x_1}{x_3}},
    function=y_0]
    {1010 0000 1010 0000}
    % i actually want to display 1111 0000 0000 0000
    \end{tikzpicture}

\end{document}

在 sharelatex.com 上查看結果

我濫用變數命名和二進制來獲得逆時針命名。我對此表示同意,直到我發現 x_0 和 x_1 的否定欄已關閉。這意味著裡面的真值根本沒有任何意義。

如何將否定欄從左側的 x_0 移到右側的 x_0?

我或多或少沒有 TikZ 經驗,這就是為什麼我為此使用了一個包。

包文件在待辦事項註釋中的第 36 頁上指出,目前無法透過直接 TikZ 互動來排列卡諾圖。

我的目標:

TikZ KV 圖的處理影像

透過影像處理完成,紅色箭頭顯示發生了什麼變化

答案1

我已經調整了我的答案在 LaTeX 中繪製卡諾圖以滿足您的需求。

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix}

%Empty Karnaugh map 4x4
\newenvironment{Karnaugh}%
{
\begin{tikzpicture}[baseline=(current bounding box.north),scale=0.8]

\matrix (mapa) [matrix of nodes,
           nodes in empty cells,
         column sep=-\pgflinewidth,
         row sep=-\pgflinewidth,
         every node/.style={draw, minimum size=8mm, outer sep=0pt},
         row 1/.style={every node/.style={draw=none, minimum size=8mm, outer sep=0pt}},
         column 1/.style={every node/.style={draw=none, minimum size=8mm, outer sep=0pt}},
        ampersand replacement=\&]
{
|[draw=none]| \&[2mm] |(c01)| \& |(c11)| \& |(c10)| \& |(c00)| \\[2mm]
|(r01)| \& |(3)|  \& |(7)|  \& |(6)|  \& |(2)|  \\
|(r11)| \& |(11)| \& |(15)| \& |(14)| \& |(10)| \\
|(r10)| \& |(9)|  \& |(13)| \& |(12)| \& |(8)|  \\
|(r00)| \& |(1)|  \& |(5)|  \& |(4)|  \& |(0)|  \\
};
\draw (3.north west) -- node [pos=0.7,above right,anchor=south west, inner sep=1pt] {$x_2x_0$} node [pos=0.7,below left,anchor=north east, inner sep=1pt] {$x_3x_1$} ++(135:1);

\draw ([xshift=1mm]c01.south west)--node[above] {$x_0$} ([xshift=-1mm]c11.south east);
\draw ([xshift=1mm]c10.south west)--node[above] {$\overline{x_0}$} ([xshift=-1mm]c00.south east);
\draw ([yshift=-1mm]r01.north east)--node[left] {$x_1$} ([yshift=1mm]r11.south east);
\draw ([yshift=-1mm]r10.north east)--node[left] {$\overline{x_1}$} ([yshift=1mm]r00.south east);
\draw ([shift={(2mm,-1mm)}]2.north east)--node[right] {$\overline{x_3}$} ([shift={(2mm,1mm)}]2.south east);
\draw ([shift={(2mm,-1mm)}]10.north east)--node[right] {$x_3$} ([shift={(2mm,1mm)}]8.south east);
\draw ([shift={(2mm,-1mm)}]0.north east)--node[right] {$\overline{x_3}$} ([shift={(2mm,1mm)}]0.south east);
\draw ([shift={(1mm,-2mm)}]1.south west)--node[below] {$\overline{x_2}$} ([shift={(-1mm,-2mm)}]1.south east);
\draw ([shift={(1mm,-2mm)}]5.south west)--node[below] {$x_2$} ([shift={(-1mm,-2mm)}]4.south east);
\draw ([shift={(1mm,-2mm)}]0.south west)--node[below] {$\overline{x_2}$} ([shift={(-1mm,-2mm)}]0.south east);

}%
{
\end{tikzpicture}
}

%Defines 8 or 16 values (0,1,X)
\newcommand{\contingut}[1]{%
\foreach \x [count=\xi from 0]  in {#1}
     \path (\xi) node {\x};
}

%color fields
%#1 - comma separated list of filling terms. 
%#2 - filling color
\newcommand{\colorfields}[2]{%
\foreach \i in {#1}
   \fill[#2, opacity=.3] (\i.north west) rectangle (\i.south east);
}

%Places 1 in listed positions
\newcommand{\minterms}[1]{%
    \foreach \x in {#1}
        \path (\x) node {1};
}

%Places 0 in listed positions
\newcommand{\maxterms}[1]{%
    \foreach \x in {#1}
        \path (\x) node {0};
}

%Places X in listed positions
\newcommand{\indeterminats}[1]{%
    \foreach \x in {#1}
        \path (\x) node {X};
}

\begin{document}
\begin{Karnaugh}
\minterms{0,1,2,3}
\colorfields{0,1,2,3}{red}
\end{Karnaugh}
\end{document}

在此輸入影像描述

相關內容