# Automatic reduplication of equal sign in the beginning of broken formula

Suppose we have the following code

\documentclass{article}
\begin{document}
$a=b=c=d=e=f=g=h=i=j=k=l=m=n=o=p=q=r=s=t=u=v=w=x=y=z$
\end{document}


which produces the following result I want to have an additional equal sign automatically added before symbol s.

### UPDATE

The same question about \leq and

$a \leq b \leq c \leq d \leq e \leq f \leq g \leq h \leq i \leq j \leq k \leq l \leq m \leq n \leq o \leq p \leq q \leq r \leq s \leq t \leq u \leq v \leq w \leq x \leq y \leq z$

• Is this method supposed to work for inline-math situations only? The reason I ask is that most display-math environments (other than those of the breqn package) force you to choose explicit line break points -- giving you a chance to supply the extra = sign. Separately, should you maybe be concerned that consecutive = signs without intervening material might confuse your readers? – Mico Jun 25 '12 at 0:43
• I know that this is traditional of Russian typography; but it's unnecessary and, in my opinion, confusing. Perhaps not so much when the equals sign is repeated, but it surely is when a binary operation symbol is repeated. – egreg Jun 25 '12 at 8:10
• Yes, strictly speaking it's unnecessary, but it's a tradition I would like to follow. – Ivan Bychkov Jun 25 '12 at 16:59
• @egreg: Did not know that applied to binary relations as well. Repeating a - sign actually changes the meaning as 9 - 5 is different than 9 - -5 (over two line), so am surprised that that is the standard in Russian typography. – Peter Grill Jun 25 '12 at 18:44
• I've added the definition for \leq as requested. For + it's just like for =. – egreg Jun 26 '12 at 20:29

I wouldn't recommend such repetition. However, with a modification of this answer you can get what you want:

\documentclass{article}
\usepackage{amsmath}

\mathchardef\mathequals=\mathcode=
\begingroup\lccode~==
\lowercase{\endgroup\def~}{\mathequals\discretionary{}{\the\textfont0=}{}}
\AtBeginDocument{\mathcode=="8000 }

\begin{document}
$a=b=c=d=e=f=g=h=i=j=k=l=m=n=o=p=q=r=s=t=u=v=w=x=y=z$
\end{document}


The \AtBeginDocument is necessary because amsmath uses the = symbol for some of its initializations. It doesn't hurt when amsmath is not loaded.

## Other math symbols

Let's see how we can redefine \leq to have the same properties as =. I adapted a trick that I believe is due to the late Michael J. Downes (the main developer of amsmath):

\let\mathleq=\leq
\def\getmeaning#1"#2#3{\noexpand\the\textfont"#3\char"}
\begingroup\edef\x{\endgroup
\def\leq{\mathleq\discretionary{}{\expandafter\getmeaning\meaning\mathleq}{}}}\x


The expansion of \meaning\mathleq is \mathchar"3214 and we need to save the 2 (which is needed as argument to \textfont) leaving 14 in the input stream. After the \edef we get

\def\leq{\mathleq\discretionary{}{\the\textfont"2\char"14}{}}


that is similar to what I used before for =.

• I noticed that current version of solution isn't a friend of \usepackage{amsmath}. – Ivan Bychkov Jun 25 '12 at 21:16
• Now it is fine. – Ivan Bychkov Jun 25 '12 at 21:45
• I managed to adapt your solution to some other binary operation symbols. But I couldn't do it for \leq. Could you provide an extended version of solution suitable for this case also ? – Ivan Bychkov Jun 26 '12 at 20:25

In preambule:

\def\?#1{#1\nobreak\discretionary{}{\hbox{$\mathsurround=0pt #1$}}{}}


Then you should add \? before operations:

\begin{document}
$a \?\leq b \?\leq c \?\leq d \?\leq e \?\leq f \?\leq g \?\leq h \?\leq i \?\leq j \?\leq k \?\leq l \?\leq m \?\leq n \?\leq o \?\leq p \?\leq q \?\leq r \?\leq s \?\leq t \?\leq u \?\leq v \?\leq w \?\leq x \?\leq y \?\leq z$
\end{document}