3

I am getting an ! Undefined control sequence error when compiling the following code:

\documentclass[11pt,table,a5paper]{article}
\usepackage{array,ragged2e}
\usepackage{graphicx}
\usepackage[framemethod=TikZ]{mdframed}
\usepackage{lipsum}
\usepackage[top=2cm, bottom=2cm, outer=1cm, inner=2.1cm,twoside, headsep=26pt]{geometry}
\usepackage{ifthen}
\usepackage{wrapfig}
\usepackage{comment}
\usepackage{parskip}
\usepackage{framed} 
\usepackage{sidecap}
\usepackage{longtable}
\begin{document}
\begin{longtable}{|p{2.7cm}|p{1.0cm}|p{2.4cm}|p{1.0cm}|p{1.3cm}|p{0.8cm}|} 
\hline 
\rowcolor{white} \textbf{ \textcolor{white}{A}} &\textbf{ \textcolor{white}{B}} &\textbf{ \textcolor{white}{C}}  &\textbf{ \textcolor{white}{D}} &\textbf{    \textcolor{white}{E}} &\textbf{ \textcolor{white}{P}} \\ 
\endfirsthead
\rowcolor{white} \textbf{ \textcolor{white}{A}} &\textbf{ \textcolor{white}{B}} &\textbf{ \textcolor{white}{C}}  &\textbf{ \textcolor{white}{D}} &\textbf{    \textcolor{white}{E}} &\textbf{ \textcolor{white}{P}} \\  
\endhead 
\hline 
\newcommand{\dsr}{\rule[-3.5cm]{0pt}{4cm}} 
\dsr  XXXXXXX  & \dsr  3.38&  \multirow{1}{*}{\parbox{2.5cm}  {\textcolor{black}{XXXXXXX >2,~\\ 
~\\ 
XXXXXXX~\\ 
~\\ 
XXXXXy XXXXX XXXXX XXXXX}}} 
&\dsr 2.36\% & \dsr 0.62\% & \dsr 18 \\\cline{1-2} \cline{4-6} 
\hline 
\end{longtable}} 
\end{document}

How to fix this issue?

2
  • 2
    Welcome to TeX.SX! Usually, we don't put a greeting or a “thank you” in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Accepting and upvoting answers is the preferred way here to say “thank you” to users who helped you.
    – jub0bs
    Commented Aug 22, 2013 at 4:01
  • 1
    A general programming hint: Define the macro \newcommand{\ttw}[1]{\textbf{ \textcolor{white}{#1}}} in the preamble, and then set up the column header items as \ttw{A}, \ttw{B}, etc. Much easier to read and to debug...
    – Mico
    Commented Aug 22, 2013 at 5:01

1 Answer 1

4

Moving the definition of \dsr command to before \begin{longtable} and adding \usepackage{multirow} in the preamble seem to solve the problem.

A definition inside a cell is only defined in the cell (which forms a group) unless it is made global. (Thanks to Qrrbrbirlbel for mentioning this in the comment.)

Output looks like this:

enter image description here

2
  • 4
    Yes, a definition inside a cell is only defined in the cell (which forms a group) unless it is made global. Commented Aug 22, 2013 at 4:38
  • @Qrrbrbirlbel: Thanks :-) I've updated my answer to include your comment.
    – Herr K.
    Commented Aug 22, 2013 at 4:44

You must log in to answer this question.

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