# Correct syntax for using \setstretch{} \color{} \textit{} and scriptsize in same macro?

I am writing a custom macro to display text as footnotes for some custom figures and pictures in my R markdown code, using latex. I need to have scriptsize fontsize, decreased line spacing than rest of document (rest of document is default - I have not set any spacing command for it), gray text color and italics in part of the note. .Rmd file code is below:

---
output:
pdf_document:
latex_engine: pdflatex
fig_caption: yes
keep_tex: yes
documentclass: article
\usepackage{array}
---

\newcommand{\greynote}[1]{
{\scriptsize
\color{darkgray}{\setstretch{0.9}{\textit{Notes:} #1}
}
}
}

**Blah blah**
**Blah blah**
**Blah blah**
**Blah blah**
**Blah blah**

\greynote{Values indicate percentage of respondents who agree or strongly agree with the prompt. Acceptability of absence means percentage of employees who believe that absence is acceptable if there is no more work, or if they are doing something good for their communities. The data has been collected in the Jan-June 2020 period.}



I get below error when I knit the pdf:

! Undefined control sequence.
l.84     \color
{darkgray}{\setstretch{0.9}{\textit{Notes:} Values indicate p..


How do I define the macro correctly? I have rearranged color and setstretch but it does not work.

• You should have \usepackage{xcolor} as well if you want to use color commands. – Marijn Jul 29 '20 at 20:17
• That worked. Thank you! – user3218428 Jul 29 '20 at 21:08