我想用 LaTeX 制作一张和图片一样的表格。
我已经使用过以下代码:
\begin{table}[h!]
\begin{tabular}{|c|c|c|c|c|}\hline
Class & Format & Constant Value & Slope Value & Slope at \\ \hline
Gain & K &$ 0^0 if K > 0$ & 0 & -$\infty$ \\ \cline{3-3}& &$ 180^0 if K > 0$ & & \\ \hline
\makecell{Zero at \\ origin}& $s^{n_0}$ & $90 n_0$ & - & -$\infty$ \\ \hline
\makecell{Simple Zero \\ at $z_i$}& $\left(1 + \frac{s}{z_i}\right)^{n_1}$ & - & $45^o n_1$ & $0.1 \times z_i$ \\ \cline{4-5} & & & $-45^o n_1$ & $10 \times z_i$ \\
\hline
\makecell{Quatrature \\ Zero at $z_j$}& $\left( 1 + 2\zeta\frac{s}{z_j} + \left(\frac{s}{z_j} \right)^2 \right)^{n_2}$ & - & $90^o n_2$ & $0.1 \times z_j$ \\ \cline{4-5} & & & $-90^o n_2$ & $10 \times z_j$ \\ \hline
\makecell{Pole at \\ origin}& $1/s^{m_0}$ & $-90 m_0$ & - & -$\infty$ \\ \hline
\makecell{Simple Pole \\ at $p_i$}& $\frac{1}{\left(1 + \frac{s}{p_i}\right)^{m_1}}$ & - & $-45^o m_1$ & $0.1 \times p_i$ \\ \cline{4-5} & & & $+45^o m_1$ & $10 \times p_i$ \\ \hline
\makecell{Quatrature \\ Pole at $p_j$}& $\frac{1}{\left( 1 + 2\zeta\frac{s}{p_j} + \left(\frac{s}{p_j} \right)^2 \right)^{m_2}}$ & - &$-90^o m_2$ & $0.1 \times p_j$ \\ \cline{4-5} & & & $+90^o m_2$ & $10 \times p_j$ \\ \hline
\end{tabular}
\end{table}
4-5
但是,如您所见,行和行中的子单元格高度不一样7-8
。我该如何匹配子单元格高度?
答案1
以下内容可以帮助您入门。请相应调整表格的其余部分:
\documentclass{article}
\usepackage{amsmath}
\usepackage{geometry}
\usepackage{makecell}
\renewcommand{\theadfont}{\normalsize}
\usepackage[column=0]{cellspace}
\setlength{\cellspacetoplimit}{\tabcolsep}
\setlength{\cellspacebottomlimit}{\tabcolsep}
\begin{document}
\begin{table}[h!]
\centering
\begin{tabular}{|0c|>{\(}c<{\)}|>{\(}c<{\)}|@{}>{\(}c<{\)}@{}|@{}>{\(}c<{\)}@{}|}\hline
\thead{Class}
& \thead{\text{Format}}
& \thead{\text{Constant}\\ \text{Value}}
& \thead{\text{Slope}\\ \text{Value}}
& \thead{\text{Slope at}} \\ \hline
\makecell{Zero at \\ origin}
& s^{n_0}
& 90 n_0
& -
& -\infty \\
\hline
\makecell{Simple Zero \\ at $z_i$}
& \left(1 + \frac{s}{z_i}\right)^{n_1}
& -
& \begin{tabular}{>{\(}0c<{\)}} 45^o n_1 \\ \hline -45^o n_1 \end{tabular}
& \begin{tabular}{>{\(}0c<{\)}} 0.1 \times z_i \\ \hline 10 \times z_i \end{tabular}\\
\hline
\end{tabular}
\end{table}
\end{document}
答案2
我建议您 (a) 删除所有垂直规则,(b) 使用更少但间隔良好的水平规则(通过使用包的宏booktabs
)和 (c) 使用更多\makecell
指令将某些行的最后两列结果分组。或者,使用tabular*
环境而不是tabular
环境来确保表格适合文本块。并且,请将^0
和的实例替换^o
为^{\circ}
。
\documentclass{article}
\usepackage{makecell}
\usepacakge{amsmath} % for \text macro
\usepackage{booktabs}% for \toprule, \midrule, \bottomrule, and \addlinespace macros
\begin{document}
\begin{table}[h!]
\setlength\tabcolsep{0pt} % let LaTeX figure out intercolumn whitespace amounts
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} l cccc}
\toprule
Class & Format & Constant Value & Slope Value & Slope at \\
\midrule
Gain &
$K$ &
\makecell{\text{$\phantom{00}0^{\circ}$ if $K>0$}\\[0.25ex]
\text{$180^{\circ}$ if $K>0$}} &
0 & $-\infty$ \\
\addlinespace \addlinespace
\makecell[l]{Zero at \\ origin}&
$s^{n_0}$ & $90 n_0$ & -- & $-\infty$ \\
\addlinespace
\makecell[l]{Simple Zero \\ at $z_i$} &
$\bigl(1+\frac{s}{z_i} \bigr)^{n_1}$ &
-- &
\makecell{$\phantom{-}45^{\circ}n_1$\\[0.25ex] $-45^{\circ}n_1$} &
\makecell{$0.1\cdot z_i$\\[0.25ex] $10 \cdot z_i$} \\
\addlinespace
\makecell[l]{Quatrature \\ Zero at $z_j$}&
$\bigl( 1 + 2\zeta\frac{s}{z_j} + (\frac{s}{z_j})^2 \bigr)^{n_2}$
& -- &
\makecell{$\phantom{-}90^{\circ}n_2$\\[0.25ex] $-90^{\circ}n_2$} &
\makecell{$0.1\cdot z_j$\\[0.25ex] $10 \cdot z_j$} \\
\addlinespace\addlinespace
\makecell[l]{Pole at \\ origin}& $1/s^{m_0}$ & $-90 m_0$ & -- & $-\infty$ \\
\addlinespace
\makecell[l]{Simple Pole \\ at $p_i$} &
$1\big/\bigl(1 + \frac{s}{p_i}\bigr)^{m_1}$ &
-- &
\makecell{$-45^{\circ}m_1$\\[0.25ex] $+45^{\circ} m_1$} &
\makecell{$0.1 \cdot p_i$\\[0.25ex] $10 \cdot p_i$} \\
\addlinespace
\makecell[l]{Quatrature \\ Pole at $p_j$} &
$1\big/\bigl( 1 + 2\zeta\frac{s}{p_j} + (\frac{s}{z_j})^2 \bigr)^{m_2}$ &
-- &
\makecell{$-90^{\circ} m_2$\\[0.25ex] $+90^{\circ} m_2$} &
\makecell{$0.1 \cdot p_j$ \\[0.25ex] $10 \cdot p_j$} \\
\bottomrule
\end{tabular*}
\end{table}
\end{document}