最近,我在主文档中输入了一个.tex
文件(就将其命名为table1.tex
,其中包含我论文中需要的表格),但是它的位置不太好,我希望它位于中间,但它却在左边,我该怎么做?
table1.tex
\newsavebox\independent
\begin{lrbox}{\independent}
\begin{minipage}{0.3\textwidth}
\begin{align*}
P_f &= (\sum_{i=1}^{n} P_i^{-1})^{-1} \\
\hat{x}_f &= P_f (\sum_{i=1}^{n} P_i^{-1} \hat{x}_i)
\end{align*}
\end{minipage}
\end{lrbox}
\newsavebox\correlated
\begin{lrbox}{\correlated}
\begin{minipage}{0.3\textwidth}
\begin{align*}
P_f &= (e^T \Sigma^{-1} e)^{-1} \\
\hat{x}_f &= P_f (e^T \Sigma^{-1} \hat{x})
\end{align*}
\end{minipage}
\end{lrbox}
\newsavebox\uc
\begin{lrbox}{\uc}
\begin{minipage}{0.3\textwidth}
\begin{align*}
P_f &= (\sum_{i=1}^{n} \omega_i P_i^{-1})^{-1} \\
\hat{x}_f &= P_f (\sum_{i=1}^{n} \omega_i P_i^{-1} \hat{x}_i)
\end{align*}
\end{minipage}
\end{lrbox}
\begin{table}
\caption{Multi-sensor Fusion Rules}
\begin{threeparttable}
\begin{center}
\begin{tabular}{ccc}
Types of Estimation Errors & Fusion Rules & Comments \\ \hline \hline
\makecell{No Correlations \\(Independent)} & \usebox{\independent} & Optimal \\
\hline
\makecell{Known Correlations \\ (Correlated)} & \usebox{\correlated} \tnote{*} & Optimal \\ \hline
Unknown Correlations & \usebox{\uc} \tnote{**} & \makecell{Suboptimal }\\ \hline \hline
\end{tabular}
\begin{tablenotes}
\item[*] $e=[I, \cdots, I]^T$, $\Sigma=(P_{ij}), \; i,j=1,\cdots, n$, and $\hat{x}= [\hat{x}_1^T, \cdots, \hat{x}_n^T]^T$.
\item[**] Covariance intersection rule, where $\omega_i\in [0\,,1],\; \sum_{i=1}^n \omega_i=1$, and $\omega_i=\arg\min_{\omega_i\in[0\,,1]} \text{tr}\{P_{f}\}$.
\end{tablenotes}
\end{center}
\end{threeparttable}
\end{table}
Main code
:
\documentclass[preview]{standalone}
\usepackage{amsmath}
\usepackage[flushleft]{threeparttable}
\usepackage{makecell}
\begin{document}
\input{table1}
\end{document}
答案1
我使用了该caption
包,以使标题和表格之间有正确的垂直间距。
我借此机会改进了您的表格,没有使用minipage
s,而是\hline
用以下命令替换了命令booktabs
:
表1.tex:
%to be input
\newsavebox\independent
\begin{lrbox}{\independent}
$ \begin{aligned}
P_f &= \Bigl(∑_{i=1}ⁿ P_i⁻¹\Bigr)⁻¹ \\
\hat{x}_f &= P_f \Bigl (∑_{i=1}ⁿ P_i⁻¹ \hat{x}_i\Bigr)
\end{aligned}
$
\end{lrbox}
\newsavebox\correlated
\begin{lrbox}{\correlated}
$ \begin{aligned}
P_f &= (e^T Σ^{-1} e)⁻¹ \\
\hat{x}_f &= P_f (e^T Σ^{-1} \hat{x})
\end{aligned}
$
\end{lrbox}
\newsavebox\uc
\begin{lrbox}{\uc}
$ \begin{aligned}
P_f &= \Bigl(∑_{i=1}ⁿ ω_i P_i⁻¹\Bigr)⁻¹ \\
\hat{x}_f &= P_f \Bigl (∑_{i=1}ⁿ ω_i P_i⁻¹ \hat{x}_i\Bigr)
\end{aligned} $
\end{lrbox}
\setlength\aboverulesep{0.65ex}
\setlength\belowrulesep{0.9ex}
\captionsetup{position =above}
\caption{Multi-sensor Fusion Rules}
\begin{threeparttable}
\begin{tabular}{cc@{\qquad}c}
Types of Estimation Errors & Fusion Rules & Comments \\
\midrule\midrule
\makecell{No Correlations \\(Independent)} & \usebox{\independent} & Optimal \\
\cmidrule(l r){1-3}
\makecell{Known Correlations \\ (Correlated)} & \usebox{\correlated} \tnote{*} & Optimal \\
\cmidrule(l r){1-3}
Unknown Correlations & \usebox{\uc} \tnote{**} & \makecell{Suboptimal } \\
\midrule\midrule
\end{tabular}
\vskip 0.8ex
\begin{tablenotes}
\item[*] $e=[I, ⋯ , I]^T$, $\Sigma=(P_{ij}), \; i,j=1, ⋯ , n$, and $\hat{x}= [\hat{x}_1^T, ⋯ , \hat{x}_n^T]^T$.\vskip 1.2ex
\item[**] Covariance intersection rule, where $ω_i ∈ [0\,,1],\; ∑_{i=1}^n ω_i=1$, and $ω_i=\arg\min_{ω_i\in[0\,,1]} \text{tr}\{P_{f}\}$.
\end{tablenotes}
\end{threeparttable}
\endinput
主文件:
\documentclass[preview]{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath}
\usepackage[flushleft]{threeparttable}%
\usepackage{makecell, caption, booktabs}
\usepackage{lipsum}
\begin{document}
\begin{table}
\centering
\input{table1inputvar}
\end{table}
\lipsum[2]
\end{document}
答案2
实际上,\newsavebox 浪费了一个计数寄存器和一个盒子寄存器。因此,为了不浪费寄存器,您可以使用:
%to be input
\bgroup% save all registers to stack
\countdef\independent=1\relax% count register
\independent=0\relax% box register
\begin{lrbox}{\independent}
$ \begin{aligned}
P_f &= \Bigl(∑_{i=1}ⁿ P_i⁻¹\Bigr)⁻¹ \\
\hat{x}_f &= P_f \Bigl (∑_{i=1}ⁿ P_i⁻¹ \hat{x}_i\Bigr)
\end{aligned}
$
\end{lrbox}
\countdef\correlated=2\relax% count register
\correlated=1\relax% box register
\begin{lrbox}{\correlated}
$ \begin{aligned}
P_f &= (e^T Σ^{-1} e)⁻¹ \\
\hat{x}_f &= P_f (e^T Σ^{-1} \hat{x})
\end{aligned}
$
\end{lrbox}
\countdef\uc=2\relax% count register
\uc=1\relax% box register
\begin{lrbox}{\uc}
$ \begin{aligned}
P_f &= \Bigl(∑_{i=1}ⁿ ω_i P_i⁻¹\Bigr)⁻¹ \\
\hat{x}_f &= P_f \Bigl (∑_{i=1}ⁿ ω_i P_i⁻¹ \hat{x}_i\Bigr)
\end{aligned} $
\end{lrbox}
\setlength\aboverulesep{0.65ex}
\setlength\belowrulesep{0.9ex}
\captionsetup{position =above}
\caption{Multi-sensor Fusion Rules}
\begin{threeparttable}
\begin{tabular}{cc@{\qquad}c}
Types of Estimation Errors & Fusion Rules & Comments \\
\midrule\midrule
\makecell{No Correlations \\(Independent)} & \usebox{\independent} & Optimal \\
\cmidrule(l r){1-3}
\makecell{Known Correlations \\ (Correlated)} & \usebox{\correlated} \tnote{*} & Optimal \\
\cmidrule(l r){1-3}
Unknown Correlations & \usebox{\uc} \tnote{**} & \makecell{Suboptimal } \\
\midrule\midrule
\end{tabular}
\vskip 0.8ex
\begin{tablenotes}
\item[*] $e=[I, ⋯ , I]^T$, $\Sigma=(P_{ij}), \; i,j=1, ⋯ , n$, and $\hat{x}= [\hat{x}_1^T, ⋯ , \hat{x}_n^T]^T$.\vskip 1.2ex
\item[**] Covariance intersection rule, where $ω_i ∈ [0\,,1],\; ∑_{i=1}^n ω_i=1$, and $ω_i=\arg\min_{ω_i\in[0\,,1]} \text{tr}\{P_{f}\}$.
\end{tablenotes}
\end{threeparttable}
\egroup% restore registers
你也可以看看重复使用保存箱 或者您可以直接加载 etex 包并忽略寄存器。