我使用以下代码来生成 LaTeX 输出。
\documentclass[12pt]{report}
\usepackage{amsmath}
\newcommand*\sumta[2]{\mathop {\sum} \limits_{#1}^{#2}}
\newcommand*\bnsar[2]{_{#1}^{#2}}
\begin{document}
\begin{table}[!ht]
\centering
\caption{Time domain features}
\label{table.1}
\begin{tabular}{l|l}
\hline
Feature & Formula \\ \hline
Mean value & $\overline{x}=\frac{1}{N}\sumta{i=1}{N}x_i$ \\
Standard deviation & $\sigma = \sqrt{\frac{1}{N}\sumta{n=1}{N}(x_i - \overline{x})^2}$ \\
Kurtosis & $\text{K}=\frac{1}{N}\sumta{i=1}{N}\frac{(x_i-\overline{x})^4}{\sigma^4}$ \\
Skewness & $\text{Sk} = \frac{1}{N}\sumta{i=1}{N}\frac{(x_i-\overline{x})^3}{\sigma^3}$ \\
Root mean square & $\text{RMS} = \sqrt{\frac{1}{N}\sumta{i=1}{N}x\bnsar{i}{2}}$ \\
Crest factor & $\text{Crf} = \frac{\max \text{value}}{\text{RMS}}$ \\
Peak to Peak value & $\text{PPV} = \max \text{value} - \min \text{value}$ \\ \hline
\end{tabular}
\end{table}
\end{document}
如您所见,每行由两列组成。右列中的表达式都是数学模式。如何在 LaTeX 中将特定运算符的方程式在列中对齐?例如,我希望方程式标记在列单元格中垂直对齐,以产生类似下图的输出。
我已经审查过其他有建议,但它们根本不是我的意思!请帮助我解决这个问题。
谢谢。
答案1
- 您应该提供完整的小文档,其中包含表中使用的所有定义
- 鉴于一个不起作用
- 我添加了两个用于改善表格外观的包
\documentclass{article}
\usepackage{array, makecell} % new
\setcellgapes{5pt} % new
\usepackage[skip=1ex]{caption} % new
\begin{document}
\begin{table}[!ht]
\centering
\makegapedcells % new
\caption{Time domain features}
\label{table.1}
\begin{tabular}{l| >{$}r<{$} @{\hspace{2.2pt}} >{$}l<{$}}
\hline
Feature & \multicolumn{2}{c}{Formula} \\
\hline
Mean value & \overline{x} & = \frac{1}{N}\sum_{i=1}^{N}x_i \\
Standard deviation & \sigma & = \sqrt{\frac{1}{N}
\sum_{i=1}^{N}(x_i - \overline{x})^2} \\
Kurtosis & \mathrm{K} & = \frac{1}{N}\sum_{i=1}^{N}
\frac{(x_i-\overline{x})^4}{\sigma^4} \\
Skewness & \mathrm{Sk} & = \frac{1}{N}\sum_{i=1}^{N}
\frac{(x_i-\overline{x})^3}{\sigma^3} \\
Root mean square & \mathrm{RMS} & = \sqrt{\frac{1}{N}
\sum_{i=1}^{N} (x_-\overline{x})^2 } \\
Crest factor & \mathrm{Crf} & = \frac{\max \mathrm{value}}{\mathrm{RMS}} \\
Peak to Peak value & \mathrm{PPV} & = \max \mathrm{value} - \min \mathrm{value} \\
\hline
\end{tabular}
\end{table}
\end{document}
答案2
booktabs
和 中型公式 的一些改进nccmath
。此外,我认为\bar{x}
看起来比 更好\overline{x}
:
\documentclass{article}
\usepackage{mathtools, nccmath}
\usepackage{array, makecell, booktabs} % new%
\setcellgapes{5pt} % new
\usepackage[skip=1ex]{caption} % new
\newcommand\msum{\medop\sum\limits}
\begin{document}
\begin{table}[!ht]
\centering%
\makegapedcells % new
\caption{Time domain features}
\label{table.1}
\begin{tabular}{@{}r @{\qquad}>{$}r<{$} @{} >{${}}l<{$}@{}}
\toprule
\multicolumn{1}{c}{Feature} & \multicolumn{2}{c}{Formula} \\
\midrule
Mean value & \bar{x} & = \mfrac{1}{N}\msum_{i=1}^{N}x_i \\
Standard deviation & \sigma & = \sqrt{\mfrac{1}{N}
\msum_{i=1}^{N}(x_i - \bar{x})^2} \\
Kurtosis & \mathrm{K} & = \mfrac{1}{N}\medop\sum_{i=1}^{N}
\mfrac{(x_i-\bar{x})^4}{\sigma^4} \\
Skewness & \mathrm{Sk} & = \mfrac{1}{N}\msum_{i=1}^{N}
\mfrac{(x_i-\bar{x})^3}{\sigma^3} \\
Root mean square & \mathrm{RMS} & = \sqrt{\mfrac{1}{N}
\msum_{i=1}^{N} (x_-\bar{x})^2 } \\
Crest factor & \mathrm{Crf} & = \mfrac{\max \mathrm{value}}{\mathrm{RMS}} \\
Peak to Peak value & \mathrm{PPV} & = \max \mathrm{value} - \min \mathrm{value} \\
\bottomrule
\end{tabular}
\end{table}
\end{document}