How to insert a non-stretching but line-breaking thin space?

The biblatex package provides the \addthinspace macro which "[a]dds a breakable thin space" (manual, section 4.7.4). Here's a variant that omits the biblatex-specific stuff. (Note that \, in text mode uses \thinspace which is defined as \kern 0.16667em.)

\documentclass{article}

\newcommand*{\addthinspace}{\hskip0.16667em\relax}

\textwidth=52pt

\begin{document}

\noindent xxx xxx xxx xxx xxx\addthinspace aaa\addthinspace aaa

\bigskip

\noindent xxx xxx xxx xxx xxx\,aaa\,aaa

\end{document}

enter image description here


The \breakingspace macro can be obtained quite easily:

\newcommand{\breakingspace}[1]{#1\hspace{0pt}}

Quoting from the TeXbook (p. 96):

Line breaks can occur only in certain places within a horizontal list. Roughly speaking, they occur between words and after hyphens, but in actuality they are permitted in the following five cases:

a) at glue, provided that this glue is immediately preceded by a non-discardable item, and that it is not part of a math formula (i.e., not between math-on and math-off). A break “at glue” occurs at the left edge of the glue space.

b) at a kern, provided that this kern is immediately followed by glue, and that it is not part of a math formula.

c) at a math-off that is immediately followed by glue.

d) at a penalty (which might have been inserted automatically in a formula).

e) at a discretionary break.

Another way might be

\newcommand{\breakingspace}[1]{{\let\kern\hskip#1}}

Example:

\documentclass{article}
\usepackage{calc}
\newcommand{\breakingspace}[1]{#1\hspace{0pt}}

\begin{document}
\fboxsep=0pt
\fbox{\parbox{\widthof{a\,a}}{
a\breakingspace{\,}a\breakingspace{\,}%
a\breakingspace{\,}a\breakingspace{\,}%
a\breakingspace{\,}a\breakingspace{\,}%
a}}

\renewcommand{\breakingspace}[1]{{\let\kern\hskip#1}}

\fbox{\parbox{\widthof{a\,a}}{
a\breakingspace{\,}a\breakingspace{\,}%
a\breakingspace{\,}a\breakingspace{\,}%
a\breakingspace{\,}a\breakingspace{\,}%
a}}
\end{document}

enter image description here

With both definitions, \breakingspace will not do anything in math mode other than adding glue or kerns; with the other possibility

\newcommand{\badbreakingspace}[1]{\penalty 0 #1}

one would add a break point also in math mode.


Just to mention that the simple \allowbreak\, seems to respond to the OP's demands. In this answer, I first tried with \allowbreak\,\allowbreak but this is a bit silly so I then turned to \allowbreak\,. As the OP said \,\allowbreak is a no-go. In passing, a funny effect is noticed when the text in the testing \parbox is not ended by a \\ or a \par.


In my testing \allowbreak\,\allowbreak works (in text mode, did not try math mode). To illustrate it and check that no thin space is present at the end of the line I replace in the following code the \, by a \bigspace of 2em.

\documentclass{article}
\begin{document}\thispagestyle{empty}

\ttfamily 

\newcommand\bigspace{\kern 2em}

\newlength\awidth
\settowidth{\awidth}{A\bigspace A\bigspace A}

\newcommand\breakingspace{\allowbreak\bigspace\allowbreak}

\fboxsep=0pt

\fbox{\parbox{\awidth}{
A\rule{2em}{1pt}A\rule{2em}{1pt}A\\
A\breakingspace
B\breakingspace
C\breakingspace
D\breakingspace
E\breakingspace
F\breakingspace
G\breakingspace
H\breakingspace
I\breakingspace
J\breakingspace
K\breakingspace
L\\
A\breakingspace
B\breakingspace
C\breakingspace
D\breakingspace
E\breakingspace
F\breakingspace
G\breakingspace
H\breakingspace
I\breakingspace
J\breakingspace
K\breakingspace
L\breakingspace
}}
\end{document}

output of the code

Hope somebody will explain the behavior at the end of the text when it is ended by \breakingspace. . .


Actually, \allowbreak\, works about the same as \allowbreak\,\allowbreak. As shown by this variant:

\renewcommand\breakingspace{\allowbreak\bigspace}

\fbox{\parbox{\awidth}{
A\rule{2em}{1pt}A\rule{2em}{1pt}A\\
A\breakingspace
B\breakingspace
C\breakingspace
D\breakingspace
E\breakingspace
F\breakingspace
G\breakingspace
H\breakingspace
I\breakingspace
J\breakingspace
K\breakingspace
L\breakingspace
}}
\fbox{\parbox{\awidth}{
A\rule{2em}{1pt}A\rule{2em}{1pt}A\\
A\breakingspace
B\breakingspace
C\breakingspace
D\breakingspace
E\breakingspace
F\breakingspace
G\breakingspace
H\breakingspace
I\breakingspace
J\breakingspace
K\breakingspace
L\breakingspace
M\breakingspace
}}

second image

I deliberately left \breakingspace at the end, rather than \par to show a funny effect. It is also interesting how the behavior is slightly different for the two definitions of \breakingspace. Note though that in both cases nothing surprising happens if one ends the thing with a \par rather than a \breakingspace.