5

I ran into a problem with “! Misplaced \omit” error. I have searched quite hard to find the relevant problem but only find mine is similar with bigbadpiano's question in which A.Ellett generated a nice table with WME.

However, my personal desire is to put one multicolumn as black background and white text, for instance: an failed example

This is an failed example since the whole first row should be black. I also get an error in Log File:" ! Misplaced \omit. \multispan ->\omit \@multispan l.10 ...multicolumn{8}{|c|}{\BlackCell{Dataset A}} \\hline I expect to see \omit only after tab marks or the \cr of an alignment. Proceed, and I'll ignore this case."

If this question is duplicate, I am really sorry but I couldn't find the correct answer to my specific problem. In this case, please inform me the exact answer and I will delete this question later. Any help is appreciated.

\documentclass{article} \pagestyle{empty} \usepackage[table]{xcolor} \newcommand\BlackCell[1]{% \multicolumn{1}{c}{\cellcolor{black}\textcolor{white}{#1}} } \begin{document} \begin{table}[h] \begin{tabular}{|c|c|c|c|c|c|c|c|}\hline \multicolumn{8}{|c|}{\BlackCell{Dataset A}} \\\hline L (m) & T (s) & T$^2$ (s$^2$) & L$^{1/2}$ (m$^{1/2}$) & $\Delta$T$^2$ (s$^2$) & $\Delta$T (s) & Fitted T$^2$ (s$^2$) & Fitted T (s) \\ \hline 0.2 & 0.626 & 0.392 & 0.447 & 0.006 & 0.005 & 0.394 & 0.662 \\ 0.3 & 0.889 & 0.790 & 0.548 & 0.009 & 0.005 & 0.797 & 0.889 \\ 0.4 & 1.105 & 1.221 & 0.632 & 0.011 & 0.005 & 1.201 & 1.081 \\ 0.5 & 1.261 & 1.590 & 0.707 & 0.013 & 0.005 & 1.604 & 1.250 \\ 0.6 & 1.420 & 2.016 & 0.775 & 0.014 & 0.005 & 2.008 & 1.403 \\ 0.7 & 1.555 & 2.418 & 0.837 & 0.016 & 0.005 & 2.411 & 1.543 \\ 0.8 & 1.679 & 2.819 & 0.894 & 0.017 & 0.005 & 2.814 & 1.674 \\ 0.9 & 1.798 & 3.233 & 0.949 & 0.018 & 0.005 & 3.218 & 1.797 \\ 1.0 & 1.901 & 3.614 & 1.000 & 0.019 & 0.005 & 3.621 & 1.913 \\ 1.1 & 2.000 & 4.000 & 1.049 & 0.020 & 0.005 & 4.025 & 2.023 \\\hline \end{tabular} \end{table} \end{document} 

1 Answer 1

4

You have a \multicolumn inside a \multicolumn which is not allowed (and you had a missing % at end of line). Use

\newcommand\BlackCell[1]{% \cellcolor{black}\textcolor{white}{#1}% } 
2
  • Thank you so much for the answer! It works perfectly now! I don't know what the purposes of the two %s. Are they used to define the invoked functions, while {} are the body of this command? Commented May 10, 2014 at 13:25
  • @Frank No they are comment markers to avoid making spurious space: tex.stackexchange.com/q/7453/1090 Commented May 10, 2014 at 13:31

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.