TikZ テーブル内の画像

TikZ テーブル内の画像

誰かテーブルについて手伝ってくれませんか? TikZ 画像のアウトラインとテーブル ラインの間に距離を置きたいのですが、さらに、TikZ 以外の画像は中央に配置されません。

これが私の LaTeX コードです:

\documentclass[a4paper,10pt]{article}
\usepackage{tikz,amsmath, amssymb,bm,color}
\usetikzlibrary{circuits.logic.US,circuits.logic.IEC}
\begin{document}

\begin{table}
\caption{Test}
\label{de:Wahrheitstabelle_Bsp01}
\setlength{\tabcolsep}{5mm} % separator between columns
\def\arraystretch{1.25} % vertical stretch factor
\centering

  \begin{tabular}{|c|c|c|}
      \hline

      Gatter    &   Funktion    &   CNF-Formel        \\ \hline

    \begin{tikzpicture}
      \draw (-1.5,-0.75) rectangle (1.5,0.75) ;
    \end{tikzpicture}   &    0   & 1    \\ \hline

    \begin{tikzpicture}[circuit logic US,  logic gate input sep=4mm]
      \node [or gate, inputs =nn] (a1) {};
      \draw (a1.input 1) -- ++(left:5mm) node[left] {$x_{1}$};
      \draw (a1.input 2) -- ++(left:5mm) node[left] {$x_{2}$};
      \draw (a1.output)--++(right:5mm) node[right] {$x_{3}$};

    \end{tikzpicture}   &    0   & 1        \\ \hline

    \begin{tikzpicture}[circuit logic US]
      \node (a1) [not gate, inputs =n] at (0,0)  {};
      \draw (a1.input) -- ++(left:5mm) node[left] {$x_{1}$};
      \draw (a1.output)--++(right:5mm) node[right] {$x_{2}$};

    \end{tikzpicture}   & $x_{2} \equiv \neg x_{1}$  & $(x_{2} \vee x_{1}) \wedge (\neg x_{2} \vee \neg x_{1})$    \\ \hline
  \end{tabular}
\end{table}

\end{document}

これが私の表です:

ここに画像の説明を入力してください

答え1

tikzpicture の周囲の垂直余白を修正するには、fitライブラリと特別なノードを使用できますcurrent boundind box。次の例では、\addvmarginマクロはこの方法を使用しています。

tikzpicture の垂直方向の位置合わせを修正するには、baselineオプションを使用できます。ここでは、0最初の tikzpicture のベース ラインとして選択していますが、任意の垂直座標を選択できます。最後の 2 つの tikzpicture では、参照として任意のノードを選択します。

ここに画像の説明を入力してください

\documentclass[a4paper,10pt]{article}
\usepackage{tikz,amsmath, amssymb,bm,color}
\usetikzlibrary{circuits.logic.US,circuits.logic.IEC,fit}
\newcommand\addvmargin[1]{
  \node[fit=(current bounding box),inner ysep=#1,inner xsep=0]{};
}
\begin{document}
\begin{table}
\caption{Test}
\label{de:Wahrheitstabelle_Bsp01}
\setlength{\tabcolsep}{5mm} % separator between columns
\def\arraystretch{1.25} % vertical stretch factor
\centering
\begin{tabular}{|c|c|c|}
  \hline
  Gatter    &   Funktion    &   CNF-Formel
  \\ \hline
  \begin{tikzpicture}[baseline=0]
    \draw (-1.5,-0.75) rectangle (1.5,0.75) ;
    \addvmargin{1mm}
  \end{tikzpicture}   &    0   & 1
  \\ \hline
  \begin{tikzpicture}[baseline={(x3.base)},circuit logic US,logic gate input sep=4mm]
    \node [or gate, inputs =nn] (a1) {};
    \draw (a1.input 1) -- ++(left:5mm) node[left] {$x_{1}$};
    \draw (a1.input 2) -- ++(left:5mm) node[left] {$x_{2}$};
    \draw (a1.output)--++(right:5mm) node[right] (x3) {$x_{3}$};
    \addvmargin{1mm}
  \end{tikzpicture}   &    0   & 1
  \\ \hline
  \begin{tikzpicture}[baseline={(x1.base)},circuit logic US]
    \node (a1) [not gate, inputs =n] at (0,0)  {};
    \draw (a1.input) -- ++(left:5mm) node[left] (x1) {$x_{1}$};
    \draw (a1.output)--++(right:5mm) node[right] {$x_{2}$};
    \addvmargin{1mm}
  \end{tikzpicture}   & $x_{2} \equiv \neg x_{1}$  & $(x_{2} \vee x_{1}) \wedge (\neg x_{2} \vee \neg x_{1})$
  \\ \hline
  \end{tabular}
\end{table}
\end{document}

関連情報