Difference between revisions of "Command/ bar"

From Wiki
Jump to navigation Jump to search
(Created page with "Documentation for \<i>bar</i>")
 
Line 10: Line 10:
 
   </cd:sequence>
 
   </cd:sequence>
 
<cd:instances>
 
<cd:instances>
     <cd:constant value="overbar"></cd:constant>
+
     <cd:constant value="overbar">for a continuous rule above every line. Not be confused with <code>\overbar</code>in math mode {{gen|mathovertextextensible}} </cd:constant>
     <cd:constant value="underbar"></cd:constant>
+
     <cd:constant value="underbar">for a continuous rule below every line. Not be confused with <code>\underbar</code>in math mode {{gen|mathundertextextensible}}</cd:constant>
     <cd:constant value="overstrike"></cd:constant>
+
     <cd:constant value="overstrike">for a continuous rule through every line.</cd:constant>
 
     <cd:constant value="understrike"></cd:constant>
 
     <cd:constant value="understrike"></cd:constant>
     <cd:constant value="overbars"></cd:constant>
+
     <cd:constant value="overbars">for a rule above every word.</cd:constant>
     <cd:constant value="underbars"></cd:constant>
+
     <cd:constant value="underbars">for a rule under every word.</cd:constant>
     <cd:constant value="overstrikes"></cd:constant>
+
     <cd:constant value="overstrikes">for a continuous rule through every word.</cd:constant>
 
     <cd:constant value="understrikes"></cd:constant>
 
     <cd:constant value="understrikes"></cd:constant>
 
     <cd:constant value="underrandom"></cd:constant>
 
     <cd:constant value="underrandom"></cd:constant>
Line 38: Line 38:
 
</cd:description>
 
</cd:description>
 
<cd:examples>
 
<cd:examples>
<!--  command example(s)
+
<cd:example title="Default style and math">
<cd:example title="">
+
<context source="yes" text="Gives:">
 +
\underbar{This is an example. $c = \sqrt{a^2 + b^2}$}
 +
 
 +
\underbar{\input ward}
 +
</context>
 
</cd:example>
 
</cd:example>
-->
+
 
 +
<cd:example title="Default style nested">
 +
<context source="yes" text="Gives:">
 +
\setupbar[color=red]
 +
 
 +
\underbar{A \underbar{B \underbar{Cc} b} a}
 +
\blank
 +
</context>
 +
</cd:example>
 +
 
 +
<cd:example title="Overstrike">
 +
 
 +
Draw a rule through every line of the text.
 +
 
 +
<context source='yes'>
 +
\setuppapersize[A5]
 +
\overstrike{This is an example. $c = \sqrt{a^2 + b^2}$}
 +
 
 +
\overstrike{\input ward}
 +
</context>
 +
 
 +
If you are using microtypography with <code>\setupalign[hz,hanging]</code>, then with some fonts the rule may end up off-target, above the characters instead of through them. (The problem was experienced with Linux Libertine and mkiv, and not with Latin Modern.) The workarounds are:
 +
 
 +
* Put the overstriked text in a <code>\inframed[frame=off]{}</code>. Example:
 +
<texcode>
 +
\setupalign[hanging,hz]
 +
bla bla bla \inframed[frame=off]{\overstrike{striked}} bla bla
 +
</texcode>
 +
 
 +
* Turn off microtypography for the paragraph containing the overstrike. Example:
 +
<texcode>
 +
\setupalign[nothanging,nohz]
 +
bla bla bla \overstrike{striked} bla bla
 +
 
 +
\setupalign[hanging,hz]
 +
bla bla bla bla bla
 +
</texcode>
 +
</cd:example>
 +
 
 +
<cd:example title="Various parameters demo">
 +
<context source="yes" text="Gives:">
 +
\setuppapersize[A5]
 +
 
 +
\definebar[BarA][color=red,rulethickness=1.4]
 +
 
 +
\BarA{BarA}
 +
\blank
 +
Hello \startbar[BarA]\input{knuth}\stopbar world!
 +
\blank
 +
 
 +
\definebar[BarB][color=green,rulethickness=2.8,order=background]
 +
 
 +
\BarB{BarB}
 +
\blank
 +
Hello \startbar[BarB]\input{knuth}\stopbar world!
 +
\blank
 +
 
 +
