修改表格以匹配图像

修改表格以匹配图像

我想要从下面的代码生成的表格如下:

在此处输入图片描述

线与线之间的间距,以及颜色框。该表摘自 Dean Banerjee 所著的《PLL 性能、仿真和设计》一书。

这是我的代码:

\documentclass{article}

\usepackage[english]{babel}
\usepackage{amsmath,amsfonts,amssymb,amsthm, bm}

\begin{document}

\begin{center}
    \begin{tabular}{ | c | c | c |  c | c |}
    \hline
    $\rightarrow$ Converting To & Integrated & Signal to Noise & RMS Phase & RMS Jitter\\ 
    $\downarrow$ Converting From & Phase Noise & Ratio & Summary & $(\sigma_{t}$) \\
     & (A) & (SNR) & $(\sigma_{\phi(deg)})$ & \\ \hline
    A &  & 1/A & $\dfrac{180}{\pi}\sqrt{A}$ & $\dfrac{1}{2\pi f}\sqrt{A}$\\ \hline
    SNR & 1/SNR &  & $\dfrac{180}{\pi\sqrt{SNR}}$ & $\dfrac{1}{2\pi f \sqrt{SNR}}$\\ \hline
    $(\sigma_{\phi(deg)})$ & $\left( \dfrac{\pi\cdot\sigma_{\phi(deg)}}{180} \right)^{2}$ & $\left( \dfrac{180}{\pi\cdot\sigma_{\phi(deg)}} \right)^{2}$ &  & $\dfrac{1}{f}\dfrac{\sigma_{\phi(deg)}}{360}$  \\ \hline
    $\sigma_{t}$ & $\left(2\pi f \cdot \sigma_{t}\right)^{2}$ & $\left( \dfrac{1}{2\pi f \cdot \sigma_{t}}\right)$ & $360\cdot f \cdot \sigma_{t}$ &   \\ \hline
    \end{tabular}
\end{center}

\end{document}

答案1

像这样:

在此处输入图片描述

对于上面的图片,我仅添加到您的 MWE\usepackage[table]{xcolor}并在对角线单元格中输入\cellcolor{gray!10}

\documentclass{article}
    \usepackage[english]{babel}
    \usepackage[table]{xcolor}% <-- added
    \usepackage{amsmath,amssymb,amsthm, bm}

\begin{document}

\begin{center}
    \begin{tabular}{ | c | c | c |  c | c |}
    \hline
$\rightarrow$ Converting To  & Integrated  & Signal to Noise & RMS Phase & RMS Jitter\\
$\downarrow$ Converting From & Phase Noise & Ratio           & Summary   & $(\sigma_{t}$) \\
     & (A) & (SNR) & $(\sigma_{\phi(deg)})$ & \\ \hline
A   &   \cellcolor{gray!10}% <-- added 
        &   1/A     
            &   $\dfrac{180}{\pi}\sqrt{A}$ 
                &   $\dfrac{1}{2\pi f}\sqrt{A}$
                \\ \hline
SNR &   1/SNR 
        &   \cellcolor{gray!10}% <-- added 
            &   $\dfrac{180}{\pi\sqrt{SNR}}$ 
                &   $\dfrac{1}{2\pi f \sqrt{SNR}}$
                \\ \hline
$(\sigma_{\phi(deg)})$ 
    &   $\left( \dfrac{\pi\cdot\sigma_{\phi(deg)}}{180} \right)^{2}$ 
        &   $\left( \dfrac{180}{\pi\cdot\sigma_{\phi(deg)}} \right)^{2}$ 
            &   \cellcolor{gray!10}% <-- added
                &   $\dfrac{1}{f}\dfrac{\sigma_{\phi(deg)}}{360}$  
                \\ \hline
$\sigma_{t}$ 
    &   $\left(2\pi f \cdot \sigma_{t}\right)^{2}$ 
        &   $\left( \dfrac{1}{2\pi f \cdot \sigma_{t}}\right)$ 
            &   $360\cdot f \cdot \sigma_{t}$ 
                &   \cellcolor{gray!10}% <-- added     
                \\ \hline
    \end{tabular}
\end{center}
    \end{document}

附录:为了使你的表格看起来更好,需要付出额外的努力。Bernard 给出了一个示例答案,下面是另一种可能性,不需要额外的包:

\documentclass{article}
    \usepackage[english]{babel}
    \usepackage[table]{xcolor}% <-- added
    \usepackage{amsmath,amssymb,amsthm, bm}

    \usepackage{makecell}
\renewcommand\theadfont{\bfseries\normalsize}
\begin{document}

