[Tex/LaTex] What’s the difference between \paragraph and \paragraph*

sectioningsections-paragraphsstarred-version

Is there any difference between \paragraph{} and \paragraph*{}?

When it's used (if nothing has been modified before, i.e. like in this post: Paragraph header), there's no difference in the created PDF file.

Normally, the * is used to prevent LaTeX to count/number the related object (paragraph here). But here, there's no count/numbering at all for both of them, thus… What's the change, if there is any at all?

Best Answer

Like with all sectioning commands from \section and lower (in the standard document classes), they are defined in terms of \@startsection, which allows for a starred variant. Taken from latex.ltx (with emphasis/comments added):

\def\@startsection#1#2#3#4#5#6{%
  \if@noskipsec \leavevmode \fi
  \par
  \@tempskipa #4\relax
  \@afterindenttrue
  \ifdim \@tempskipa <\z@
    \@tempskipa -\@tempskipa \@afterindentfalse
  \fi
  \if@nobreak
    \everypar{}%
  \else
    \addpenalty\@secpenalty\addvspace\@tempskipa
  \fi
  \@ifstar%  <------------------------------------------ Condition on *
    {\@ssect{#3}{#4}{#5}{#6}}%  <----------------------- starred-version
    {\@dblarg{\@sect{#1}{#2}{#3}{#4}{#5}{#6}}}}%  <----- regular/non-starred version

The difference only becomes noticeable when looking at the inner workings of \@ssect and \@sect - the choices after conditioning on * - the former associated with the starred-version. The main differences include:

  • Numbering, based on the value of the counter secnumdepth. For \paragraph, this is 4. Setting secnumdepth to anything higher than or equal to 4 would reveal the difference;

  • Inclusion in the ToC. Regardless of the value of tocdepth - the counter deciding which sectional units to include in the ToC, the entry is written to the .toc file. Only upon reading the .toc file is it decided to include the entry or not, based on the value of tocdepth.

  • The running heads is triggered by \paragraphmark (when calling \paragraph{..}), initially set to \@gobble. So, without any modifications, this just gobbles its argument - the "paragraph title" and changes nothing in the heading. However, a suitable definition of \paragraphmark would show a different effect when using \paragraph as opposed to \paragraph* where no \paragraphmark is called.