Get this error for the first line of the table:
> ! Extra }, or forgotten $.<template> \unskip \hfil }\hskip \tabcolsep
> \endtemplate 1 & ! Missing $ inserted.<inserted text>$ 1 & !
> Missing } inserted.<inserted text>} 1 & ! Extra alignment tab has been
> changed to \cr.<recently read> \endtemplate 1 &
This only occured after adding the fifth column of the table
\documentclass[a4paper,twocolumn,12pt]{article}
\usepackage[top=25mm,bottom=25mm,left=25mm,right=25mm]{geometry}
\usepackage{amssymb, amsmath}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{url}
\usepackage{setspace}
\usepackage{gensymb}
\setstretch{1.44}
\setlength{\columnsep}{6mm}
\usepackage{titlesec}
\titleformat{\section}{\bfseries\large\scshape\filcenter}{\thesection}{1em}{}
\titleformat{\subsection}{\bfseries\normalsize\scshape\filcenter}{\thesubsection}{1em}{}
\titlespacing{\section}{0pt}{2pt}{0pt}
\titlespacing{\subsection}{0pt}{2pt}{0pt}
% Following change makes the caption size footnotesize From: http://rorasa.wordpress.com/2010/01/13/instant-latex-command-for-small-figure-and-table-caption/
\renewcommand{\abstractname}{} % clear the title
\newcommand{\captionfonts}{\footnotesize}
\renewcommand\thesection{\Roman{section}.}
\renewcommand\thesubsection{\Alph{subsection}.}
\makeatletter
\long\def\@makecaption#1#2{
\vskip\abovecaptionskip
\sbox\@tempboxa{{\captionfonts #1: #2}}%
\ifdim \wd\@tempboxa >\hsize
{\captionfonts #1: #2\par}
\else
\hbox to\hsize{\hfil\box\@tempboxa\hfil}%
\fi
\vskip\belowcaptionskip}
\renewcommand\p@subsection{\thesection}
\makeatother
\begin{document}
\begin{table*}
\centering
\begin{tabular}{ccccc}
Peak No. & 2$\theta (\degree)$ & d-spacing (\AA) & hkl values & Relative
Intensity ($%$)\\
1 & 23.38 & 3.804$\pm$0.003 & [1~0~1] & $\sim 10$ \\
2 & 26.65 & 3.345$\pm$0.004 & [0~0~6] & $\sim 5$ \\
3 & 32.11 & 2.7872$\pm$0.0004 & [1~0~5] & $\sim 90$ \\
4 & 32.71 & 2.7380$\pm$0.0003 & [1~1~0] & $\sim 100$ \\
5 & 42.66 & 2.1196$\pm$0.0005 & [1~1~6] & $\sim 20$ \\
6 & 45.17 & 2.0072$\pm$0.0009 & [0~0~10] & $\sim 10$ \\
7 & 46.93 & 1.9362$\pm$0.0002 & [2~0~0] & $\sim 40$ \\
8 & 56.86 & 1.6194$\pm$0.0008 & [1~1~10] & $\sim 5$ \\
9 & 58.01 & 1.5899$\pm$0.0004 & [2~1~5] & $\sim 30$ \\
10 & 67.15 & 1.3940$\pm$0.0005 & [2~0~10] & $\sim 10$ \\
11 & 68.53 & 1.3693$\pm$0.0004 & [2~2~0] & $\sim 10$
\end{tabular}
\caption{Bragg angles, $2\theta$ and their respective d-spacings}
\label{xrpd}
\end{table*}
\end{document}
답변1
how to manage your error i describe in my comment. here i like to show how i would write your table:
- add package
siunitx
for nicer and simpler set third table's column - add
booktabs
packages for horizontal rules (you are extrem on opside site of people, which all rows separate by\hline
, you have no one :-) )
\documentclass[a4paper,twocolumn,12pt]{article}
\usepackage[top=25mm,bottom=25mm,left=25mm,right=25mm]{geometry}
\usepackage{amssymb, amsmath}
\usepackage{gensymb}
\usepackage{setspace}
\setstretch{1.44}
%\setlength{\columnsep}{6mm}
\usepackage{siunitx}
\usepackage{booktabs, makecell}
\begin{document}
\begin{table*}
\centering
\begin{tabular}{cc
S[table-format=1.4(1),
separate-uncertainty = true,
table-align-uncertainty=false]
c
>{$\sim} c <{$}}
\toprule
Peak No. & $2\theta(\degree)$ & {d-spacing (\AA)} & hkl values &
\multicolumn{1}{c}{\makecell[b]{Relative\\ Intensity ($\%$)}} \\
\midrule
1 & 23.38 & 3.804(3) & [1 0 1] & 10 \\
2 & 26.65 & 3.345(4) & [0 0 6] & 5 \\
3 & 32.11 & 2.7872(4) & [1 0 5] & 90 \\
4 & 32.71 & 2.7380(3) & [1 1 0] & 100 \\
5 & 42.66 & 2.1196(5) & [1 1 6] & 20 \\
6 & 45.17 & 2.0072(9) & [0 0 10] & 10 \\
7 & 46.93 & 1.9362(2) & [2 0 0] & 40 \\
8 & 56.86 & 1.6194(8) & [1 1 10] & 5 \\
9 & 58.01 & 1.5899(4) & [2 1 5] & 30 \\
10 & 67.15 & 1.3940(5) & [2 0 10] & 10 \\
11 & 68.53 & 1.3693(4) & [2 2 0] & 10 \\
\bottomrule
\end{tabular}
\caption{Bragg angles, $2\theta$ and their respective d-spacings}
\label{xrpd}
\end{table*}
\end{document}
in code below i limited myself only to table relevant packages in preamble: