2

[* MWE ADDED AT BOTTOM *]

I need help understanding the error I am getting on the line with only }. They are marked below...While it doesn't affect anything when I compile it, I would like to fix it, because any changes I make cause it to not be able to compile. LaTeX Error: Something's wrong--perhaps a missing \item. Any help would be great.

\documentclass[landscape, 12pt]{report} 
\usepackage{ocgx}
\usepackage{tikz}
\usepackage{array}

\newcommand{\myarrow}{\raisebox{1ex}{\tikz \draw[->, line width=1.25mm] (0,0)--++(1,0);}}

\newcommand{\ocgItem}[2]{%
\colorbox{%
\ifcase#1 \or
red\or
green\fi
}{\huge Item 1}%
}
\begin{document}
\begin{minipage}[t]{5cm}
\switchocg{ocg1}{%
\fcolorbox{black}{white}{%
    \bfseries\Large%
    \resizebox{5cm}{!}{\begin{tabular}{c c c c c c c c c c c c c c}  
\\
\\
\\
  {\Huge Project 1} \\ 
\\
\\
\\
\end{tabular}}}}\\%
    \begin{ocg}{OCG 1}{ocg1}{0}
             \colorbox{white}{%
                \parbox{10cm}{%
                    \colorbox{green}{\begin{center}
\begin{tabular}{m{4.18cm}} 
  Step 1
\end{tabular}
\end{center}
}\\%
                    \colorbox{red}{\normalsize \color{white}{\begin{center}
\begin{tabular}{m{4.3cm}} 
  Step 2
\end{tabular}
\end{center}
}\\%
                    }%
                 } %ERROR ON THIS LINE
    \end{ocg}
\end{minipage}%
\end{document}

[EDIT] MWE below

\documentclass{article} 
\usepackage{xcolor}

\begin{document}    
\colorbox{red}{% 
\begin{center}
\begin{tabular}{c} 
  Step 2
\end{tabular}
\end{center}
} %ERROR ON THIS LINE
\end{document}
4

\colorbox is an horizontal box. Neither environment center nor command \centering do have any business there. The uneven left and right margins comes from the additional unwanted space from the line end after \end{tabular}. Fixed example:

\documentclass{article}
\usepackage{xcolor}

\begin{document}
\colorbox{red}{%
  \begin{tabular}{c}
    Step 2
  \end{tabular}%
}
\end{document}

Result

Centering the \colorbox inside the \parbox is best done with \centering outside \colorbox:

\parbox{10cm}{%
  \centering
  \colorbox{green}{...}%
}
| improve this answer | |
  • You're right.... – JPi Jul 11 '16 at 19:48
3

Replace \begin{center} and \end{center} with \centering and all is well. The code below compiles fine.

\documentclass{article} 
\usepackage{xcolor}




\begin{document}    
\colorbox{red}{% 
\centering
\begin{tabular}{c} 
  Step 2
\end{tabular}
} %NO ERROR ON THIS LINE
\end{document}
| improve this answer | |

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