\begin{center}
    \begin{tabular}{|*{5}{@{\rule[-4ex]{0pt}{9ex}\hspace{6pt}}c|}}%
    \hline
\thead{$\to$  Converting To\\
       $\downarrow$ Converting From}
    &   \thead{Integrated\\Phase Noise\\ $(A)$}
        &   \thead{Signal to\\ Noise Ratio\\ $(SNR)$}
            &   \thead{RMS Phase\\ Summary\\ $(\sigma_{t})$}
                &   \thead{RMS Jitter\\ $(\sigma_{\phi(deg)})$}
                \\  \hline
$A$     &   \cellcolor{gray!10}{}% <-- added
            &   $1/A$
                &   $\dfrac{180}{\pi}\sqrt{A}$
                    &   $\dfrac{1}{2\pi f}\sqrt{A}$
                    \\ \hline
$SNR$   &   $1/SNR$
            &   \cellcolor{gray!10}% <-- added
                &   $\dfrac{180}{\pi\sqrt{SNR}}$
                    &   $\dfrac{1}{2\pi f \sqrt{SNR}}$
                    \\ \hline
$(\sigma_{\phi(deg)})$
        &   $\left( \dfrac{\pi\cdot\sigma_{\phi(deg)}}{180} \right)^{2}$
            &   $\left( \dfrac{180}{\pi\cdot\sigma_{\phi(deg)}} \right)^{2}$
                &   \cellcolor{gray!10}% <-- added
                    &   $\dfrac{1}{f}\dfrac{\sigma_{\phi(deg)}}{360}$
                    \\ \hline
$\sigma_{t}$
        &   $\left(2\pi f \cdot \sigma_{t}\right)^{2}$
            &   $\left( \dfrac{1}{2\pi f \cdot \sigma_{t}}\right)$
                &   $360\cdot f \cdot \sigma_{t}$
                    &   \cellcolor{gray!10}% <-- added
                    \\ \hline
    \end{tabular}
\end{center}
    \end{document}

使@{\rule[-4ex]{0pt}{9ex}\hspace{6pt}所有单元格相等且具有足够的高度:

在此处输入图片描述

答案2

带有包的解决方案makecell(允许换行和单元格中的常见格式和对齐方式),cellspace(确保列中的单元格与上下单元格之间的垂直填充最小)和colortbl。我还变成了deg数学运算符\deg

\documentclass{article}

\usepackage[english]{babel}
\usepackage{amsmath,amsfonts,amssymb,amsthm, bm}
\usepackage{array, makecell, colortbl,cellspace }
\usepackage[x11names, table]{xcolor}
\renewcommand{\theadfont}{\normalsize\bfseries\boldmath}
\setlength\cellspacetoplimit{4pt}
\setlength\cellspacebottomlimit{4pt}

\begin{document}

\begin{center}
\begin{tabular}{ | *{5} {Sc |}}
\hline
\thead{\itshape$\rightarrow$ Converting To\\[1.5ex]\itshape$\downarrow$ Converting From} & \thead{Integrated\\Phase Noise\\(A)} & \thead{Signal to Noise\\Ratio\\(SNR)} & \thead{RMS Phase\\Summary\\$(\sigma_{\phi(\deg)})$} & \thead{RMS Jitter\\ $(\sigma_{t}$)}\\
\hline
A & \cellcolor{Snow2}& 1/A & $\dfrac{180}{\pi}\sqrt{A}$ & $\dfrac{1}{2\pi f}\sqrt{A}$\\ \hline
SNR & 1/SNR & \cellcolor{Snow2} & $\dfrac{180}{\pi\sqrt{SNR}}$ & $\dfrac{1}{2\pi f \sqrt{SNR}}$\\ 
\hline
$(\sigma_{\phi(\deg)})$ & $\left( \dfrac{\pi\cdot\sigma_{\phi(\deg)}}{180} \right)^{2}$ & $\left( \dfrac{180}{\pi\cdot\sigma_{\phi(\deg)}} \right)^{2}$ & \cellcolor{Snow2} & $\dfrac{1}{f}\dfrac{\sigma_{\phi(\deg)}}{360}$ \\ 
\hline
$\sigma_{t}$ & $\left(2\pi f \cdot \sigma_{t}\right)^{2}$ & $\left( \dfrac{1}{2\pi f \cdot \sigma_{t}}\right)$ & $360\cdot f \cdot \sigma_{t}$ & \cellcolor{Snow2} \\ 
\hline
\end{tabular}
\end{center}

\end{document} 

在此处输入图片描述

相关内容