# I want to include a closing bracket } in a \newcommand definition

I want to use the closing bracket in a \newcommand definition. I can give more explanation as to why, but this seems unnecessary at the moment. Obviously the MWE does not work, but how to make this work?

MWE

\documentclass{minimal}
\newcommand{\test}{somecommand}}

\begin{document}
Hi
\end{document}


which gives the error

! Too many }'s.

• Do you want to end a group, or do you want to display the }? Oct 17, 2014 at 13:07
• End a group. I have another command with an opening bracket, some text in between and then a command with a closing bracket (the one I am asking about now).
– Ritz
Oct 17, 2014 at 13:09
• then why not use \begingroup and \endgroup? Oct 17, 2014 at 13:11

You can use \bgroup and \egroup to begin and end groups in such circumstances.
\documentclass[11pt,a4paper]{article}