# putting \textbf{} inside \newcommand

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.

• Why don't you use a proper sectioning command like \paragraph or something like this? – Ulrike Fischer Sep 23 '16 at 21:36
• Do you want the problem number to be automatically generated? – GuM Sep 23 '16 at 21:41

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.

• You can add \noindent in the definition, if still needed. – Werner Sep 23 '16 at 21:42