4

Hi I am putting together a crib sheet and on it there are two tables of information that are separated by a paragraph or two of other text. Latex centres each table nicely, but because the tables have different widths the result looks odd on the page.

Is there a reasonably straight forward way to get the tables pretty much in the centre of the page, but with their left-hand side aligned?

Here is a cut down version of my code:

\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}  

Cheers

  • 2
    Welcome to TeX.SX! I wouldn't bother: either you left align (maybe with a fixed margin) all tables or center them. Are you really sure you want to mix Computer Modern math fonts with Helvetica as the main document font? The result is far from being nice, in my opinion. – egreg Jun 24 '14 at 9:41
1

You could use tabularx and specify a width for these tables:

Sample output

\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} 
  • Thanks for the answers. I am going to learn to use the tabularex method. I do realise that the fonts look odd. The university that I work for is rather taken with the idea that sans serif fonts are more readable (I am not). I noticed the table alignment issue when I began the move to Helvetica, but I forgot to strip that out of the example that I submitted. – SimonM68 Jun 26 '14 at 14:32
2

To align two center-set tables, they need to have the same widths. Currently, the left-hand columns of the two tabular environments appear to have the same width, whereas the right-hand column of the second tabular is wider than than of the first.

You could thus achieve your objective by issuing the instructions

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

in the preamble and using the instruction

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

to start the first tabular. This will ensure that the second columns of both tables also have the same width.

A separate issue: You may want to think a bit more about the appearance of your document -- Helvetica text font and Computer Modern math font are not exactly well matched.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.