6

The following code gives me an error:

\documentclass[12pt]{article}
\usepackage[margin=2cm]{geometry}
\usepackage [english]{babel}
\usepackage{amsmath, amssymb}
\usepackage{enumitem, array}
\begin{document}
{\begin{minipage}[t]{\textwidth}
\begin{enumerate}[label=(\roman*)]
{\setlength\itemindent{10pt}\item 
\begin{equation*}
\begin{array}{>{\centering\arraybackslash}m{1.5cm}>{\centering\arraybackslash}m{1.5cm}>{\centering\arraybackslash}m{1.5cm}>{\centering\arraybackslash}m{1.5cm}>{\centering\arraybackslash}m{1.5cm}}

\hline
x & l_{[x]} & d_{[x]} & l_{x+1} & \mathring{e}_{[x]} \\
\hline
\end{array}
\end{equation*}}
\end{enumerate}
\end{minipage}}
\end{document}

Note: for various reasons, I have to keep minipage there. For some reason, this code gives me an error when it compiles. It gives the following output:

enter image description here

The errors either say there is a } missing or a $ missing. My eyes don't see such a thing!

3
  • 1
    >{\centering\arraybackslash$}m{1.5cm}<{$} is the correct input. However, \arraybackslash is really needed only in the last column. Why do you have braces around the minipage and also around the item? Of course the table will always start lower than the item, probably you already know it.
    – egreg
    Commented Jul 24, 2014 at 19:58
  • This is an excerpt from a much larger block of code. The reason why the braces are around the \item is to indent the entire enumerate environment. As for why the minipage is in braces, there is a \hspace that I've used that moves the entire minipage. Commented Jul 24, 2014 at 20:03
  • 1
    Neither pair of braces does anything good.
    – egreg
    Commented Jul 24, 2014 at 20:06

2 Answers 2

5

Only l, c and r columns in array are supposed to contain just math mode material, since paragraphs in math mode don't make much sense. However, you can state math mode in p, m or b columns by adding $ to the specifications. Namely

\begin{equation*}
\begin{array}{
  >{\centering\arraybackslash$}m{1.5cm}<{$}
  >{\centering\arraybackslash$}m{1.5cm}<{$}
  >{\centering\arraybackslash$}m{1.5cm}<{$}
  >{\centering\arraybackslash$}m{1.5cm}<{$}
  >{\centering\arraybackslash$}m{1.5cm}<{$}
}
\hline
x & l_{[x]} & d_{[x]} & l_{x+1} & \mathring{e}_{[x]} \\
\hline
\end{array}
\end{equation*}

Actually, \arraybackslash is necessary only in the last column. It would be much easier adding

\newcolumntype{M}[1]{>{\centering\arraybackslash$}m{#1}<{$}}

to your preamble and specify the table as

\begin{equation*}
\begin{array}{ *{5}{M{1.5cm}} }
\hline
x & l_{[x]} & d_{[x]} & l_{x+1} & \mathring{e}_{[x]} \\
\hline
\end{array}
\end{equation*}
3

Your problem comes from the blankline and the fact the m type columns are not in math mode. While I was at it, I simplified your code:

\documentclass[12pt]{article}
\usepackage[margin=2cm]{geometry}
\usepackage [english]{babel}
\usepackage{amsmath, amssymb}
\usepackage{enumitem, array}

\begin{document}

{\begin{minipage}[t]{\textwidth}
\begin{enumerate}[label=(\roman*)]
{\setlength\itemindent{10pt}\item%
\begin{equation*}
\begin{array}{*{5}{>{\centering\arraybackslash $}m{1.5cm}<{$}}}
\hline
x & l_{[x]} & d_{[x]} & l_{x+1} & \mathring{e}_{[x]} \\
\hline
\end{array}
\end{equation*}}
\end{enumerate}
\end{minipage}}

\end{document} 

enter image description here

3
  • Very nice. I suppose *{5} means to repeat the code afterward five times? Commented Jul 24, 2014 at 20:29
  • Exactly. I think it's defined in the array package.
    – Bernard
    Commented Jul 24, 2014 at 20:36
  • I know this is old but actually, you don't need any package to use the syntax *{x}{y} to repeat x times the column defined by y.
    – Anab
    Commented Aug 25, 2016 at 5:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .