看看以下 MWE
\documentclass[t]{beamer}
\usepackage{siunitx,tikz}
\usepackage{amsmath}
\usepackage{color}
\usepackage{flexisym}
\usepackage{enumerate}
\usetikzlibrary{positioning,arrows,shapes.gates.logic.US,shapes.gates.logic.IEC,calc}
\usepackage{makecell}
\usefonttheme[onlymath]{serif}
\setbeamercolor{postit}{fg=black,bg=blue!10}
\usepackage{ragged2e}
\usepackage{etoolbox}
\apptocmd{\frame}{}{\justifying}{} % Allow optional arguments after frame.
\usepackage{colortbl}
\tikzstyle{branch}=[fill,shape=circle,minimum size=4pt,inner sep=0pt]
\begin{document}
%################## Exercise 1 ###########################
\begin{frame}
\begin{center}
\begin{tikzpicture}[very thick]
\node (x) at (0,.46) {$x$};
\node (y) at (0,0) {$y$};
\node[and gate US, draw, logic gate inputs=nnn] at ($(y)+(1.5,.23)$) (And) {};
\draw (x) -- (And.input 1) ;
\draw (y) -- (And.input 3) ;
\draw (And.output) -- node[above] {$xy$} ([xshift=1.5cm]And.output);
\node[above=of And] {AND};
%===============
\node (x1) at (5,.46) {$x$};
\node (y1) at (5,0) {$y$};
\node[or gate US, draw, logic gate inputs=nnn] at ($(y1)+(1.5,.23)$) (OR) {};
\draw (x1) -- (OR.input 1) ;
\draw (y1) -- (OR.input 3) ;
\draw (OR.output) -- node[above] {$x+y$} ([xshift=1.5cm]OR.output);
\node[above=of OR] {OR};
\node (x2) at (0,-2) {$x$};
\node[not gate US, draw, logic gate inputs=nnn] at ($(x2)+(1.5,0)$) (Not) {};
\draw (x2) -- (Not.input) ;
\draw (Not.output) -- node[above] {$x'$} ([xshift=1.5cm]Not.output);
\node[above=of Not] {Inverter};
\node (x3) at (5,-2) {$x$};
\node[buffer gate US, draw, logic gate inputs=nnn] at ($(x3)+(1.5,0)$) (Buffer) {};
\draw (x3) -- (Buffer.input) ;
\draw (Buffer.output) -- node[above] {$x$} ([xshift=1.5cm]Buffer.output);
\node[above=of Buffer] {Buffer};
\node (x4) at (0,-3.56) {$x$};
\node (y4) at (0,-4) {$y$};
\node[nand gate US, draw, logic gate inputs=nnn] at ($(x4)+(1.5,-.2)$) (Nand) {};
\draw (x4) -- (Nand.input 1) ;
\draw (y4) -- (Nand.input 3) ;
\draw (Nand.output) -- node[above] {$(xy)'$} ([xshift=1.5cm]Nand.output);
\node[above=of Nand,,yshift=-.1cm] {NAND};
\node (x5) at (5,-3.56) {$x$};
\node (y5) at (5,-4) {$y$};
\node[nor gate US, draw, logic gate inputs=nnn] at ($(x5)+(1.5,-.2)$) (Nor) {};
\draw (x5) -- (Nor.input 1) ;
\draw (y5) -- (Nor.input 3) ;
\draw (Nor.output) -- node[above] {$(x+y)'$} ([xshift=1.5cm]Nor.output);
\node[above=of Nor,,yshift=-.1cm] {NOR};
\node (x6) at (0,-5.2) {$x$};
\node (y6) at (0,-5.43) {$y$};
\node[xor gate US, draw, logic gate inputs=nn] at ($(x6)+(1.5,-.12)$) (Xor) {};
\draw (x6) -- (Xor.input 1) ;
\draw (y6) -- (Xor.input 2) ;
\draw (Xor.output) -- node[above] {$xy'+ x'y$} ([xshift=1.5cm]Xor.output);
\node[above=of Xor,,yshift=-.2cm] {XOR};
\node (x7) at (5,-5.2) {$x$};
\node (y7) at (5,-5.43) {$y$};
\node[xnor gate US, draw, logic gate inputs=nn] at ($(x7)+(1.5,-.12)$) (Nor) {};
\draw (x7) -- (Nor.input 1) ;
\draw (y7) -- (Nor.input 2) ;
\draw (Nor.output) -- node[above] {$xy+ x'y'$} ([xshift=1.5cm]Nor.output);
\node[above=of Nor,,yshift=-.2cm] {XNOR};
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}
由此得出了这张混乱的图片
不过,在独立模式下,输出是令人满意的。
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows,shapes.gates.logic.US,shapes.gates.logic.IEC,calc}
\begin{document}
\begin{tikzpicture}[node distance=.2cm,label distance=2mm,very thick]
\node (x) at (0,.46) {$x$};
\node (y) at (0,0) {$y$};
\node[and gate US, draw, logic gate inputs=nnn] at ($(y)+(1.5,.23)$) (And) {};
\draw (x) -- (And.input 1) ;
\draw (y) -- (And.input 3) ;
\draw (And.output) -- node[above] {$xy$} ([xshift=1.5cm]And.output);
\node[above=of And] {AND};
%===============
\node (x1) at (5,.46) {$x$};
\node (y1) at (5,0) {$y$};
\node[or gate US, draw, logic gate inputs=nnn] at ($(y1)+(1.5,.23)$) (OR) {};
\draw (x1) -- (OR.input 1) ;
\draw (y1) -- (OR.input 3) ;
\draw (OR.output) -- node[above] {$x+y$} ([xshift=1.5cm]OR.output);
\node[above=of OR] {OR};
\node (x2) at (0,-2) {$x$};
\node[not gate US, draw, logic gate inputs=nnn] at ($(x2)+(1.5,0)$) (Not) {};
\draw (x2) -- (Not.input) ;
\draw (Not.output) -- node[above] {$x'$} ([xshift=1.5cm]Not.output);
\node[above=of Not] {Inverter};
\node (x3) at (5,-2) {$x$};
\node[buffer gate US, draw, logic gate inputs=nnn] at ($(x3)+(1.5,0)$) (Buffer) {};
\draw (x3) -- (Buffer.input) ;
\draw (Buffer.output) -- node[above] {$x$} ([xshift=1.5cm]Buffer.output);
\node[above=of Buffer] {Buffer};
\node (x4) at (0,-3.56) {$x$};
\node (y4) at (0,-4) {$y$};
\node[nand gate US, draw, logic gate inputs=nnn] at ($(x4)+(1.5,-.2)$) (Nand) {};
\draw (x4) -- (Nand.input 1) ;
\draw (y4) -- (Nand.input 3) ;
\draw (Nand.output) -- node[above] {$(xy)'$} ([xshift=1.5cm]Nand.output);
\node[above=of Nand,,yshift=-.1cm] {NAND};
\node (x5) at (5,-3.56) {$x$};
\node (y5) at (5,-4) {$y$};
\node[nor gate US, draw, logic gate inputs=nnn] at ($(x5)+(1.5,-.2)$) (Nor) {};
\draw (x5) -- (Nor.input 1) ;
\draw (y5) -- (Nor.input 3) ;
\draw (Nor.output) -- node[above] {$(x+y)'$} ([xshift=1.5cm]Nor.output);
\node[above=of Nor,,yshift=-.1cm] {NOR};
\node (x6) at (0,-5.2) {$x$};
\node (y6) at (0,-5.43) {$y$};
\node[xor gate US, draw, logic gate inputs=nn] at ($(x6)+(1.5,-.12)$) (Xor) {};
\draw (x6) -- (Xor.input 1) ;
\draw (y6) -- (Xor.input 2) ;
\draw (Xor.output) -- node[above] {$xy'+ x'y$} ([xshift=1.5cm]Xor.output);
\node[above=of Xor,,yshift=-.2cm] {XOR};
\node (x7) at (5,-5.2) {$x$};
\node (y7) at (5,-5.43) {$y$};
\node[xnor gate US, draw, logic gate inputs=nn] at ($(x7)+(1.5,-.12)$) (Nor) {};
\draw (x7) -- (Nor.input 1) ;
\draw (y7) -- (Nor.input 2) ;
\draw (Nor.output) -- node[above] {$xy+ x'y'$} ([xshift=1.5cm]Nor.output);
\node[above=of Nor,,yshift=-.2cm] {XNOR};
\end{tikzpicture}
\end{document}
有任何线索可以解释为什么会发生这种情况吗?谢谢。
答案1
独立也有同样的问题:
\documentclass{standalone}
%\usepackage{siunitx,
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{color}
\usepackage{flexisym}
\usepackage{enumerate}
\usetikzlibrary{positioning,arrows,shapes.gates.logic.US,shapes.gates.logic.IEC,calc}
\usepackage{makecell}
%\usefonttheme[onlymath]{serif}
%\setbeamercolor{postit}{fg=black,bg=blue!10}
\usepackage{ragged2e}
\usepackage{etoolbox}
\apptocmd{\frame}{}{\justifying}{} % Allow optional arguments after frame.
\usepackage{colortbl}
\tikzstyle{branch}=[fill,shape=circle,minimum size=4pt,inner sep=0pt]
\begin{document}
%################## Exercise 1 ###########################
%\begin{frame}
%\begin{center}
\begin{tikzpicture}[very thick]
\node (x) at (0,.46) {$x$};
\node (y) at (0,0) {$y$};
\node[and gate US, draw, logic gate inputs=nnn] at ($(y)+(1.5,.23)$) (And) {};
\draw (x) -- (And.input 1) ;
\draw (y) -- (And.input 3) ;
\draw (And.output) -- node[above] {$xy$} ([xshift=1.5cm]And.output);
\node[above=of And] {AND};
%===============
\node (x1) at (5,.46) {$x$};
\node (y1) at (5,0) {$y$};
\node[or gate US, draw, logic gate inputs=nnn] at ($(y1)+(1.5,.23)$) (OR) {};
\draw (x1) -- (OR.input 1) ;
\draw (y1) -- (OR.input 3) ;
\draw (OR.output) -- node[above] {$x+y$} ([xshift=1.5cm]OR.output);
\node[above=of OR] {OR};
\node (x2) at (0,-2) {$x$};
\node[not gate US, draw, logic gate inputs=nnn] at ($(x2)+(1.5,0)$) (Not) {};
\draw (x2) -- (Not.input) ;
\draw (Not.output) -- node[above] {$x'$} ([xshift=1.5cm]Not.output);
\node[above=of Not] {Inverter};
\node (x3) at (5,-2) {$x$};
\node[buffer gate US, draw, logic gate inputs=nnn] at ($(x3)+(1.5,0)$) (Buffer) {};
\draw (x3) -- (Buffer.input) ;
\draw (Buffer.output) -- node[above] {$x$} ([xshift=1.5cm]Buffer.output);
\node[above=of Buffer] {Buffer};
\node (x4) at (0,-3.56) {$x$};
\node (y4) at (0,-4) {$y$};
\node[nand gate US, draw, logic gate inputs=nnn] at ($(x4)+(1.5,-.2)$) (Nand) {};
\draw (x4) -- (Nand.input 1) ;
\draw (y4) -- (Nand.input 3) ;
\draw (Nand.output) -- node[above] {$(xy)'$} ([xshift=1.5cm]Nand.output);
\node[above=of Nand,,yshift=-.1cm] {NAND};
\node (x5) at (5,-3.56) {$x$};
\node (y5) at (5,-4) {$y$};
\node[nor gate US, draw, logic gate inputs=nnn] at ($(x5)+(1.5,-.2)$) (Nor) {};
\draw (x5) -- (Nor.input 1) ;
\draw (y5) -- (Nor.input 3) ;
\draw (Nor.output) -- node[above] {$(x+y)'$} ([xshift=1.5cm]Nor.output);
\node[above=of Nor,,yshift=-.1cm] {NOR};
\node (x6) at (0,-5.2) {$x$};
\node (y6) at (0,-5.43) {$y$};
\node[xor gate US, draw, logic gate inputs=nn] at ($(x6)+(1.5,-.12)$) (Xor) {};
\draw (x6) -- (Xor.input 1) ;
\draw (y6) -- (Xor.input 2) ;
\draw (Xor.output) -- node[above] {$xy'+ x'y$} ([xshift=1.5cm]Xor.output);
\node[above=of Xor,,yshift=-.2cm] {XOR};
\node (x7) at (5,-5.2) {$x$};
\node (y7) at (5,-5.43) {$y$};
\node[xnor gate US, draw, logic gate inputs=nn] at ($(x7)+(1.5,-.12)$) (Nor) {};
\draw (x7) -- (Nor.input 1) ;
\draw (y7) -- (Nor.input 2) ;
\draw (Nor.output) -- node[above] {$xy+ x'y'$} ([xshift=1.5cm]Nor.output);
\node[above=of Nor,,yshift=-.2cm] {XNOR};
\end{tikzpicture}
%\end{center}
%\end{frame}
\end{document}
输出:
解决方案...尝试尽可能使用自动距离,这样您就可以通过对基本距离进行两三次更改来解决这些问题......
经过OP编辑:使用与tikzpicture相同代码的Beamer运行良好!
\documentclass{beamer}
%\usepackage{siunitx,
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{color}
\usepackage{flexisym}
\usepackage{enumerate}
\usetikzlibrary{positioning,arrows,shapes.gates.logic.US,shapes.gates.logic.IEC,calc}
\usepackage{makecell}
%\usefonttheme[onlymath]{serif}
%\setbeamercolor{postit}{fg=black,bg=blue!10}
\usepackage{ragged2e}
\usepackage{etoolbox}
\apptocmd{\frame}{}{\justifying}{} % Allow optional arguments after frame.
\usepackage{colortbl}
\tikzstyle{branch}=[fill,shape=circle,minimum size=4pt,inner sep=0pt]
\begin{document}
\begin{frame}
\begin{tikzpicture}[node distance=.2cm,label distance=2mm,very thick]
\node (x) at (0,.46) {$x$};
\node (y) at (0,0) {$y$};
\node[and gate US, draw, logic gate inputs=nnn] at ($(y)+(1.5,.23)$) (And) {};
\draw (x) -- (And.input 1) ;
\draw (y) -- (And.input 3) ;
\draw (And.output) -- node[above] {$xy$} ([xshift=1.5cm]And.output);
\node[above=of And] {AND};
%===============
\node (x1) at (5,.46) {$x$};
\node (y1) at (5,0) {$y$};
\node[or gate US, draw, logic gate inputs=nnn] at ($(y1)+(1.5,.23)$) (OR) {};
\draw (x1) -- (OR.input 1) ;
\draw (y1) -- (OR.input 3) ;
\draw (OR.output) -- node[above] {$x+y$} ([xshift=1.5cm]OR.output);
\node[above=of OR] {OR};
\node (x2) at (0,-2) {$x$};
\node[not gate US, draw, logic gate inputs=nnn] at ($(x2)+(1.5,0)$) (Not) {};
\draw (x2) -- (Not.input) ;
\draw (Not.output) -- node[above] {$x'$} ([xshift=1.5cm]Not.output);
\node[above=of Not] {Inverter};
\node (x3) at (5,-2) {$x$};
\node[buffer gate US, draw, logic gate inputs=nnn] at ($(x3)+(1.5,0)$) (Buffer) {};
\draw (x3) -- (Buffer.input) ;
\draw (Buffer.output) -- node[above] {$x$} ([xshift=1.5cm]Buffer.output);
\node[above=of Buffer] {Buffer};
\node (x4) at (0,-3.56) {$x$};
\node (y4) at (0,-4) {$y$};
\node[nand gate US, draw, logic gate inputs=nnn] at ($(x4)+(1.5,-.2)$) (Nand) {};
\draw (x4) -- (Nand.input 1) ;
\draw (y4) -- (Nand.input 3) ;
\draw (Nand.output) -- node[above] {$(xy)'$} ([xshift=1.5cm]Nand.output);
\node[above=of Nand,,yshift=-.1cm] {NAND};
\node (x5) at (5,-3.56) {$x$};
\node (y5) at (5,-4) {$y$};
\node[nor gate US, draw, logic gate inputs=nnn] at ($(x5)+(1.5,-.2)$) (Nor) {};
\draw (x5) -- (Nor.input 1) ;
\draw (y5) -- (Nor.input 3) ;
\draw (Nor.output) -- node[above] {$(x+y)'$} ([xshift=1.5cm]Nor.output);
\node[above=of Nor,,yshift=-.1cm] {NOR};
\node (x6) at (0,-5.2) {$x$};
\node (y6) at (0,-5.43) {$y$};
\node[xor gate US, draw, logic gate inputs=nn] at ($(x6)+(1.5,-.12)$) (Xor) {};
\draw (x6) -- (Xor.input 1) ;
\draw (y6) -- (Xor.input 2) ;
\draw (Xor.output) -- node[above] {$xy'+ x'y$} ([xshift=1.5cm]Xor.output);
\node[above=of Xor,,yshift=-.2cm] {XOR};
\node (x7) at (5,-5.2) {$x$};
\node (y7) at (5,-5.43) {$y$};
\node[xnor gate US, draw, logic gate inputs=nn] at ($(x7)+(1.5,-.12)$) (Nor) {};
\draw (x7) -- (Nor.input 1) ;
\draw (y7) -- (Nor.input 2) ;
\draw (Nor.output) -- node[above] {$xy+ x'y'$} ([xshift=1.5cm]Nor.output);
\node[above=of Nor,,yshift=-.2cm] {XNOR};
\end{tikzpicture}
\end{frame}
\end{document}
输出:
我只是没用过,siunitx
但我想这不会有什么区别
答案2
我犯了一个粗心的错误。基本上在投影仪中,tikzpicture 有这个选项
\begin{tikzpicture}[very thick]
独立使用时,它具有以下功能
\begin{tikzpicture}[node distance=.2cm,label distance=2mm,very thick]
在投影机中,tikzpicture 应该具有与独立模式下产生正确输出相同的选项。