2

Desired Result

I'm new to LaTeX and am having problems with this compiling in LaTeX the above, desired table. Here is the code I'm working with:

\documentclass{article}
\usepackage{amsmath}
\title{Latex File}
\author{Noob}
\date{\today}
\begin{document}
\maketitle
\renewcommand{\arraystretch}{1.2}
\begin{center}
\begin{tabular}{c c c c c c}
\hline
\hline
Nuclide & Gamma-Ray \newline Energy (keV) & Half-Life \newline (Days) & Master\newline Source \newline ($\gamma$ps/g) & This Source \newline ($\gamma$ps) & Calibration Method \\
\hline
\hline
$^{210}\text{Pb}$ & 46.5 & 8.145E3 &  &4.596E2 & 4IILS \\
$^{242}\text{Am}$ & 59.5 & 1.580E5 &  & 3.265E2 & 4IILS \\
$^{109}\text{Cd}$ & 88.0 & 4.626E2 & 1.665E5 & 4.408E2 & HPGe \\
$^{57}\text{Co}$ & 122.1 & 2.718E2 & 8.986E4 & 2.379E2 & HPGe \\
$^{139}\text{Ce}$ & 165.9 & 1.376E2 & 1.253E5 & 3.315E2 & HPGe \\
$^{51}\text{Cr}$ & 320.1 & 2.770E1 & 4.003E5 & 1.060E3 & IC \\
$^{113}\text{Sn}$ & 391.7 & 1.151E2 & 1.746E5 & 4.621E2 & HPGe \\
$^{85}\text{Sr}$ & 514.0 & 6.484E1 & 3.070E5 & 8.127E2 & IC \\
$^{137}\text{Cs}$ & 661.7 & 1.098E4 & 1.111E5 & 2.941E2 & HPGe \\
$^{88}\text{Y}$ & 898.0 & 1.066E2 & 4.263E5 & 1.128E3 & HPGe \\
$^{60}\text{Co}$ & 1173.2 & 1.925E3 & 2126E5 & 5.628E2 & HPGe \\
$^{60}\text{Co}$ & 1332.5 & 1.925E3 & 2.127E5 & 5.629E2 & HPGe \\
$^{88}\text{Y}$ & 1836.1 & 1.066E2 & 4.513E5 & 1.195E3 & HOGe \\
\hline
\end{tabular}
\end{center}
\end{document}

The issues I'm having are that

  • the \newline command is not doing anything,
  • the \center is not fixing the orientation of the table, which runs off the page.
  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – user11232 Apr 10 '15 at 4:07
2

Here is how I would typeset the table:

\documentclass{article}

