Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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!

share|improve this question
    
>{\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 Jul 24 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. –  Clarinetist Jul 24 at 20:03
1  
Neither pair of braces does anything good. –  egreg Jul 24 at 20:06

2 Answers 2

up vote 4 down vote accepted

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*}
share|improve this answer

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

share|improve this answer
    
Very nice. I suppose *{5} means to repeat the code afterward five times? –  Clarinetist Jul 24 at 20:29
    
Exactly. I think it's defined in the array package. –  Bernard Jul 24 at 20:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.