表的第一行出現此錯誤:
> ! 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 &
這僅在添加表的第五列後發生
\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
如何管理我在評論中描述的錯誤。在這裡我想展示我將如何編寫你的表:
- 新增包
siunitx
以更好更簡單地設定第三個表的列 - 加上
booktabs
水平規則的包(你是人的對面站點的極端,所有行都用 分隔\hline
,你沒有人:-))
\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}
在下面的程式碼中,我只限於在序言中列出相關的套件: