是否可以创建波浪下划线?像这样,但是是波浪形的:
\setupwhitespace[big]
\starttext
\underbar{\samplefile{knuth}}
\stoptext
答案1
您可以轻松定义自己的undergraphic
使用 MetaFun 中的正弦波。
\setupwhitespace[big]
\startuseMPgraphic{rules:under:wave}
draw function(2, "x", "sin(2*(x mod (2*pi)))", 0, RuleWidth, 1pt)
shifted (0,RuleFactor*RuleOffset+RuleDepth)
withpen pencircle scaled RuleThickness
withcolor RuleColor ;
setbounds currentpicture to unitsquare xysized(RuleWidth,RuleHeight) ;
\stopuseMPgraphic
\definebar
[underwave]
[undergraphic]
[mp=rules:under:wave]
\definebar
[underwaves]
[underwave]
[continue=yes]
\starttext
\underwaves{\samplefile{knuth}}
\stoptext
避免溢出的一种方法可能是使用手绘波浪。现在看起来有点尴尬。肯定还有改进的空间。
\setupwhitespace[big]
\startuseMPgraphic{rules:under:wave}
numeric n ; n := 2 ;
path p ;
p := (0,RuleDepth) for i=0 step n until RuleWidth:
.. (i,RuleDepth) .. (i+1*n/4,RuleDepth+1pt) .. (i+2*n/4,RuleDepth) .. (i+3*n/4,RuleDepth-1pt)
endfor ;
draw p shifted (0,RuleFactor*RuleOffset)
withpen pencircle scaled RuleThickness
withcolor RuleColor ;
setbounds currentpicture to unitsquare xysized(RuleWidth,RuleHeight) ;
\stopuseMPgraphic
\definebar
[underwave]
[undergraphic]
[mp=rules:under:wave]
\definebar
[underwaves]
[underwave]
[continue=yes]
\starttext
\underwaves{\samplefile{knuth}}
\stoptext
避免溢出的另一种选择是在 Lua 中计算正弦。
\setupwhitespace[big]
\startuseMPgraphic{rules:under:wave}
vardef lsin primary x =
lua("mp.print(math.sin(" & decimal x & "))")
enddef ;
draw function(1, "x", "lsin(2*x)", 0, RuleWidth, .2pt)
shifted (0,RuleFactor*RuleOffset+RuleDepth)
withpen pencircle scaled RuleThickness
withcolor RuleColor ;
setbounds currentpicture to unitsquare xysized(RuleWidth,RuleHeight) ;
\stopuseMPgraphic
\definebar
[underwave]
[undergraphic]
[mp=rules:under:wave]
\definebar
[underwaves]
[underwave]
[continue=yes]
\starttext
\underwaves{\samplefile{knuth}}
\stoptext