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.

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?

share|improve this question
1  
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. –  Jubobs Aug 22 '13 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 Aug 22 '13 at 5:01

1 Answer 1

up vote 4 down vote accepted

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

share|improve this answer
3  
Yes, a definition inside a cell is only defined in the cell (which forms a group) unless it is made global. –  Qrrbrbirlbel Aug 22 '13 at 4:38
    
@Qrrbrbirlbel: Thanks :-) I've updated my answer to include your comment. –  Kevin C Aug 22 '13 at 4:44

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.