在 ConTeXt 中,我遵循了例子在输入逐字文本的官方 wiki 上。那里的屏幕截图显示,长行在换行时正确地避免了两次编号。但是,当我运行相同的代码时,长行被错误地重新编号。这是为什么?
\defineframedtext
[framedcode]
[strut=yes,
offset=2mm,
width=7cm,
align=right]
\definetyping[code][numbering=line,
bodyfont=small,
before={\startframedcode},
after={\stopframedcode}]
\starttext
\startcode
This is the first line
This is a rather long line that is wrapped, so look how the line numbering is done
Another line
Last line after an empty line
\stopcode
\stoptext
答案1
这不是对问题的回答,而是对您要求解决方法的评论的回答:
好的,我会在邮件列表中询问。但是现在还有什么方法可以避免重新编号吗?
不建议使用它即使作为一种解决方法但也许是类似的东西?
\defineframedtext
[framedcode]
[strut=yes,
offset=2mm,
width=7cm,
align=right]
\def\startlinenb{%
\definenumber[line]%
\EveryLine{\incrementnumber[line]\inmargin{\ttx\getnumber[line]}}%
}
\def\stoplinenb{%
\resetnumber[line]%
\EveryLine{}%
}
\definetyping[code][bodyfont=small,
before={\startframedcode\startlinenb},
after={\stoplinenb\stopframedcode}]
\starttext
\startcode
This is the first line
This is a rather long line that is wrapped, so look how the line numbering is done
Another line
Last line after an empty line
\stopcode
And some text without line numbering.
\stoptext
请记住,这可能是一个糟糕的解决方案(我刚开始学习 ConTeXt......),但它确实有效。