如何在表格环境中对齐 tikz 图形和方程式

如何在表格环境中对齐 tikz 图形和方程式

我正在关注例子在 tikz 箭头节点内添加文本(我的情况是数学)。在箭头旁边的单元格中我有方程式。我有两个问题:

  1. 如何水平对齐箭头和方程式?
  2. 如何反转蓝色箭头的方向?不是从左到右,而是从右到左(-Latex 似乎不起作用!?)。

以下是我目前所拥有的。

\documentclass[table]{beamer}
\usetheme{Boadilla}
\usepackage{makecell}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{shapes, arrows, arrows.meta}
\begin{document}
\begin{frame}{Relationship Among Frequency Variables}
\begin{table}[]
\setlength{\tabcolsep}{6pt} % Default value: 6pt
\renewcommand{\arraystretch}{1.5} % Default value: 1
    \begin{center}
    \label{tab:table1}
    \begin{tabular}{@{}ccc@{}} \toprule
        Continuous-time signals & & Discrete-time signals \\
        \midrule
        $\Omega = 2\pi F$ &  & $\omega = 2\pi f$ \\
        $\frac{\text{radians}}{\text{sec}} \quad \text{Hz}$ & & $\frac{\text{radians}}{\text{sample}} \quad \frac{\text{cycles}}{\text{sample}}$ \\
        \midrule
        &     
                \begin{tikzpicture}[every node/.style={single arrow}]
                    \node (A) [draw,fill=red!10] {$\omega=\Omega T, f=F\//F_s$};
                \end{tikzpicture}%
        & $ -\pi \leq \omega \leq \pi $ \\
        &
            \begin{tikzpicture}[every node/.style={single arrow}]
                \node (B) [draw,fill=blue!10, -Latex] {$\Omega=\omega\//T, F=f \cdot F_s$};
            \end{tikzpicture}%
        & $ -\frac{1}{2} \leq f \leq \frac{1}{2} $ \\
        \midrule
        $-\infty < \Omega < \infty$ & & $-\pi\//T \leq \Omega \leq \pi\//T$ \\
        $-\infty < F < \infty$ & & $-F_{s}\//2 \leq F \leq F_{s}\//2$ \\
        \bottomrule
    \end{tabular}
    \end{center}
\end{table}
\end{frame}
\end{document}

答案1

像这样:

在此处输入图片描述

对于每个tikzpicture你需要添加baseline=(current bounding box.center),选项,或者像下面 MWE 中的一些微小的代码改进一样, \tikzset为两个图片定义共同点:

\documentclass[table]{beamer}
\usetheme{Boadilla}
\usepackage{booktabs, makecell, tabularx}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, shapes}
\begin{document}
\begin{frame}[fragile]
\frametitle{Relationship Among Frequency Variables}
    \begin{table}
\tikzset{
     baseline = (current bounding box.center),
    SA/.style = {single arrow, draw, fill=#1, minimum height=11em}
        }
\renewcommand{\arraystretch}{1.5} % Default value: 1
    \centering
\begin{tabular}{@{} >{$}c<{$} c  >{$}c<{$} @{}}
    \toprule
\text{Continuous-time signals}
    &   &   \text{Discrete-time signals}                    \\
    \midrule
\Omega = 2\pi F
    &   &   \omega = 2\pi f                                 \\
\frac{\mathrm{radians}}{\mathrm{sec}} \quad \text{Hz}
    &   &   \frac{\mathrm{radians}}{\mathrm{sample}} 
                \quad \frac{\text{cycles}}{\text{sample}}   \\
    \midrule
    &   \begin{tikzpicture}
    \node (A) [SA=red!10] {$\omega=\Omega T,\ f=F\//F_s$};
        \end{tikzpicture}
    &   -\pi \leq \omega \leq \pi                           \\
    \addlinespace
    &   \begin{tikzpicture}
    \node (B) [SA=blue!10] {$\Omega=\omega/T,\ F=f{\cdot}F_s$};
        \end{tikzpicture}
        &   -\frac{1}{2} \leq f \leq \frac{1}{2}            \\
    \midrule
-\infty < \Omega < \infty
    &   &   -\pi\//T \leq \Omega \leq \pi\//T               \\
-\infty < F < \infty
    &   &   -F_{s}\//2 \leq F \leq F_{s}\//2                \\
    \bottomrule
\end{tabular}
    \end{table}
\end{frame}
\end{document}

附录: 用于改变single arrow预期参数的方向shape border rotate。有关详细信息,请参阅 TiZ 和 PGF 手册,第 811 页(版本 3.12.8b):

\documentclass[table]{beamer}
\usetheme{Boadilla}
\usepackage{booktabs, makecell, tabularx}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, shapes}
\begin{document}
\begin{frame}[fragile]
\frametitle{Relationship Among Frequency Variables}
    \begin{table}
\tikzset{
     baseline = (current bounding box.center),
    SA/.style = {single arrow, draw, fill=#1, minimum height=11em} % <---
        }
\renewcommand{\arraystretch}{1.5} % Default value: 1
    \centering
\begin{tabular}{@{} >{$}c<{$} c  >{$}c<{$} @{}}
    \toprule
\text{Continuous-time signals}
    &   &   \text{Discrete-time signals}                    \\
    \midrule
\Omega = 2\pi F
    &   &   \omega = 2\pi f                                 \\
\frac{\mathrm{radians}}{\mathrm{sec}} \quad \text{Hz}
    &   &   \frac{\mathrm{radians}}{\mathrm{sample}}
                \quad \frac{\text{cycles}}{\text{sample}}   \\
    \midrule
    &   \begin{tikzpicture}
    \node (A) [SA=red!10] {$\omega=\Omega T,\ f=F\//F_s$};
        \end{tikzpicture}
    &   -\pi \leq \omega \leq \pi                           \\
    \addlinespace
    &   \begin{tikzpicture}
    \node (B) [SA=blue!10, 
               shape border rotate=180] {$\Omega=\omega/T,\ F=f{\cdot}F_s$};
        \end{tikzpicture}
        &   -\frac{1}{2} \leq f \leq \frac{1}{2}            \\
    \midrule
-\infty < \Omega < \infty
    &   &   -\pi\//T \leq \Omega \leq \pi\//T               \\
-\infty < F < \infty
    &   &   -F_{s}\//2 \leq F \leq F_{s}\//2                \\
    \bottomrule
\end{tabular}
    \end{table}
\end{frame}
\end{document}

在此处输入图片描述

相关内容