[Tex/LaTex] putting \textbf{} inside \newcommand

boldmacros

I use LaTeX mostly for homework assignments. And I would like a faster way to type

\noindent\textbf{problem number} 

Since I do it for every problem and every part of the problem if it has multiple parts.

I was thinking something like this might work, but it isn't:

\newcommand{\HW{}}{\noindent\textbf{}}

I've tried with and without the \textbf brackets.

Best Answer

You need to use the following format:

\newcommand{\HW}{\textbf}

Note that I haven't captured the argument, since \textbf will do this when used as the replacement of \HW. Of course, you can capture and pass the argument if needed via

\newcommand{\HW}[1]{\textbf{#1}}

The only different between these two definitions would be if you had category code changes within the argument.

Related Question