![更改卡诺图 tikzpicture 的否定顺序](https://linux22.com/image/353384/%E6%9B%B4%E6%94%B9%E5%8D%A1%E8%AF%BA%E5%9B%BE%20tikzpicture%20%E7%9A%84%E5%90%A6%E5%AE%9A%E9%A1%BA%E5%BA%8F.png)
我知道已经有很多很棒的卡诺问题,但我的问题具体是关于对karnaughmap
卡诺图的否定进行重新排序。
我目前正在使用karnaughmap
-Michael Vonbun 提供的软件包,但我并不受此软件包的约束。该软件包非常易于使用,我已经能够有点重现我所寻找的内容:
这是我的 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}
我误用了变量命名和二进制来获得逆时针命名。我对此很满意,直到我发现 x_0 和 x_1 的负号是关闭的。这意味着里面的真值根本没有意义。
我怎样才能将负号从左侧的 x_0 移动到右侧的 x_0?
我或多或少没有 TikZ 经验,这就是我为此使用包的原因。
这包装文档待办事项第 36 页指出,目前无法通过直接 TikZ 交互来排列卡诺图。
我的目标:
通过图像处理完成,红色箭头显示发生了哪些变化
答案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}