# Question

Is it possible to keep the \item commands in the body and wrap the itemize list environment with \NewEnviron from the environ package? I am also trying to wrap the list inside a TikZ node, which is also wrapped in a minipage :), which I know is possible from here.

## Purpose

Keep source code as simple as possible.

## Sample Code

\documentclass{article}
\usepackage{fontspec}
\usepackage{tikz}
\usetikzlibrary{calc,positioning}
\usepackage{environ} % \NewEnviron command collects body and can be accessed by \BODY macro within the definition for making custom environments

\NewEnviron{RedBoxList}[1][MISSING VARIABLE!]{%
\begin{tikzpicture}[remember picture, overlay]
\path [fill=red] (current page.north west) rectangle (current page.north);
\node [xshift=5mm,yshift=-10mm,anchor=north west, align=left] (nodeID) at (current page.north west) {%
\begin{minipage}[t]{.6\linewidth}
\textcolor{white}{%
{\Huge #1}
\begin{itemize}
\BODY
\end{itemize}
}% end textcolor white
\end{minipage}
};% end node
\end{tikzpicture}
}% end NewEnviron

\begin{document}
\begin{RedBoxList}{Title of the Box}
\item test1
\item test2
\item test3
\end{RedBoxList}
\end{document}

• There are some other issues besides wrapping the list. The \path does nothing as it has no vertical extend (north to north). Therefore you don't see a result due to white text on white background. – Harald Jan 22 '15 at 9:39
• Yikes, there is also that problem! It seems like I have two issues going on here. One pointed out by egreg and DavidCarlisle is that I used braces instead brackets for my first variable input in the body text. The second is with TikZ and the current page nodes. – Jonathan Komar Jan 22 '15 at 9:50

You are defining RedBoxList with an optional argument, not a mandatory one, so

\begin{RedBoxList}[Title of the Box]
\item test1
\item test2
\item test3
\end{RedBoxList}


will do what you want it to.

However, it seems a bad user interface: forgetting the optional argument will result in the title being “MISSING VARIABLE!”, so this argument is better managed as mandatory:

 \NewEnviron{RedBoxList}[1]{%
<same code as before>
}

• It is used for a document that is translated into multiple languages. By default, English will be used, not MISSING VARIABLE (that is just for debugging and drawing attention to it in the output). So is my code correct except for the [] instead of {} around the variables? – Jonathan Komar Jan 22 '15 at 9:43
• @macmadness86 I can't read your mind. But the syntax you're using requires the argument being in [...]. – egreg Jan 22 '15 at 9:54
• Ok, not sure about the reading my mind part, but that's what I wanted to know! Thanks for the help. I am stuck as whether to mark your answer as correct or the one from David Carlisle. Both taught me something. – Jonathan Komar Jan 22 '15 at 9:57
• @macmadness86 When faced with that dilemma there is always an obvious resolution! (hint: not the one you chose:-) – David Carlisle Jan 23 '15 at 9:32
• Haha :) Well, I considered basing my decision on the answer times, but I concluded that egreg's answer corrected my mistake most efficiently. It was a tough call. – Jonathan Komar Jan 23 '15 at 9:49

You need to declare the Title of The Box argument. I changed to [2] this means it doesn't use the optional argument #1 but I don't know your intended use for that

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{calc,positioning}
\usepackage{environ} % \NewEnviron command collects body and can be accessed by \BODY macro within the definition for making custom environments

\NewEnviron{RedBoxList}[2][MISSING VARIABLE!]{%
\begin{tikzpicture}[remember picture, overlay]
\path [fill=red] (current page.north west) rectangle (current page.north);
\node [xshift=5mm,yshift=-10mm,anchor=north west, align=left] (nodeID) at (current page.north west) {%
\begin{minipage}[t]{.6\linewidth}%\show\BODY
\textcolor{white}{%
{\Huge #2}
\begin{itemize}
\BODY
\end{itemize}
}% end textcolor white
\end{minipage}
};% end node
\end{tikzpicture}
}% end NewEnviron

\begin{document}
\begin{RedBoxList}{Title of the Box}
\item test1
\item test2
\item test3
\end{RedBoxList}
\end{document}

• Ok, I think I see the problem now. Between you and egreg I think I see the problem. So in your example, MISSING VARIABLE! would replace #1 and Title of the Box would replace #2, correct? – Jonathan Komar Jan 22 '15 at 9:52
• @macmadness86 yes – David Carlisle Jan 22 '15 at 10:32