对齐两个表格的左侧

对齐两个表格的左侧

你好,我正在整理一张小抄,上面有两个信息表,中间用一两段其他文字隔开。Latex 可以很好地将每个表居中,但由于表格的宽度不同,结果在页面上看起来很奇怪。

是否有一个合理直接的方法可以让表格位于页面的中央,但左侧对齐?

这是我的代码的精简版本:

\documentclass[12pt]{article}
\usepackage[paper=a4paper,margin=1.75cm]{geometry}               
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{ragged2e}

\usepackage{fontspec,xltxtra,xunicode}
\usepackage{siunitx,amsmath}
\defaultfontfeatures{Mapping=tex-text}
\setromanfont[Mapping=tex-text]{Hoefler Text}
\setsansfont[Scale=MatchLowercase,Mapping=tex-text]{Helvetica}
\setmonofont[Scale=MatchLowercase]{Andale Mono}
\renewcommand\familydefault{\sfdefault}
\begin{document}
\thispagestyle{empty}
Content stripped out...


\subsubsection*{Statistics of small data sets $(N\le10)$}
\begin{table}[h]
\centering
\begin{tabular}{ll}
    Average                                   & $\overline{x}=\frac{x_1+x_2+\cdots+x_N}{N}$                       \\
    Range                                     & $R=x_{max}-x_{min}$                                            \\
    Uncertainty in a measurement & $\Delta x=\frac{R}{2}=\frac{R=x_{max}-x_{min}}{2}$             \\
    Uncertainty in the mean  & $\Delta \overline{x}=\frac{\Delta x}{\sqrt N}=\frac{R}{2\sqrt N}$ \\
    Measured value $x_m$                      & $x_m=\overline{x}\pm\Delta\overline{x}$                                 
\end{tabular}
\end{table}
\subsubsection*{Statistics of large data sets $(N>10)$}
When the data set is a sample of a larger set then a confidence interval is calculated:
% will have equations and table side-by-side

Content stripped out...

When the data set is complete then absolute statistics can be calculated:
\begin{table}[h]
\centering
\begin{tabular}{ll}
    Average                                   & $\overline{x}=\frac{\Sigma_{i=1}^N x_i}{N}$                                                \\
    Uncertainty in a measurement  & $\Delta x=\sigma=\sqrt{\frac{1}{N}\Sigma_{i=1}^N(x_i-\overline{x})^2}$                                    \\
    Uncertainty in the mean  & $\Delta \overline{x}=\frac{\sigma}{\sqrt N}$ \\
    Measured value $x_m$                      & $x_m=\overline{x}\pm\Delta\overline{x}$                                                          
\end{tabular}
\end{table}


\end{document}  

干杯

答案1

您可以使用tabularx并指定这些表的宽度:

示例输出

\documentclass[12pt]{article}

\usepackage[paper=a4paper,margin=1.75cm]{geometry}               
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{ragged2e}

\usepackage{fontspec,xltxtra,xunicode}
\usepackage{siunitx,amsmath}

\usepackage{tabularx}
\begin{document}
\thispagestyle{empty}
Content stripped out\dots


\subsubsection*{Statistics of small data sets $(N\le10)$}
\begin{table}[h]
\centering
\begin{tabularx}{0.7\textwidth}{XX}
    Average                                   & $\overline{x}=\frac{x_1+x_2+\cdots+x_N}{N}$                       \\
    Range                                     & $R=x_{max}-x_{min}$                                            \\
    Uncertainty in a measurement & $\Delta x=\frac{R}{2}=\frac{R=x_{max}-x_{min}}{2}$             \\
    Uncertainty in the mean  & $\Delta \overline{x}=\frac{\Delta x}{\sqrt N}=\frac{R}{2\sqrt N}$ \\
    Measured value $x_m$                      & $x_m=\overline{x}\pm\Delta\overline{x}$                                 
\end{tabularx}
\end{table}
\subsubsection*{Statistics of large data sets $(N>10)$}
When the data set is a sample of a larger set then a confidence interval is calculated:

Content stripped out\dots

When the data set is complete then absolute statistics can be calculated:
\begin{table}[h]
\centering
\begin{tabularx}{0.7\textwidth}{XX}
    Average                                   & $\overline{x}=\frac{\Sigma_{i=1}^N x_i}{N}$                                                \\
    Uncertainty in a measurement  & $\Delta x=\sigma=\sqrt{\frac{1}{N}\Sigma_{i=1}^N(x_i-\overline{x})^2}$                                    \\
    Uncertainty in the mean  & $\Delta \overline{x}=\frac{\sigma}{\sqrt N}$ \\
    Measured value $x_m$                      & $x_m=\overline{x}\pm\Delta\overline{x}$                                                          
\end{tabularx}
\end{table}


\end{document} 

答案2

要对齐两个居中表格,它们需要具有相同的宽度。目前,两个环境的左侧列tabular似乎具有相同的宽度,而第二个环境的右侧列tabular比第一个环境的右侧列宽。

因此,您可以通过发出指令来实现您的目标

\newlength\mylen
\settowidth\mylen{$\Delta x=\sigma=\sqrt{\frac{1}{N}\Sigma_{i=1}^N(x_i-\overline{x})^2}$}

在序言中并使用指令

\begin{tabular}{lp{\mylen}}

开始第一个tabular。这将确保两个表格的第二列也具有相同的宽度。

一个单独的问题:您可能需要多考虑一下文档的外观——Helvetica 文本字体和 Computer Modern 数学字体并不完全匹配。

相关内容