Changes

Jump to navigation Jump to search
887 bytes added ,  19:03, 6 December 2023
more intro
{{todo|Add more examples of usage of textbackgrounds.}}
== Basics == Pages, paragraphs, words can have a background color or frame[[Overlays|overlay]]. ConTeXt creates these using [[MetaPost]]. But a usual frame is only one object, its contents can’t flow over to the next page. You can use {{cmd|definetextbackground}} to define a named text background. The environment is based on {{cmd|framed}} and understands its parameters, but can contain several paragraphs and page breaks. After `\definetextbackground[Name]` you can use `\startName ... \stopName` (if there’s no name conflict) or `\starttextbackground[Name] ... \stoptextbackground`. Usually you won’t need {{cmd|setuptextbackground}}. The `location` parameter changes the behaviour between `text` (highlighting running text) and `paragraph` (boxed paragraphs).
(See, eventually, the [[manual:details.pdf| details]] manual or the {{src|anch-bck.mkvi|source}} for further explanations.)
 
 
'''Beware''': The examples using {{cmd|startnarrower}} may be misleading – of course you can use {{cmd|startbackground}} without the `narrower` environment; it behaves differently without `\starttext ... \stoptext`.
== Example: multi-page backgrounded text ==
frame=off,]
\input starttext\samplefile{knuth}
\startsecondary
\input samplefile{knuth}
\stopsecondary
\input samplefile{knuth}\stoptext
</context>
frame=off,]
\input starttext\samplefile{knuth}
\startsecondary
\input samplefile{knuth}
\stopsecondary
\input samplefile{knuth}\stoptext
</context>
Underlining is generally frowned upon by experienced TeXnicians. Occasionally,
however, it is necessary and <{{cmd>|ul</cmd> }} or <{{cmd>|underbar</cmd> }} doesn’t do what you want. In thosecases using <{{cmd>|definetextbackground</cmd> }} for the underlining may also be tried.
<context source="yes">
\definetextbackground[underline]
[location=text,alternative=1,background=,frame=off]
 
\definestartstop[underline]
[before={\starttextbackground[underline]},
after=\stoptextbackground]
\startTEXpage
An example with \startunderline underlined\stopunderline\ text.
\stopTEXpage
</context>
setbounds currentpicture to p ;
\stopuseMPgraphic
 
\definetextbackground[underline]
[location=text,alternative=1,background=,frame=off]
 
\definestartstop[underline]
[before={\starttextbackground[underline]},
after=\stoptextbackground]
 
\startTEXpage
An example with \startunderline underlined\stopunderline\ text.
\stopTEXpage
</context>
\startdashed
\input samplefile{ward}
\stopdashed
</context>
== What if textbackground doesn’t work? (MkII) == The textbackground commands require [[write18Category:Basics]] to be enabled; see that page for more information.

Navigation menu