# Allowing breaks at a location with no spaces or hyphens

I have two letters: A and B. In most situations, I'd like them to appear together with no space, e.g. ("AB"), however, if TeX feels it needs a linebreak or to split these across two pages, this is allowed. This could appear as:

AB

Or:

A

B

What can I place between the two letters (or long string of letters), which will allow them to be split across pages?

• This should leave no space.
• This should leave no hyphen.
• This should use the same splitting rules used if the letters actually had a space.
-

If you introduce a small 0pt skip in between the letters TeX will not treat them as a word and will allow them to break as you wish. You can create a macro or use them where you require them. (I used the same example from Schweinebacke for convenience and comparison).

\documentclass{article}

\begin{document}
A\hskip0ptB vs. some text, some text, some text, some text, some text, some text, some
text A\hskip0ptB and some text.

A\hskip0ptB vs. some text, some text, some text, some text, some text, some text, some
text A\hskip0ptB and some text.
\end{document}

-
This would also break/remove kerning (e.g. try VA instead of V\hskip0ptA) and so it would result in something like extra space between the characters. –  Schweinebacke Nov 19 '11 at 9:53
@Schweinebacke Breaking between the letters AB without a hyphen is pretty much bad typography in any case. I wouldn't worry too much over it. From memory using \discretionary would have the same effect. –  Yiannis Lazarides Nov 19 '11 at 10:01
You are wrong, \discretionary would not remove kerning. Simply replace \discretionary{A}{B}{AB} at my example by \discretionary{V}{A}{VA} to compare it. –  Schweinebacke Nov 19 '11 at 10:18

I would simply use \discretionary for this and define a macro to increase comfort.

\documentclass{article}
\usepackage{xspace}% see http://ctan.org/pkg/xspace
\usepackage[textwidth=2.78in,textheight=0.9in]{geometry}% for demonstration only
\usepackage{showframe}% for demonstration only

\newcommand*{\AB}{\discretionary{A}{B}{AB}\xspace}

\begin{document}
\AB vs. some text, some text, some text, some text, some text, some text, some
text \AB and some text.

\AB vs. some text, some text, some text, some text, some text, some text, some
text \AB and some text.
\end{document}


I've used package showframe to demonstrate the width and height of the text area at my example (suggestion from Werner). I've used very small width and height to demonstrate line break and page break.

Here are snapshots of the relevant area of page 1 and 2:

If you want, you may define a more general command:

\documentclass{article}
\usepackage[textwidth=2.78in,textheight=0.9in]{geometry}% for demonstration only
\usepackage{showframe}% for demonstration only

\newcommand*{\breakchars}[2]{\discretionary{#1}{#2}{#1#2}}

\begin{document}
\breakchars AB vs. some text, some text, some text, some text, some text, some
text, some text \breakchars AB and some text.

\breakchars AB vs. some text, some text, some text, some text, some text, some
text, some text \breakchars AB and some text.

\breakchars VA vs. some text, some text, some text, some text, some text, some
text, some text \breakchars VA and some text.

\end{document}


You don't need argument braces at this case, because without the first and second non-space character (letter or other) will be used to be the first and second argument.

The example with VA was made to show, that kerning still works with this suggestion.

-
A\discretionary{}{}{}B is simpler, though. –  egreg Nov 19 '11 at 10:16
@egreg: But it would break kerning. Compare: VA \discretionary{V}{A}{VA} V\discretionary{}{}{}A. The first and the second are kerned, at the third the kerning is missing. –  Schweinebacke Nov 19 '11 at 10:23
Yes, it does. :( –  egreg Nov 19 '11 at 10:26
\documentclass[ngerman,english]{article}
\usepackage{babel}
\useshorthands{"}
\begin{document}

\begin{minipage}{1cm}% only for demonstration
foo bar baz A""B
and some other words
A""B and the same
\end{minipage}

\end{document}


-
Works nice but breaks kerning of the two letters too. Try it with V""A to see this. –  Schweinebacke Nov 19 '11 at 10:36
did I said something different? ;-) it is a solution for AB and not VA ... –  Herbert Nov 19 '11 at 10:43
It is a solution for AB if the used font has no kerning entry for this pair. This seems to be common, but who knows … ;-) Maybe it would be good to know more about the real circumstances of the question to distinguish valid caveats from invalid. BTW: If not only pairs but sequences of characters should be handled, your answer would be very useful - my one not. –  Schweinebacke Nov 19 '11 at 11:03