如何从 rmathbr 包中向 \SetBreakableRel 内的 \newcommand 添加变量参数?(内联数学重复)

如何从 rmathbr 包中向 \SetBreakableRel 内的 \newcommand 添加变量参数?(内联数学重复)

rmathbr是一个包,它支持另一种惯例,即如果内联方程运行时间过长,则将其中断。具体来说,符号会在新行上重复(并保留在前一行)。因此,例如,在第一行上a = b被中断,在第二行上继续。该包是a == b最近更新(2020 年 12 月)。

  • 在尝试回答问题时,请考虑使用最新版本;否则可能会出现意外的错误。

\SetBreakableRel包中有一个名为的宏,rmathbr用于创建复合符号,人们也想打破它有重复必要时(见文档)例如,要获得一个易碎的示例用法,将新命令定义\goesto为(在文档序言中)

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

就我而言,这非常有效(线断了,符号重复了):

$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$给出

\goesto 工作原理的示例

问题开始出现当尝试定义新的命令(破坏和重复)时也接受变量参数。例如,如果n和 ∞ 我们希望有变量#1#2,即

\newcommand{\goestoarg}[2]{\xrightarrow{#1\to#2}} %<-- this doesn't work
\SetBreakableRel{\goestoarg} %<-- this doesn't work

那么这会产生错误并且不起作用:例如,$\goestoarg{a}{b}$只给出错误输出示例(这从一开始就是错误的符号,所以我没有尝试查看它是否在换行符处重复)。为了表明问题可能来自rmathbr:如果一个(仅)注释掉\SetBreakableRel{\goestoarg},则会出现预期的输出:无需 rmathbr 即可工作。当然,我拥有它未注释强制换行有重复对于这种关系\goestoarg

  • 问题:如何\goestoarg用两个参数进行定义以使其正常工作\SetBreakableRel

我也尝试过放置两个#(即,##而不是#,参见下面的 MWE),但没有成功。


这是代码(带有一些附加包来提示需要与其他包的兼容性):

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

\newcommand{\goesto}{\xrightarrow{n\to\infty}} %works great
\SetBreakableRel{\goesto} %works great

%%%%% uncomment as necessary

%\newcommand{\goestoarg}[2]{\xrightarrow{#1\to#2}} %<-- this doesn't work
%\SetBreakableRel{\goestoarg} %<-- this doesn't work

%\newcommand{\Goestoarg}[2]{\xrightarrow{##1\to##2}} %<-- this also doesn't work
%\SetBreakableRel{\Goestoarg} %<-- this also doesn't work


\begin{document}


$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$

%$\goestoarg{a}{b}$ %<- does not work
%$\Goestoarg{a}{b}$ %<- also does not work


\end{document}

这是日志文件\goestoarg(三行:定义SetBreakableRel和用法$\goestoarg{a}{b}$未注释。这是整个日志文件的子集;我将其缩小到rmathbr加载时开始,因为超出了 30 000 个字符的限制。错误出现在日志末尾附近的 TeX 内存使用输出之前。

(C:\Users\Lala\AppData\Local\Programs\MiKTeX 2.9\tex/latex/rmathbr\rmathbr.st
y
Package: rmathbr 2020/12/18 1.1.1 Repeating of math operator at the broken line
 and the new line in inline equations

(C:\Users\Lala\AppData\Local\Programs\MiKTeX 2.9\tex/generic/iftex\ifetex.sty
Package: ifetex 2019/10/25 v1.3 ifetex legacy package. Use iftex instead.
(C:\Users\Lala\AppData\Local\Programs\MiKTeX 2.9\tex/generic/iftex\iftex.sty
Package: iftex 2020/03/06 v1.0d TeX engine tests
))
(C:\Users\Lala\AppData\Local\Programs\MiKTeX 2.9\tex/generic/iftex\ifluatex.s
ty
Package: ifluatex 2019/10/25 v1.5 ifluatex legacy package. Use iftex instead.
)
(C:\Users\Lala\AppData\Local\Programs\MiKTeX 2.9\tex/latex/xkeyval\xkeyval.st
y
Package: xkeyval 2020/11/20 v2.8 package option processing (HA)

(C:\Users\Lala\AppData\Local\Programs\MiKTeX 2.9\tex/generic/xkeyval\xkeyval.
tex
(C:\Users\Lala\AppData\Local\Programs\MiKTeX 2.9\tex/generic/xkeyval\xkvutils
.tex
\XKV@toks=\toks30
\XKV@tempa@toks=\toks31
)
\XKV@depth=\count271
File: xkeyval.tex 2014/12/03 v2.7a key=value parser (HA)
))
(C:\Users\Lala\AppData\Local\Programs\MiKTeX 2.9\tex/latex/l3kernel\expl3.sty
Package: expl3 2021-02-18 L3 programming layer (loader) 

(C:\Users\Lala\AppData\Local\Programs\MiKTeX 2.9\tex/latex/l3backend\l3backen
d-pdftex.def
File: l3backend-pdftex.def 2021-03-18 L3 backend support: PDF output (pdfTeX)
\l__color_backend_stack_int=\count272
\l__pdf_internal_box=\box51
)))
(C:\Users\Lala\AppData\Local\Programs\MiKTeX 2.9\tex/latex/graphics\graphicx.
sty
Package: graphicx 2020/09/09 v1.2b Enhanced LaTeX Graphics (DPC,SPQR)

(C:\Users\Lala\AppData\Local\Programs\MiKTeX 2.9\tex/latex/graphics\graphics.
sty
Package: graphics 2020/08/30 v1.4c Standard LaTeX Graphics (DPC,SPQR)

(C:\Users\Lala\AppData\Local\Programs\MiKTeX 2.9\tex/latex/graphics\trig.sty
Package: trig 2016/01/03 v1.10 sin cos tan (DPC)
)
(C:\Users\Lala\AppData\Local\Programs\MiKTeX 2.9\tex/latex/graphics-cfg\graph
ics.cfg
File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration
)
Package graphics Info: Driver file: pdftex.def on input line 105.

(C:\Users\Lala\AppData\Local\Programs\MiKTeX 2.9\tex/latex/graphics-def\pdfte
x.def
File: pdftex.def 2020/10/05 v1.2a Graphics/color driver for pdftex
))
\Gin@req@height=\dimen164
\Gin@req@width=\dimen165
)
(C:\Users\Lala\AppData\Local\Programs\MiKTeX 2.9\tex/latex/parskip\parskip.st
y
Package: parskip 2021-03-14 v2.0h non-zero parskip adjustments

(C:\Users\Lala\AppData\Local\Programs\MiKTeX 2.9\tex/latex/kvoptions\kvoption
s.sty
Package: kvoptions 2020-10-07 v3.14 Key value format for package options (HO)

(C:\Users\Lala\AppData\Local\Programs\MiKTeX 2.9\tex/generic/ltxcmds\ltxcmds.
sty
Package: ltxcmds 2020-05-10 v1.25 LaTeX kernel commands for general use (HO)
)
(C:\Users\Lala\AppData\Local\Programs\MiKTeX 2.9\tex/generic/kvsetkeys\kvsetk
eys.sty
Package: kvsetkeys 2019/12/15 v1.18 Key value parser (HO)
))
(C:\Users\Lala\AppData\Local\Programs\MiKTeX 2.9\tex/latex/etoolbox\etoolbox.
sty
Package: etoolbox 2020/10/05 v2.5k e-TeX tools for LaTeX (JAW)
\etb@tempcnta=\count273
))
(C:\Users\Lala\AppData\Local\Programs\MiKTeX 2.9\tex/latex/geometry\geometry.
sty
Package: geometry 2020/01/02 v5.9 Page Geometry

(C:\Users\Lala\AppData\Local\Programs\MiKTeX 2.9\tex/generic/iftex\ifvtex.sty
Package: ifvtex 2019/10/25 v1.7 ifvtex legacy package. Use iftex instead.
)
\Gm@cnth=\count274
\Gm@cntv=\count275
\c@Gm@tempcnt=\count276
\Gm@bindingoffset=\dimen166
\Gm@wd@mp=\dimen167
\Gm@odd@mp=\dimen168
\Gm@even@mp=\dimen169
\Gm@layoutwidth=\dimen170
\Gm@layoutheight=\dimen171
\Gm@layouthoffset=\dimen172
\Gm@layoutvoffset=\dimen173
\Gm@dimlist=\toks32

(C:\Users\Lala\AppData\Local\Programs\MiKTeX 2.9\tex/latex/geometry\geometry.
cfg))
No file Test12.aux.
\openout1 = `Test12.aux'.

LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 27.
LaTeX Font Info:    ... okay on input line 27.
LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 27.
LaTeX Font Info:    ... okay on input line 27.
LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 27.
LaTeX Font Info:    ... okay on input line 27.
LaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 27.
LaTeX Font Info:    ... okay on input line 27.
LaTeX Font Info:    Checking defaults for TS1/cmr/m/n on input line 27.
LaTeX Font Info:    ... okay on input line 27.
LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 27.
LaTeX Font Info:    ... okay on input line 27.
LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 27.
LaTeX Font Info:    ... okay on input line 27.
LaTeX Font Info:    Checking defaults for LGR/cmr/m/n on input line 27.
LaTeX Font Info:    Trying to load font information for LGR+cmr on input line 2
7.

(C:\Users\Lala\AppData\Local\Programs\MiKTeX 2.9\tex/latex/cbfonts-fd\lgrcmr.
fd
File: lgrcmr.fd 2017/07/29 v1.2 Greek European Computer Regular
)
LaTeX Font Info:    ... okay on input line 27.

(C:\Users\Lala\AppData\Local\Programs\MiKTeX 2.9\tex/context/base/mkii\supp-p
df.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
\scratchcounter=\count277
\scratchdimen=\dimen174
\scratchbox=\box52
\nofMPsegments=\count278
\nofMParguments=\count279
\everyMPshowfont=\toks33
\MPscratchCnt=\count280
\MPscratchDim=\dimen175
\MPnumerator=\count281
\makeMPintoPDFobject=\count282
\everyMPtoPDFconversion=\toks34
)
(C:\Users\Lala\AppData\Local\Programs\MiKTeX 2.9\tex/latex/epstopdf-pkg\epsto
pdf-base.sty
Package: epstopdf-base 2020-01-24 v2.11 Base part for package epstopdf
Package epstopdf-base Info: Redefining graphics rule for `.eps' on input line 4
85.

(C:\Users\Lala\AppData\Local\Programs\MiKTeX 2.9\tex/latex/00miktex\epstopdf-
sys.cfg
File: epstopdf-sys.cfg 2021/03/18 v2.0 Configuration of epstopdf for MiKTeX
))
*geometry* driver: auto-detecting
*geometry* detected driver: pdftex
*geometry* verbose mode - [ preamble ] result:
* driver: pdftex
* paper: a4paper
* layout: <same size as paper>
* layoutoffset:(h,v)=(0.0pt,0.0pt)
* modes: 
* h-part:(L,W,R)=(89.62709pt, 418.25368pt, 89.6271pt)
* v-part:(T,H,B)=(101.40665pt, 591.5302pt, 152.11pt)
* \paperwidth=597.50787pt
* \paperheight=845.04684pt
* \textwidth=418.25368pt
* \textheight=591.5302pt
* \oddsidemargin=17.3571pt
* \evensidemargin=17.3571pt
* \topmargin=-7.86334pt
* \headheight=12.0pt
* \headsep=25.0pt
* \topskip=12.0pt
* \footskip=30.0pt
* \marginparwidth=44.0pt
* \marginparsep=10.0pt
* \columnsep=10.0pt
* \skip\footins=10.8pt plus 4.0pt minus 2.0pt
* \hoffset=0.0pt
* \voffset=0.0pt
* \mag=1000
* \@twocolumnfalse
* \@twosidefalse
* \@mparswitchfalse
* \@reversemarginfalse
* (1in=72.27pt=25.4mm, 1cm=28.453pt)

LaTeX Font Info:    Trying to load font information for U+msa on input line 30.

(C:\Users\Lala\AppData\Local\Programs\MiKTeX 2.9\tex/latex/amsfonts\umsa.fd
File: umsa.fd 2013/01/14 v3.01 AMS symbols A
)
LaTeX Font Info:    Trying to load font information for U+msb on input line 30.


(C:\Users\Lala\AppData\Local\Programs\MiKTeX 2.9\tex/latex/amsfonts\umsb.fd
File: umsb.fd 2013/01/14 v3.01 AMS symbols B
)
! Argument of \rmathbr@orig@goestoarg has an extra }.
<inserted text> 
                \par 
l.32 $\goestoarg{
                 a}{b}$ %<- does not work
? 
Runaway argument?
! Paragraph ended before \rmathbr@orig@goestoarg was complete.
<to be read again> 
                   \par 
l.32 $\goestoarg{
                 a}{b}$ %<- does not work
? 
! Missing $ inserted.
<inserted text> 
                $
l.32 $\goestoarg{
                 a}{b}$ %<- does not work
? 
! Missing } inserted.
<inserted text> 
                }
l.32 $\goestoarg{
                 a}{b}$ %<- does not work
? 
! Too many }'s.
<recently read> }
                 
l.32 $\goestoarg{
                 a}{b}$ %<- does not work
? 
! Missing $ inserted.
<inserted text> 
                $
l.34 
     
? 
[1

{C:/Users/Lala/AppData/Local/MiKTeX/2.9/pdftex/config/pdftex.map}]
(Test12.aux) ) 
Here is how much of TeX's memory you used:
 7565 strings out of 479283
 112372 string characters out of 2852377
 434818 words of memory out of 3000000
 24941 multiletter control sequences out of 15000+600000
 408839 words of font info for 46 fonts, out of 8000000 for 9000
 1141 hyphenation exceptions out of 8191
 68i,16n,75p,1197b,108s stack positions out of 5000i,500n,10000p,200000b,80000s
{C:/Users/Lala/AppData/Local/Programs/MiKTeX 2.9/fonts/enc/dvip
s/cm-super/cm-super-t1.enc}<C:/Users/Lala/AppData/Local/Programs/MiKTeX 2.9/f
onts/type1/public/amsfonts/cm/cmmi12.pfb><C:/Users/Lala/AppData/Local/Program
s/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmmi8.pfb><C:/Users/Lala/AppData/
Local/Programs/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmsy10.pfb><C:/Users/R
asmus/AppData/Local/Programs/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmsy8.pf
b><C:/Users/Lala/AppData/Local/Programs/MiKTeX 2.9/fonts/type1/public/cm-supe
r/sfrm1200.pfb>
Output written on Test12.pdf (1 page, 36772 bytes).
PDF statistics:
 27 PDF objects out of 1000 (max. 8388607)
 0 named destinations out of 1000 (max. 500000)
 1 words of extra memory for PDF output out of 10000 (max. 10000000)


我正在运行pdflatex3.141592653-2.6-1.40.22(MikTeX 21.3),并且我本地发行版中的每个软件包都已于今天早些时候更新。

答案1

只进行了最低限度的测试,但应该可以工作。文档中未建议这样做可能有原因,但我无法推断出何时这样的事情会失败。

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

\newcommand{\goesto}{\xrightarrow{n\to\infty}} %works great
\SetBreakableRel{\goesto} %works great

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

\begin{document}


$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$

$e\goestoarg{a}{b} e \goestoarg{a}{b} e \goestoarg{a}{b} e \goestoarg{a}{b} e \goestoarg{a}{b} e \goestoarg{a}{b} e \goestoarg{a}{b} e \goestoarg{a}{b} e \goestoarg{a}{b} e \goestoarg{a}{b} e \goestoarg{a}{b} e \goestoarg{a}{b} e \goestoarg{a}{b} e $ 
%$\Goestoarg{a}{b}$ %<- also does not work


\end{document}

相关内容