1

I am trying to define numbered paragraphs \mypar which can admit an optional <title>. I did the following:

\newcounter{paranum}[section]
\renewcommand{\theparanum}{\thesection.\arabic{paranum}}
\newcommand{\mypar}[1][]{\bigskip%
\noindent%
\refstepcounter{paranum}\textbf{\theparanum\quad#1}}
% Above defines a custom paragraph numbering scheme.

This more of less did the job. The only deficiency is that when I have a title for the paragraph, the spacing following the title (and before the content) is just the usual amount of spacing between words in normal text. However, given that this is the title of the paragraph, I would like there to be some extra spacing following it to separate it from the following normal text. I tried adding the \quad:

\newcounter{paranum}[section]
\renewcommand{\theparanum}{\thesection.\arabic{paranum}}
\newcommand{\mypar}[1][]{\bigskip%
\noindent%
\refstepcounter{paranum}\textbf{\theparanum\quad#1\quad}}
% Above defines a custom paragraph numbering scheme.

This works fine when the title is present; however, it also puts unnecessary extra space even when there isn't a title for the paragraph.

How may I define the command to make sure that there is only one \quad (instead of two) between the paragraph number and the normal-text content when there isn't a title; but also when there is a title, one \quad between the paragraph number and the title, and another \quad between the title and the normal-text content? Any help appreciated!

1 Answer 1

3

Just add conditional to your definition. \@empty is an empty string in LaTeX; since it has @, surround it by \makeatletter/\makeatoher:

\makeatletter
\newcounter{paranum}[section]
\renewcommand{\theparanum}{\thesection.\arabic{paranum}}
\newcommand{\mypar}[1][]{\bigskip%
\noindent%
\refstepcounter{paranum}\textbf{\theparanum\quad\ifx#1\@empty\else#1\quad\fi}}
\makeatother

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .