Changes

Jump to navigation Jump to search
1,276 bytes added ,  15:06, 31 August 2021
m
Remove MkII hint, enhance markup
< [[Main Page]] | [[Visuals]] >
 
{{todo|Add more examples of usage of textbackgrounds.}}
Pages, paragraphs, words can have a background: color or screenframe(See, eventually, the ConTeXt creates these using [[manual:details.pdf| detailsMetaPost]] manual for further explanations.) == What if textbackground doesn't work? ==
The textbackground commands require (See, eventually, the [[write18manual:details.pdf| details]] to be enabled; see that page manual or the {{src|anch-bck.mkvi|source}} for more informationfurther explanations.)
== Example: multi-page backgrounded text ==
In the following example, we also reduce the textwidth and bodyfont size.
<context source="yes">
\setupcolorsdefinetextbackground[statesecondary][ location=paragraph, background=color, backgroundcolor=lightgray, leftoffset=.5\bodyfontsize, rightoffset=.5\bodyfontsize, topoffset=.5\bodyfontsize, bottomoffset=.5\bodyfontsize, before={\startnarrower\switchtobodyfont[small]}, after={\stopnarrower}, frame=startoff,\samplefile{knuth} \startsecondary\samplefile{knuth}\stopsecondary
\samplefile{knuth}
</context>
 
== Background Offset ==
 
The options left, right, top, bottomoffset can be replaced by backgroundoffset yielding a different result:
 
<context source="yes">
\definetextbackground[secondary][
location=paragraph, background=color, backgroundcolor=middlegraylightgray, leftoffset=.5\bodyfontsize,rightoffset backgroundoffset=.5\bodyfontsize, topoffset=.5\bodyfontsize,bottomoffset=.5\bodyfontsize, before={\startnarrower\switchtobodyfont[small]}, after={\stopnarrower}, frame=off,]
\starttext \input samplefile{knuth}
\startsecondary
\input samplefile{knuth}
\stopsecondary
\input samplefile{knuth}</context> == Underlining with Text Backgrounds == Underlining is generally frowned upon by experienced TeXnicians. Occasionally,however, it is necessary and {{cmd|ul}} or {{cmd|underbar}} doesn’t do what you want. In thosecases using {{cmd|definetextbackground}} for the underlining may also be tried.
\stoptext</contextsource="yes">\definetextbackground[underline] [location=text,alternative=1,background=,frame=off]
\definestartstop[underline] [before={{todo|The background does not show here using the live\starttextbackground[underline]}, online conTeXt processor. Why?}} after=\stoptextbackground]
== backgroundoffset ==\startTEXpageAn example with \startunderline underlined\stopunderline\ text.\stopTEXpage</context>
The options leftIf desired, right, top, bottomoffset the location of the line can also be replaced by backgroundoffset yielding a different result:adjusted.
<context source="yes">
\setupcolorsstartuseMPgraphic{mpos:par:columnset} % Shift underlining down a touch \iftracepositions show_multi_pars \else draw_multi_pars \fi ; path p ; p := boundingbox currentpicture ; currentpicture := currentpicture shifted (0,-StrutDepth/3) ; setbounds currentpicture to p ;\stopuseMPgraphic \definetextbackground[underline] [statelocation=text,alternative=1,background=,frame=startoff]
\definetextbackgrounddefinestartstop[secondaryunderline] [ location=paragraph, background=color,backgroundcolor=middlegray, backgroundoffset=.5\bodyfontsize, before={\startnarrower\switchtobodyfontstarttextbackground[smallunderline]}, after={\stopnarrower}, frame=offstoptextbackground]
\starttextstartTEXpageAn example with \startunderline underlined\stopunderline\ text.\stopTEXpage</context>
\input knuth
\startsecondary=== Example: dashed underbar === \input knuth\stopsecondary(by WS, 4/2011)
<context source="yes">\input knuthdefinetextbackground [dashed] [location=text, framecolor=black, alternative=1, voffset=-\strutdp, background=, frame=off, dash=1]
\stoptextstartdashed\samplefile{ward}\stopdashed
</context>
 
[[Category:Basics]]

Navigation menu