Suppose that I want to create a new command named step, which functionally add Step 1., Step 2., and so on in the proof. This can be done by:

\newcommand{\step}{\stepcounter{stepnum}\textbf{Step \arabic{stepnum}}.}

The problem is, which will not automatically start a newline at the end of each step, but this can be fixed by:

\newenvironment{step}{\stepcounter{stepnum}\textbf{Step \arabic{stepnum}}.}{\par}

I "hate" to write \begin{step} and \end{step} each time, clearly the command \step is more simple, but in the later case \step will not add a par at the end of line.

How can I fix this?

  • 7
    consider adding \par at the beginning of the expansion of the command. if it's in vertical mode, it should make no difference; if in horizontal mode, it will have the desired effect. assuming you're using an environment for proof, that should take care of the end of the group. – barbara beeton Apr 15 '13 at 12:48
  • It works! But why the "beginning" par are working at the "end" of line? even through I have more than one paragraph in a step? – user19832 Apr 15 '13 at 12:58
  • TOO Long, I can't get the point, why this related? – user19832 Apr 15 '13 at 13:04
  • @barbarabeeton's suggestion is very nice, otherwise you could define your command with an argument: \newcommand{\step}[1]{\stepcounter{stepnum}\textbf{Step \arabic{stepnum}}. #1\par} \step{This is the first step}\step{This is the second step} should work. – AndreasT Apr 15 '13 at 13:13
  • 4
    If you are automatically enumerating something it is better to use \refstepcounter rather than \stepcounter then you can use label/\ref. Also it's normally better to use a list environment definition: your definition is essentially the definition of \item but the standard definition goes to a lot of trouble to get \par handling right. – David Carlisle Apr 15 '13 at 13:49

I'd do it differently:

  \textbf{Step \arabic{stepnum}}.\enspace\ignorespaces

Thus you can do

\step This is the first
\step And the second

\step Third

The blank line is optional.

However, using enumitem is better.

  label=\textbf{Step \arabic*}.,


\item This is the first
\item And the second

\item Third


enter image description here

You can customize the list in many ways.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.