1

I'm trying to have a 2-columns table, with fixed length and text centered on each column. I've found an example in the LaTex documentation (p. 159) but when I try to compile it, it does not work. Here is my code:

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

I get:

./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}|}

? 

Any idea ? Where am I wrong ?

3
  • Welcome to TeX.SE. The (admittedly nearly incomprehensible) error message is caused by a failure to load the array package. Load the package, and your code compiles without further incidents.
    – Mico
    Apr 26 '17 at 0:02
  • Off-topic: Since all instances of \bb appear to occur whlle TeX is in math mode, the macro's definition really ought to be \newcommand{\bb}[1]{\mathbf{#1}}.
    – Mico
    Apr 26 '17 at 0:07
  • @Mico Thanks a lot, you're right! A si simple solution for a so mysterious error message... And thanks for the hint on my \bb command !
    – ariel67
    Apr 26 '17 at 5:50
1

(posted an earlier comment as an answer so that this posting can be considered has having received an "official" answer)

The (admittedly nearly incomprehensible) error message you report is issued when LaTeX is trying to digest the following code snippet:

>{\centering}p{0.1\linewidth}

In order for LaTeX to be able to process this instruction, the array package must be loaded. Load the array package and your example code compiles without further incident.

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.