4

I'm trying to add a dot at the end of the default \paragraph, but want its spacing to be consistent with the usual "post-dot spacing" (and don't want to just use \frenchspacing). The \wordsep command that titlesec provides unfortunately only adds the normal whitespace, not the "post-dot space". I tried adding regular whitespaces in some of the arguments of the \titleformat command (e.g. after the dot, including using \titlesec's explicit option), but it seems to be ignored / gobbled.

\documentclass{article}
\usepackage{titlesec}
\titleformat{\paragraph}[runin]{\normalfont\normalsize\bfseries}{}{0pt}{}[.]
\titlespacing*{\paragraph}{0pt}{3.25ex plus 1ex minus .2ex}{\wordsep}
\begin{document}
    \paragraph{Paragraph} \vrule\\
    \textbf{Paragraph.} \vrule
\end{document}

output (cropped)

1 Answer 1

3

I've been trying to reverse-engineer a bit.

The titlesec package defines \wordsep as

\newcommand\wordsep{\fontdimen\tw@\font \@plus
  \fontdimen\thr@@\font \@minus \fontdimen4\font}

\fontdimen\thr@@\font and such are essentially equivalent to \fontdimen3\font and such (TeXBook p. 345), which are themselves explained in TeXBook p. 433, TeX by Topic p. 31, as well as in How does TeX know how to space different typefaces?.

Now, to find out how TeX changes the spacing after dots specifically, TeXBook p. 351 proves useful, where \nonfrenchspacing is defined:

\def\nonfrenchspacing{\sfcode‘\.=3000 \sfcode‘\?=3000 \sfcode‘\!=3000
  \sfcode‘\:=2000 \sfcode‘\;=1500 \sfcode‘\,=1250 }

TeX by Topic p. 155 explains that \sfcode sets \spacefactor for a specific character. Setting \spacefactor to 3000 here then has three consequences (on the glue following a sentence-ending period):

  • Stretchability is multiplied by 3000/1000
  • Schrinkability is multiplied by 1000/3000
  • Because 3000 is greater or equal to 2000, the "extra space" \fontdimen7\font is added

Hence, I'd expect the following to do the trick:

\newcommand\postdotsep{\dimexpr\fontdimen\thr@@\font+\fontdimen7\font \@plus
  \dimexpr3\fontdimen\thr@@\font \@minus \dimexpr\fontdimen4\font/3}

And indeed, this works!

\documentclass{article}
\usepackage{titlesec}
\makeatletter
\newcommand\postdotsep{\dimexpr\fontdimen\tw@\font+\fontdimen7\font\@plus
  \dimexpr3\fontdimen\thr@@\font \@minus \dimexpr\fontdimen4\font/3}

\titleformat{\paragraph}[runin]{\normalfont\normalsize\bfseries}{}{0pt}{}[.]
\titlespacing*{\paragraph}{0pt}{0pt}{\postdotsep}

\makeatother

\begin{document}
    \paragraph{Paragraph} \vrule\\
    \textbf{Paragraph.} \vrule
\end{document}

You must log in to answer this question.

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