Difference between revisions of "Command/ bar"

From Wiki
Jump to navigation Jump to search
(explain more instances)
m (small fixes)
 
Line 29: Line 29:
 
   </cd:command>
 
   </cd:command>
 
</cd:variants>
 
</cd:variants>
<cd:description>In MkIV only those of the same kind are nestable (stacking), in LMTX also mixed.</cd:description>
+
<cd:description></cd:description>
<cd:examples><cd:example title="Default style and math"><context source="yes" text="Gives:">
+
<cd:examples><cd:example title="Default style and math"><context source="yes" text="gives:">
 
\underbar{This is an example. $c = \sqrt{a^2 + b^2}$}
 
\underbar{This is an example. $c = \sqrt{a^2 + b^2}$}
  
 
\underbar{\input ward}
 
\underbar{\input ward}
 
</context>
 
</context>
</cd:example><cd:example title="Nested bars"><context source="yes" text="Gives:">
+
</cd:example><cd:example title="Nested bars"><context source="yes" text="gives:">
 
\setupbar[color=red]
 
\setupbar[color=red]
  
Line 45: Line 45:
 
\blank
 
\blank
 
</context>
 
</context>
</cd:example><cd:example title="Overstrike">Draw a rule through every line of the text.
+
 
 +
In MkIV only bars of the same kind are nestable (stacking), in LMTX also mixed.</cd:example><cd:example title="Overstrike">Draw a rule through every line of the text.
  
 
<context source="yes">
 
<context source="yes">
Line 70: Line 71:
 
bla bla bla bla bla
 
bla bla bla bla bla
 
</texcode>
 
</texcode>
</cd:example><cd:example title="Various parameters demo"><context source="yes" text="Gives:">
+
</cd:example><cd:example title="Various parameters demo"><context source="yes" text="gives:">
 
\setuppapersize[A5]
 
\setuppapersize[A5]
  
Line 94: Line 95:
 
\blank
 
\blank
 
</context>
 
</context>
</cd:example><cd:example title="Underbar for clozes"><context source="yes" text="Gives:">
+
</cd:example><cd:example title="Underbar for clozes"><context source="yes" text="gives:">
 
\definebar[ClozeBar][underbar][continue=yes, color=black, offset=-0.5]
 
\definebar[ClozeBar][underbar][continue=yes, color=black, offset=-0.5]
  
Line 115: Line 116:
 
<cd:source file="node-rul.mkiv" originator="system"></cd:source>
 
<cd:source file="node-rul.mkiv" originator="system"></cd:source>
 
<cd:wikipage originator="system" page="Category:Rules"></cd:wikipage>
 
<cd:wikipage originator="system" page="Category:Rules"></cd:wikipage>
<cd:manual pdf="rules-mkiv">Everything about rules (lines)</cd:manual></cd:seealso>
+
<cd:manual pdf="rules-mkiv.pdf">Everything about rules (lines)</cd:manual></cd:seealso>
 
</cd:commandgroup>
 
</cd:commandgroup>

Latest revision as of 19:06, 9 December 2021


\bar

Summary

There are several variants of underlining predefined.

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.
\understrikebackground color behind the line, like with a marker pen
\overbarsfor a rule above every word.
\underbarsfor a rule under every word.
\overstrikesfor a continuous rule through every word.
\understrikesbackground color for every word.
\underrandomirregular (randomized) underlining.
\underrandomsirregular underlining for every word.
\underdashdashed underlining.
\underdashesdashed underlining for every word.
\underdotdotted underlining.
\underdotsdotted underlining for every word.
\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

Nested bars

\setupbar[color=red]

\underbar{A \underbar{B \underbar{Cc} b} a}
\blank
\underbar{A \underdot{B \underdash{Cc} b} a}
\blank
\underrandoms{A \overbar{B \underrandoms{Cc} b} a}
\blank

gives:

In MkIV only bars of the same kind are nestable (stacking), in LMTX also mixed.

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: