# Breakable period

LaTeX will not insert a line break before or after a period . I understand why you'd want to avoid line break before a period, since you'd otherwise get stranded periods at the end of sentences. I assume there are good reasons for not allowing breaks after a period also (perhaps to avoid splitting abbreviations such as e.g.)

But sometimes you do want to be able to break a line after a period, or at least allow the line to be broken at that juncture. In linguistics, for example, words in foreign languages are commonly glossed with the morphology explicitly explained with grammatical codes separated by periods without space, as in e.g. f.dat.sg.indef. In the following example, the line should be broken as 'f.dat.sg. - indef'.

Is there a way to use such "breakable periods" in LaTeX?

\documentclass{article}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
Abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd ab f.dat.sg.indef'.
\end{document}


-

A simple application of expl3:

\documentclass{article}

\usepackage{xparse}

\ExplSyntaxOn
\NewDocumentCommand{\gloss}{m}
{
\tl_set:Nn \l_tmpa_tl { #1 }
\tl_replace_all:Nnn \l_tmpa_tl { . } { .\- }
\tl_use:N \l_tmpa_tl'
}
\ExplSyntaxOff

\begin{document}

Abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd ab f.dat.sg.indef'.

Abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd ab \gloss{f.dat.sg.indef}.

\end{document}


We just replace every period by .\- (with a discretionary hyphen).

If you have to obey to rules that don't care about the reader, then

\documentclass{article}

\usepackage{xparse}

\ExplSyntaxOn
\NewDocumentCommand{\gloss}{m}
{
\tl_set:Nn \l_tmpa_tl { #1 }
\tl_replace_all:Nnn \l_tmpa_tl { . } { .\discretionary{}{}{} }
\tl_use:N \l_tmpa_tl'
}
\ExplSyntaxOff

\begin{document}

Abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd ab \gloss{f.dat.sg.indef}.

\end{document}


will do.

-
What if I don't want the hyphen? –  Sverre May 20 at 17:02
@Sverre change \- to \linebreak[0] :-) –  David Carlisle May 20 at 17:06
@Sverre You do want the hyphen. ;-) –  egreg May 20 at 17:09
No I don't: Leipzig glossing rules :) –  Sverre May 20 at 17:12
Hyphen and period mean two different things in this tradition, so that's just the way it is ... –  Sverre May 20 at 17:41

LaTeX will normally break after a full stop (at the space). If you have a specialist use where there is no following space one easy way is to use url package and

\url{f.dat.sg.indef}


or by hand

f.\linebreak[0]dat.\linebreak[0]sg.\linebreak[0]indef}

-
What does the [0] after \linebreak do? –  Sverre May 20 at 16:43
It allows a break without saying it's good or bad (\penalty0 in plain) the option can be 0 to 4 where 4 is the default and forces a break –  David Carlisle May 20 at 16:54
Both answers are equally acceptable, but I like the \gloss macron defined by egreg. –  Sverre May 21 at 14:03
@Sverre oh no, not to egreg that's a disaster:-) –  David Carlisle May 21 at 14:44