我想将 Karnaughquatre 和数组并排放置并居中。我该如何实现?
\begin{Karnaughquatre}
\contingut{1, 0, 0, 1}
\end{Karnaughquatre}
\begin{displaymath}
\begin{array}{C C|C}
$A$ & $B$ & $F$\\
\hline
0 & 0 & 1\\
0 & 1 & 0\\
1 & 0 & 0\\
1 & 1 & 1
\end{array}
\end{displaymath}
编辑1:
以下是MWE:
\documentclass[twoside]{article}
\setlength{\oddsidemargin}{0.25 in}
\setlength{\evensidemargin}{-0.25 in}
\setlength{\topmargin}{-0.6 in}
\setlength{\textwidth}{6.5 in}
\setlength{\textheight}{8.5 in}
\setlength{\headsep}{0.75 in}
\setlength{\parindent}{0 in}
\setlength{\parskip}{0.1 in}
%
% ADD PACKAGES here:
%
\usepackage{amsmath,amsfonts,graphicx}
%
% The following commands set up the lecnum (lecture number)
% counter and make various numbering schemes work relative
% to the lecture number.
%
\newcounter{lecnum}
\renewcommand{\thepage}{\thelecnum-\arabic{page}}
\renewcommand{\thesection}{\thelecnum.\arabic{section}}
\renewcommand{\theequation}{\thelecnum.\arabic{equation}}
\renewcommand{\thefigure}{\thelecnum.\arabic{figure}}
\renewcommand{\thetable}{\thelecnum.\arabic{table}}
%
% The following macro is used to generate the header.
%
\newcommand{\lecture}[4]{
\pagestyle{myheadings}
\thispagestyle{plain}
\newpage
\setcounter{lecnum}{#1}
\setcounter{page}{1}
\noindent
\begin{center}
\framebox{
\vbox{\vspace{2mm}
\hbox to 6.28in { {\bf Logic Design
\hfill Fall 2017} }
\vspace{4mm}
\hbox to 6.28in { {\Large \hfill Lecture #1: #2 \hfill} }
\vspace{2mm}
\hbox to 6.28in { {\it Lecturer: #3 \hfill Scribes: #4} }
\vspace{2mm}}
}
\end{center}
\markboth{Lecture #1: #2}{Lecture #1: #2}
{\bf Note}: {\it LaTeX notes for Logic Design.}
{\bf Disclaimer}: {\it These notes have not been subjected to the
usual scrutiny reserved for formal publications. They may be distributed
outside this class only with the permission of the Instructor.}
\vspace*{4mm}
}
\newcommand\E{\mathbb{E}}
\usepackage{tikz}
\usetikzlibrary{matrix,calc}
%Empty Karnaugh map 2x2
\newenvironment{Karnaughquatre}%
{
\begin{tikzpicture}[baseline=(current bounding box.north),scale=0.8]
\draw (0,0) grid (2,2);
\draw (0,2) -- node [pos=0.7,above right,anchor=south west] {b} node [pos=0.7,below left,anchor=north east] {a} ++(135:1);
%
\matrix (mapa) [matrix of nodes,
column sep={0.8cm,between origins},
row sep={0.8cm,between origins},
every node/.style={minimum size=0.3mm},
anchor=2.center,
ampersand replacement=\&] at (0.5,0.5)
{
\& |(c00)| 0 \& |(c01)| 1 \\
|(r00)| 0 \& |(0)| \phantom{0} \& |(1)| \phantom{0} \\
|(r01)| 1 \& |(2)| \phantom{0} \& |(3)| \phantom{0} \\
};
}%
{
\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};
}
\usepackage{amsmath}
\usepackage{array}
\newcolumntype{C}{>$c<$}
\begin{document}
%FILL IN THE RIGHT INFO.
%\lecture{**LECTURE-NUMBER**}{**DATE**}{**LECTURER**}{**SCRIBE**}
\lecture{5}{November 08}{Paschalis Antonis}{Platon Kiorpelidis}
%\footnotetext{These notes are partially based on those of Nigel Mansell.}
% **** YOUR NOTES GO HERE:
% Some general latex examples and examples making use of the
% macros follow.
%**** IN GENERAL, BE BRIEF. LONG SCRIBE NOTES, NO MATTER HOW WELL WRITTEN,
%**** ARE NEVER READ BY ANYBODY.
\section{K-map of 2 variables}
\vspace{2pt}
\begin{center}
\begin{Karnaughquatre}
\contingut{1, 0, 0, 1}
\end{Karnaughquatre}
\begin{displaymath}
\begin{array}{C C|C}
$A$ & $B$ & $F$\\
\hline
0 & 0 & 1\\
0 & 1 & 0\\
1 & 0 & 0\\
1 & 1 & 1
\end{array}
\end{displaymath}
\end{center}
\end{document}
答案1
放置array
内部$
分隔符(而不是displaymath
)以使其成为可以与其他内容放在同一行的内联框。
然后,我将stackengine
放在Karnaughquatre
基线上,并使用[b]
对齐array
进行同样的操作。\qquad
在它们之间放置 A 以进行分隔。
的垂直移位Karnaughquatre
可以通过可选参数 进行进一步调整\abovebaseline
,当前设置为0pt
。
\documentclass[twoside]{article}
\setlength{\oddsidemargin}{0.25 in}
\setlength{\evensidemargin}{-0.25 in}
\setlength{\topmargin}{-0.6 in}
\setlength{\textwidth}{6.5 in}
\setlength{\textheight}{8.5 in}
\setlength{\headsep}{0.75 in}
\setlength{\parindent}{0 in}
\setlength{\parskip}{0.1 in}
%
% ADD PACKAGES here:
%
\usepackage{amsmath,amsfonts,graphicx}
%
% The following commands set up the lecnum (lecture number)
% counter and make various numbering schemes work relative
% to the lecture number.
%
\newcounter{lecnum}
\renewcommand{\thepage}{\thelecnum-\arabic{page}}
\renewcommand{\thesection}{\thelecnum.\arabic{section}}
\renewcommand{\theequation}{\thelecnum.\arabic{equation}}
\renewcommand{\thefigure}{\thelecnum.\arabic{figure}}
\renewcommand{\thetable}{\thelecnum.\arabic{table}}
%
% The following macro is used to generate the header.
%
\newcommand{\lecture}[4]{
\pagestyle{myheadings}
\thispagestyle{plain}
\newpage
\setcounter{lecnum}{#1}
\setcounter{page}{1}
\noindent
\begin{center}
\framebox{
\vbox{\vspace{2mm}
\hbox to 6.28in { {\bf Logic Design
\hfill Fall 2017} }
\vspace{4mm}
\hbox to 6.28in { {\Large \hfill Lecture #1: #2 \hfill} }
\vspace{2mm}
\hbox to 6.28in { {\it Lecturer: #3 \hfill Scribes: #4} }
\vspace{2mm}}
}
\end{center}
\markboth{Lecture #1: #2}{Lecture #1: #2}
{\bf Note}: {\it LaTeX notes for Logic Design.}
{\bf Disclaimer}: {\it These notes have not been subjected to the
usual scrutiny reserved for formal publications. They may be distributed
outside this class only with the permission of the Instructor.}
\vspace*{4mm}
}
\newcommand\E{\mathbb{E}}
\usepackage{tikz}
\usetikzlibrary{matrix,calc}
%Empty Karnaugh map 2x2
\newenvironment{Karnaughquatre}%
{
\begin{tikzpicture}[baseline=(current bounding box.north),scale=0.8]
\draw (0,0) grid (2,2);
\draw (0,2) -- node [pos=0.7,above right,anchor=south west] {b} node [pos=0.7,below left,anchor=north east] {a} ++(135:1);
%
\matrix (mapa) [matrix of nodes,
column sep={0.8cm,between origins},
row sep={0.8cm,between origins},
every node/.style={minimum size=0.3mm},
anchor=2.center,
ampersand replacement=\&] at (0.5,0.5)
{
\& |(c00)| 0 \& |(c01)| 1 \\
|(r00)| 0 \& |(0)| \phantom{0} \& |(1)| \phantom{0} \\
|(r01)| 1 \& |(2)| \phantom{0} \& |(3)| \phantom{0} \\
};
}%
{
\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};
}
\usepackage{amsmath}
\usepackage{array}
\newcolumntype{C}{>$c<$}
\usepackage{stackengine}
\begin{document}
%FILL IN THE RIGHT INFO.
%\lecture{**LECTURE-NUMBER**}{**DATE**}{**LECTURER**}{**SCRIBE**}
\lecture{5}{November 08}{Paschalis Antonis}{Platon Kiorpelidis}
%\footnotetext{These notes are partially based on those of Nigel Mansell.}
% **** YOUR NOTES GO HERE:
% Some general latex examples and examples making use of the
% macros follow.
%**** IN GENERAL, BE BRIEF. LONG SCRIBE NOTES, NO MATTER HOW WELL WRITTEN,
%**** ARE NEVER READ BY ANYBODY.
\section{K-map of 2 variables}
\vspace{2pt}
\begin{center}
\abovebaseline[0pt]{%
\begin{Karnaughquatre}
\contingut{1, 0, 0, 1}
\end{Karnaughquatre}}
\qquad
$
\begin{array}[b]{C C|C}
$A$ & $B$ & $F$\\
\hline
0 & 0 & 1\\
0 & 1 & 0\\
1 & 0 & 0\\
1 & 1 & 1
\end{array}
$
\end{center}
\end{document}