# Is this possible for inline math line breaks: Have symbol duplicated on the next line?

In certain typographical conventions, it is customary to duplicate symbols of binary mathematical operators when a line break occurs. For instance, if a + b = c is broken at +, the result would be a + on the first line, and + b = c on the second line. Duplication also occurs for logical connectives (\Longrightarrow), and relation symbols which are binary (=), and several arrows (xrightarrow).

The exception to this would be the binary minus sign, –. As example, a – b = c would become a + on the first line, and – b = c on the second line.

Question: Is there a way to do such breaking globally but for inline math only in an automatic way?

Here's an MWE that might be tested to work properly should you choose to answer this question.

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[LGR,T1]{fontenc}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{mathtools}
\usepackage{titlesec}
\usepackage[pdftex]{graphicx}
\usepackage{parskip}
\usepackage[a4paper]{geometry}

%Solution code might go here%

\begin{document}

$a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a$

$b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b$

$c=c=c=c=c=c=c=c=c=c=c=c=c=c=c=c=c=c=c=c=c=c=c=c==c=c=c=c=c=c=c=c=c=c=c=c=c$

$d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d$

$e\xrightarrow{n\to\infty} e\xrightarrow{n\to\infty} e\xrightarrow{n\to\infty} e\xrightarrow{n\to\infty} e\xrightarrow{n\to\infty} e\xrightarrow{n\to\infty} e\xrightarrow{n\to\infty} e\xrightarrow{n\to\infty} e\xrightarrow{n\to\infty} e\xrightarrow{n\to\infty} e\xrightarrow{n\to\infty} e\xrightarrow{n\to\infty} e$

\end{document}


Note: -s are used on purpose. Also: I'm using pdfLaTeX if this is important. (The loaded packages are not really important, however do serve as some kind of a selection. If the proposed solution does not interfere with common packages, that would be ideal).

A previous question looked at doing this only for = and \leq. Is there a more general way without having to specify each symbol separately?

This is also related but less so.

