1

In Cyrillic typography tradition you need to duplicate the math operators (+, =, -, x) on line break. Following this answer I can get it working in math mode. How can I make = duplicate on line break in text mode:

enter image description here

MWE:

\documentclass{article}
\usepackage{amsmath}

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

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

\begin{document}
In math mode: $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 + 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$

In Text mode: 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 + 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}
1
  • 2
    just use a macro that expands to \discretionary{=}{=}{=} Apr 8, 2019 at 18:14

1 Answer 1

2

enter image description here

\documentclass{article}
\usepackage{amsmath}

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

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

\newcommand\z[1]{\ifhmode\unskip\fi\nobreak\ \discretionary{#1}{#1}{#1}\nobreak}

\begin{document}
In math mode: $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 + 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$

In Text mode: a  \z=  b \z= c \z= d \z= e \z= f \z= g \z= h \z= i \z= j \z= k \z= l \z= m \z= n \z= o \z=
p \z= q \z= r \z= s \z= t \z= u \z= v \z= w \z= x \z= y \z= z + 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}

or

\documentclass{article}
\usepackage{amsmath}

\newcommand\z[1]{\relax
\ifmmode
#1\discretionary{}{\the\textfont0 #1}{}%
\else
\ifhmode\unskip\fi\nobreak\ \discretionary{#1}{#1}{#1}\nobreak
\fi}

\begin{document}
In math mode: $a \z= b \z= c \z= d \z= e \z= f \z= g \z= h \z= i \z= j \z= k \z= l \z= m \z= n \z= o \z=
p \z= q \z= r \z= s \z= t \z= u \z= v \z= w \z= x \z= y \z= z + 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$

In Text mode: a  \z=  b \z= c \z= d \z= e \z= f \z= g \z= h \z= i \z= j \z= k \z= l \z= m \z= n \z= o \z=
p \z= q \z= r \z= s \z= t \z= u \z= v \z= w \z= x \z= y \z= z + 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}
4
  • And how can i use \z= in math mode? So I can replace = with \z= in whole document? Apr 8, 2019 at 18:33
  • 1
    @DenysPotapov I added something Apr 8, 2019 at 18:44
  • Thanks! If there will be no answer when i do not need to replace each occurrence of = than i will mark your answer as correct. Apr 8, 2019 at 18:59
  • 1
    @DenysPotapov you could make = active and define it to be as above so not need \z but active = is far more intrusive than the mathcode"8000 "math active" used in your question, it would work in a simple example above but break = in \includegraphics[width=...] or \textwidth=5cm or ... Apr 8, 2019 at 19:01

You must log in to answer this question.

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