1

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.

5
  • 1
    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) Commented Mar 15, 2020 at 21:16
  • 1
    Check the rmathbr package
    – egreg
    Commented Mar 15, 2020 at 21:24
  • However I don't think you can do with \xrightarrow: only single symbols can get repeated.
    – egreg
    Commented Mar 15, 2020 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}[2]{\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. Commented Mar 16, 2020 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. Commented May 1, 2021 at 19:39

1 Answer 1

1

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}[2]{\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

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

Output of MWE


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}[2]{\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).

You must log in to answer this question.

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