
我正在嘗試建立 2 列表,其長度固定且文字位於每列的中心。我在 LaTex 文件(第 159 頁)中找到了一個範例,但是當我嘗試編譯它時,它不起作用。這是我的程式碼:
\documentclass[12pt, openright, twoside, a4paper]{book}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english,french]{babel}
\newcommand{\bb}{\textbf}
\begin{document}
\begin{tabular}{|>{\centering}p{0.1\linewidth}|p{0.15\linewidth}|}
\hline
\textbf{SI} & \textbf{Gaussian} \tabularnewline
\hline \hline
$\bb{E}$ & $\bb{E}$ \tabularnewline
$\bb{D}$ & $\bb{D} / 4 \pi$ \tabularnewline
$\bb{H}$ & $c \bb{H} / 4 \pi$ \tabularnewline
$\bb{B}$ & $\bb{B} / c$ \tabularnewline
$\varepsilon_0$ & $1 / 4 \pi$ \tabularnewline
$\mu_0$ & $4 \pi / c^2$ \tabularnewline
$\rho_e$ & $\rho_e$ \tabularnewline
$\bb{J}$ & $\bb{J}$ \tabularnewline
\hline
\end{tabular}
\end{document}
我得到:
./test.tex:10: Use of \@array doesn't match its definition.
\new@ifnextchar ...served@d = #1\def \reserved@a {
#2}\def \reserved@b {#3}\f...
l.10 ...ering}p{0.1\linewidth}|p{0.15\linewidth}|}
?
任何想法 ?我哪裡錯了?
答案1
(發布了較早的評論作為答案,因此該帖子可以被視為已收到“官方”答案)
當 LaTeX 嘗試消化以下程式碼片段時,會發出您報告的(誠然幾乎難以理解的)錯誤訊息:
>{\centering}p{0.1\linewidth}
為了讓 LaTeX 能夠處理該指令,array
必須載入該套件。載入該array
包,您的範例程式碼就會編譯,不會發生進一步的事件。