\definebar[BarC][color=blue,rulethickness=2.8,order=background,offset=1.5,continue=yes]
 +
 
 +
\BarC{BarC}
 +
\blank
 +
Hello \startbar[BarC]\input{knuth}\stopbar world!
 +
\blank
 +
</context>
 +
</cd:example>
 +
<cd:example title="Underbar for clozes">
 +
<context source="yes" text="Gives:">
 +
\definebar[ClozeBar][underbar][continue=yes, color=black, offset=-0.5]
 +
 
 +
\starttexdefinition unexpanded Cloze #1
 +
  \startbar[ClozeBar]
 +
  \scratchdimen\widthofstring{#1}\relax
 +
  \zwj\kern.2\scratchdimen #1 \kern.2\scratchdimen\zwj
 +
  \stopbar
 +
\stoptexdefinition
 +
 
 +
\startTEXpage
 +
This is a \Cloze{\color[red]{cloze}} whose underbar is 1.4 times as wide as the text above it. \Cloze{The leading} and trailing spaces are never broken.
 +
\stopTEXpage
 +
</context>
 +
</cd:example>
 +
 
 
</cd:examples>
 
</cd:examples>
 
<cd:notes>
 
<cd:notes>

Revision as of 19:53, 20 August 2020


\bar

Summary

The instances of \bar are used for ...

Instances

\overbarfor a continuous rule above every line. Not be confused with \overbarin math mode mathovertextextensible
\underbarfor a continuous rule below every line. Not be confused with \underbarin math mode mathundertextextensible
\overstrikefor a continuous rule through every line.
\understrike
\overbarsfor a rule above every word.
\underbarsfor a rule under every word.
\overstrikesfor a continuous rule through every word.
\understrikes
\underrandom
\underrandoms
\underdash
\underdashes
\underdot
\underdots
\nobar
\hiddenbar

Settings instance

\BAR{...}
{...}content

Description

Examples

Default style and math

\underbar{This is an example. $c = \sqrt{a^2 + b^2}$}

\underbar{\input ward}

Gives:

internal error: convert failed

Default style nested

\setupbar[color=red]

\underbar{A \underbar{B \underbar{Cc} b} a}
\blank

Gives:

Overstrike


Draw a rule through every line of the text.

\setuppapersize[A5]
\overstrike{This is an example. $c = \sqrt{a^2 + b^2}$}

\overstrike{\input ward}
internal error: convert failed

If you are using microtypography with \setupalign[hz,hanging], then with some fonts the rule may end up off-target, above the characters instead of through them. (The problem was experienced with Linux Libertine and mkiv, and not with Latin Modern.) The workarounds are:

  • Put the overstriked text in a \inframed[frame=off]{}. Example:
\setupalign[hanging,hz]
bla bla bla \inframed[frame=off]{\overstrike{striked}} bla bla
  • Turn off microtypography for the paragraph containing the overstrike. Example:
\setupalign[nothanging,nohz]
bla bla bla \overstrike{striked} bla bla

\setupalign[hanging,hz]
bla bla bla bla bla

Various parameters demo

\setuppapersize[A5]

\definebar[BarA][color=red,rulethickness=1.4]

\BarA{BarA}
\blank
Hello \startbar[BarA]\input{knuth}\stopbar world!
\blank

\definebar[BarB][color=green,rulethickness=2.8,order=background]

\BarB{BarB}
\blank
Hello \startbar[BarB]\input{knuth}\stopbar world!
\blank

\definebar[BarC][color=blue,rulethickness=2.8,order=background,offset=1.5,continue=yes]

\BarC{BarC}
\blank
Hello \startbar[BarC]\input{knuth}\stopbar world!
\blank

Gives:

Underbar for clozes

\definebar[ClozeBar][underbar][continue=yes, color=black, offset=-0.5]

\starttexdefinition unexpanded Cloze #1
   \startbar[ClozeBar]
   \scratchdimen\widthofstring{#1}\relax
   \zwj\kern.2\scratchdimen #1 \kern.2\scratchdimen\zwj
   \stopbar
\stoptexdefinition

\startTEXpage
This is a \Cloze{\color[red]{cloze}} whose underbar is 1.4 times as wide as the text above it. \Cloze{The leading} and trailing spaces are never broken.
\stopTEXpage

Gives:

Notes

See also

Help from ConTeXt-Mailinglist/Forum

All issues with: