文本模式下换行符上重复等号

文本模式下换行符上重复等号

在西里尔印刷传统中,您需要在换行符处重复数学运算符(+、=、-、x)。在此之后回答我可以让它在数学模式下工作。如何在文本模式下使 = 在换行符上重复:

在此处输入图片描述

平均能量损失

\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

在此处输入图片描述

\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}

或者

\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}

相关内容