• I don't see how you can avoid defining this for each symbol that you want to allow duplication, especially if you need non-simple duplicates such as - splitting as +\\- (also your mwe is missing \documentclass) Mar 15 '20 at 21:16
• Check the rmathbr package Mar 15 '20 at 21:24
• However I don't think you can do with \xrightarrow: only single symbols can get repeated. Mar 15 '20 at 21:29
• Thank you both for the helpful comments, and thanks to the editor! @egreg That package rmathbr seems to be a goodie indeed for me! A few points. I could do \newcommand{\goesto}{\xrightarrow{n\to\infty}} and then \SetBreakableRel{\goesto} which does work. However, I could not understand how to (1) have – break up as +–; (2) if I instead defined \newcommand{\gotoarg}{\xrightarrow{#1\to #2}}, how should one send this to \SetBreakableRel for arbitrary arguments? Any ideas? Feel free to post everything as an answer, even if it's (almost) just the package itself. Mar 16 '20 at 12:42
• @egreg I have now attempted to convert your suggestion and various other bits and pieces into an answer. Thank you again for your helpful comment. May 1 at 19:39

As suggested by egreg, the package rmathbr is pertinent here. It provides options for most things asked in the OP. Please be sure to use the latest version of rmathbr (at time of writing, this is December 2020).

• Various bugs were fixed, e.g. \coloneqq now works.
• I usually load it after most packages, except possibly bookmark, geometry and the similar.
• See also: documentation. Known issues: with breqn package. With commath makes := asymmetric again even though loading commath makes it symmetric. But \coloneqq is unaffected (works fine).

For many types of breaks, just loading the package is sufficient. The rest of the answer is dedicated to answering specific wishes in OP which need some additional code (parts 1, 2 and 3).

1. New relations/operations that do not have variable arguments

To get a breakable n to infty arrow stuff, define \goesto in the preamble like so:

\newcommand{\goesto}{\xrightarrow{n\to\infty}}
\SetBreakableRel{\goesto}

1. New relations/operations that DO contain variable arguments

To get a breakable a to b arrow stuff (with a and b variables), define \goestoarg in the preamble like so:

\DeclareRobustCommand{\goestoarg}{\brokenrel{\xrightarrow{#1\to#2}}}


(Of course, you can generalise that syntax to suit your needs).

1. Getting an asymmetrically breakable minus –

To get a – b break up as a – and + b, add the following code in the preamble:

\makeatletter
\def\minus@char{\mathchar8704}
\def\plus@char{\mathchar8235}
\def\rmathbr@selector#1{%
\def\x@char{#1}%
\ifx\x@char\minus@char\def\x@char{\plus@char}\fi%
\mathchoice
{\discretionary{}{\hbox{$\m@th\displaystyle\x@char$}}{}}
{\discretionary{}{\hbox{$\m@th\textstyle\x@char$}}{}}
{\discretionary{}{\hbox{$\m@th\scriptstyle\x@char$}}{}}
{\discretionary{}{\hbox{$\m@th\scriptscriptstyle\x@char$}}{}}%
}
\makeatother

• The previous code is from Github. See Request: add option to break the minus symbol asymmetrically. More specifically, see the answer by dryabov. Caveats according to the comment: the other version of breaking +- is more difficult to do; solution may or may not work with package unicode-math (it is for XeLaTeX and LuaLaTeX, so no problem for pdflatex).

Here is the output of an MWE (see after picture): MWE code:

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[LGR,T1]{fontenc}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{mathtools}
\usepackage{titlesec}
\usepackage[pdftex]{graphicx}
\usepackage{parskip}
\usepackage{rmathbr} %<- here is package rmathbr
\usepackage[a4paper]{geometry}

%% part 1 code (no variables) %%
\newcommand{\goesto}{\xrightarrow{n\to\infty}}
\SetBreakableRel{\goesto}
%%-------------%%

%%part 2 code (with variables) %% (from Willie Wong)
\DeclareRobustCommand{\goestoarg}{\brokenrel{\xrightarrow{#1\to#2}}}
%%-------------%%

%%part 3 code (breaking – as –+)%% (from dryabov)
\makeatletter
\def\minus@char{\mathchar8704}
\def\plus@char{\mathchar8235}
\def\rmathbr@selector#1{%
\def\x@char{#1}%
\ifx\x@char\minus@char\def\x@char{\plus@char}\fi%
\mathchoice
{\discretionary{}{\hbox{$\m@th\displaystyle\x@char$}}{}}
{\discretionary{}{\hbox{$\m@th\textstyle\x@char$}}{}}
{\discretionary{}{\hbox{$\m@th\scriptstyle\x@char$}}{}}
{\discretionary{}{\hbox{$\m@th\scriptscriptstyle\x@char$}}{}}%
}
\makeatother
%%-------------%%

\begin{document}

$a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a$

$b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b-b$

$c=c=c=c=c=c=c=c=c=c=c=c=c=c=c=c=c=c=c=c=c=c=c=c=c=c=c=c=c=c=c=c=c=c=c=c=c$

$d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d\Longrightarrow d$

$e\goesto e\goesto e\goesto e\goesto e\goesto e\goesto e\goesto e\goesto e\goesto e\goesto e\goesto e\goesto e$

aasdf asdf asd fasdf asdf  aasdf asdf asd fasdf asdf asdf aasdf asd asdas $eeeeeeeee\goestoarg{a}{b} cccccccccc$ aasdf asdf asd fasdf asdf asdf aasdf asdf asd fasdf asdf asdf

$a \coloneqq b \coloneqq b \coloneqq b \coloneqq b \coloneqq b \coloneqq b \coloneqq b \coloneqq b \coloneqq b \coloneqq b \coloneqq b \coloneqq b \coloneqq b \coloneqq b \coloneqq b \coloneqq b \coloneqq b \coloneqq b \coloneqq b \coloneqq b \coloneqq b \coloneqq b \coloneqq b \coloneqq b \coloneqq b \coloneqq b \coloneqq b \coloneqq b \coloneqq b \coloneqq b \coloneqq b \coloneqq b \coloneqq b \coloneqq b \coloneqq b \coloneqq b \coloneqq b$

\end{document}


Final note: it is also possible to disable breaking with repetition for relations/operators you do not want to be broken like that. I think the syntax is \UnsetBrokenCmd{<your operator/relation name>} (restores to behaviour without rmathbr`).