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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have tried to see if my error is the same as any of the numerous other threads on this forum with the same content, however I cannot seem to find any that match my problem.

When trying to typeset the following code, I am faced with a ! Misplaced \omit. \multispan ->\omit error.

$$
\begin{array} {l r@{}l@{} r@{}l@{}}
\text{Max}  \quad   &   R   &{}\multicolumn{3}{l}{=\log\left(...............\right)}    \\
\text{s.t.} \quad   &   A   &{}=    B.C.D   &   E   &{}=    F.G.H   \\
                    &   I   &{}=    J.K.L   &   M   &{}=    N.O.P   \\
\end{array}
$$

My aim is to have it look like the following:

Max R=log(......)

s.t. A=B.C.D E=F.G.H

I=J.K.L M=N.O.P

where R, A and I are vertically aligned, as are E and M but they are aligned under the contents of the log to save space.

I am presuming the error is due to the alignment tabs and the multicolumn.

share|improve this question
up vote 3 down vote accepted

The {} group should go inside the \multicolumn; you're forgetting @{} too.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\[
\begin{array} {l r@{}l@{} r@{}l@{}}
\text{Max}  \quad   &   R   &\multicolumn{3}{@{}l}{{}=\log\left(...............\right)}    \\
\text{s.t.} \quad   &   A   &{}=    B.C.D   &   E   &{}=    F.G.H   \\
                    &   I   &{}=    J.K.L   &   M   &{}=    N.O.P   \\
\end{array}
\]

\end{document}

See Why is \[ ... \] preferable to $$ ... $$? for reasons why $$ should never be used in LaTeX.

enter image description here

A different trick:

\documentclass{article}
\usepackage{amsmath}

\newcommand{\multialign}[2]{%
  \multispan{#1}\mbox{$\displaystyle#2$}%
}

\begin{document}

\begin{alignat*}{3}
&\textnormal{Max}  \quad & R &\multialign{3}{{}=\log\left(...............\right)} \\
&\textnormal{s.t.} \quad & A &= B.C.D \quad&  E &= F.G.H \\
&&                         I &= J.K.L \quad&  M &= N.O.P
\end{alignat*}

\end{document}

enter image description here

share|improve this answer

It appears \multicolumn command must appear first in its cell. Your code (completed into a MWE) compiles with {}\multicolumn replaced by \multicolumn and the extra \left removed.

share|improve this answer
    
The problem with removing the {} is that the equals sign between R and log is no longer aligned with the equals signs between A & B and I & J. P.S. that extra \left was accidentally left from what was the contents. I will remove it now. – Daniel Wilson-Nunn Jan 10 at 13:13
1  
\multicolumn{3}{@{}l@{}}{{}=\log\left(..... – jfbu Jan 10 at 13:18

It is not a direct answer to your question, but I would rather use the align environment in that case. The source code and output looks much cleaner to me.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
& \text{Max} & R& =\log\left(\dots\right)\\
& \text{s.t.}& A& = B.C.D & E &= F.G.H\\
&            & I& = J.K.L & M &= N.O.P
\end{align*}
\end{document}

Align

share|improve this answer

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.