\usepackage[margin = 4cm]{geometry} % to avoid `overfull \hbox' warning
\usepackage[tableposition = top]{caption}
\usepackage{mathtools}
\usepackage{siunitx}
\usepackage{booktabs}
%\usepackage[version = 4]{mhchem} % use if you have more than a few chemical symbols

\newcommand*\nuc[1]{$\prescript{#1}{}{}$}
\newcommand*\elem[1]{\textup{#1}}
\newcommand*\mc[1]{\multicolumn{2}{c}{#1}}
\newcommand*\lineB[2][c]{\begin{tabular}[#1]{@{}c@{}}#2\end{tabular}}

\begin{document}

\begin{table}
\centering
\caption{A table with some data.}
\label{tbl:some-data}
\begin{tabular}{
  @{\hspace{0.85em}} r
  @{\hspace{0em}}    l
                     S[table-format = 4.1]
                *{3}{S[table-format = 1.3e1, exponent-product = \cdot]}
                     c
}
 \toprule
  \mc{Nuclide}          & {\lineB{Gamma-Ray\\ Energy}} & {Half-life} & {Master Source}                             & {This Source}      & {\lineB{Calibration\\ Method}} \\[2ex]
  \mc{---}              & {\si{\keV}}                  & {Days}      & {$\gamma$\si[per-mode = symbol]{\ps\per\g}} & {$\gamma$\si{\ps}} & ---                            \\
 \midrule
  \nuc{210} & \elem{Pb} &   46.5                       & 8.145e3     & {---}                                       & 4.596e2            & 4IILS                          \\
  \nuc{242} & \elem{Am} &   59.5                       & 1.580e5     & {---}                                       & 3.265e2            & 4IILS                          \\
  \nuc{109} & \elem{Cd} &   88.0                       & 4.626e2     & 1.665e5                                     & 4.408e2            & HPGe                           \\
  \nuc{57}  & \elem{Co} &  122.1                       & 2.718e2     & 8.986e4                                     & 2.379e2            & HPGe                           \\
  \nuc{139} & \elem{Ce} &  165.9                       & 1.376e2     & 1.253e5                                     & 3.315e2            & HPGe                           \\
  \nuc{51}  & \elem{Cr} &  320.1                       & 2.770e1     & 4.003e5                                     & 1.060e3            & IC                             \\
  \nuc{113} & \elem{Sn} &  391.7                       & 1.151e2     & 1.746e5                                     & 4.621e2            & HPGe                           \\
  \nuc{85}  & \elem{Sr} &  514.0                       & 6.484e1     & 3.070e5                                     & 8.127e2            & IC                             \\
  \nuc{137} & \elem{Cs} &  661.7                       & 1.098e4     & 1.111e5                                     & 2.941e2            & HPGe                           \\
  \nuc{88}  & \elem{Y}  &  898.0                       & 1.066e2     & 4.263e5                                     & 1.128e3            & HPGe                           \\
  \nuc{60}  & \elem{Co} & 1173.2                       & 1.925e3     & 2.126e5                                     & 5.628e2            & HPGe                           \\
  \nuc{60}  & \elem{Y}  & 1332.5                       & 1.925e3     & 2.127e5                                     & 5.629e2            & HPGe                           \\
  \nuc{88}  & \elem{Y}  & 1836.1                       & 1.066e2     & 4.513e5                                     & 1.195e3            & HOGe                           \\
 \bottomrule
\end{tabular}
\end{table}

\noindent Above we have table~\ref{tbl:some-data}.

\end{document}

output

A few suggestions:

  • Use the siunitx package to typeset the physical numbers and units in the table.
  • Use the booktabs package to get a better thickness of -- and spacing around -- the horizontal rules.
  • Use the caption package with the option tableposition = top to get better spacing between the caption and the table.
  • Use the syntax *{<number of columns>}{<column type>} where possible to shorten the code.
  • Structure the input code to make it look like the output to get a better overview of it.
1

\newline won't work inside c column type. You can use tabularx and its X column instead.

\documentclass{article}
\usepackage{amsmath,tabularx}
\title{Latex File}
\author{Noob}
\date{\today}
\begin{document}
\maketitle

\renewcommand{\arraystretch}{1.2}
\noindent
\begin{tabularx}{\textwidth}{XXXXXX}
\hline
\hline
Nuclide & Gamma-Ray  Energy (keV) & Half-Life  (Days) & Master Source  ($\gamma$ps/g) & This Source  ($\gamma$ps) & Calibration Method \\
\hline
\hline
$^{210}\text{Pb}$ & 46.5 & 8.145E3 &  &4.596E2 & 4IILS \\
$^{242}\text{Am}$ & 59.5 & 1.580E5 &  & 3.265E2 & 4IILS \\
$^{109}\text{Cd}$ & 88.0 & 4.626E2 & 1.665E5 & 4.408E2 & HPGe \\
$^{57}\text{Co}$ & 122.1 & 2.718E2 & 8.986E4 & 2.379E2 & HPGe \\
$^{139}\text{Ce}$ & 165.9 & 1.376E2 & 1.253E5 & 3.315E2 & HPGe \\
$^{51}\text{Cr}$ & 320.1 & 2.770E1 & 4.003E5 & 1.060E3 & IC \\
$^{113}\text{Sn}$ & 391.7 & 1.151E2 & 1.746E5 & 4.621E2 & HPGe \\
$^{85}\text{Sr}$ & 514.0 & 6.484E1 & 3.070E5 & 8.127E2 & IC \\
$^{137}\text{Cs}$ & 661.7 & 1.098E4 & 1.111E5 & 2.941E2 & HPGe \\
$^{88}\text{Y}$ & 898.0 & 1.066E2 & 4.263E5 & 1.128E3 & HPGe \\
$^{60}\text{Co}$ & 1173.2 & 1.925E3 & 2126E5 & 5.628E2 & HPGe \\
$^{60}\text{Co}$ & 1332.5 & 1.925E3 & 2.127E5 & 5.629E2 & HPGe \\
$^{88}\text{Y}$ & 1836.1 & 1.066E2 & 4.513E5 & 1.195E3 & HOGe \\
\hline
\end{tabularx}
\end{document}

enter image description here

With centered columns and booktabs rules:

\documentclass{article}
\usepackage{amsmath,tabularx,booktabs}
\title{Latex File}
\author{Noob}
\date{\today}
\begin{document}
\maketitle

\renewcommand{\arraystretch}{1.2}
\noindent
\begin{tabularx}{\textwidth}{*{6}{>{\centering\arraybackslash}X}}
\toprule
Nuclide & Gamma-Ray  Energy (keV) & Half-Life  (Days) & Master Source  ($\gamma$ps/g) & This Source  ($\gamma$ps) & Calibration Method \\
\midrule
$^{210}\text{Pb}$ & 46.5 & 8.145E3 &  &4.596E2 & 4IILS \\
$^{242}\text{Am}$ & 59.5 & 1.580E5 &  & 3.265E2 & 4IILS \\
$^{109}\text{Cd}$ & 88.0 & 4.626E2 & 1.665E5 & 4.408E2 & HPGe \\
$^{57}\text{Co}$ & 122.1 & 2.718E2 & 8.986E4 & 2.379E2 & HPGe \\
$^{139}\text{Ce}$ & 165.9 & 1.376E2 & 1.253E5 & 3.315E2 & HPGe \\
$^{51}\text{Cr}$ & 320.1 & 2.770E1 & 4.003E5 & 1.060E3 & IC \\
$^{113}\text{Sn}$ & 391.7 & 1.151E2 & 1.746E5 & 4.621E2 & HPGe \\
$^{85}\text{Sr}$ & 514.0 & 6.484E1 & 3.070E5 & 8.127E2 & IC \\
$^{137}\text{Cs}$ & 661.7 & 1.098E4 & 1.111E5 & 2.941E2 & HPGe \\
$^{88}\text{Y}$ & 898.0 & 1.066E2 & 4.263E5 & 1.128E3 & HPGe \\
$^{60}\text{Co}$ & 1173.2 & 1.925E3 & 2126E5 & 5.628E2 & HPGe \\
$^{60}\text{Co}$ & 1332.5 & 1.925E3 & 2.127E5 & 5.629E2 & HPGe \\
$^{88}\text{Y}$ & 1836.1 & 1.066E2 & 4.513E5 & 1.195E3 & HOGe \\
\bottomrule
\end{tabularx}
\end{document}

enter image description here

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.