Difference between revisions of "Command/definefirstline"

From Wiki
Jump to navigation Jump to search
(Hans added this yesterday)
 
m (typo)
Line 40: Line 40:
 
Define a style to apply only to the first line of a paragraph.
 
Define a style to apply only to the first line of a paragraph.
 
Once defined, the style can be applied by invoking
 
Once defined, the style can be applied by invoking
{{cmd|setfirstlinestyle}} on a paragraph.
+
{{cmd|setfirstline}} on a paragraph.
 
One of two methods can be requested by setting the keyword
 
One of two methods can be requested by setting the keyword
 
<code>alternative</code>:
 
<code>alternative</code>:

Revision as of 10:26, 23 August 2013

\definefirstline

Syntax

\definefirstline[..][]
\definefirstline[...][...][...=...]
[...] name of firstline style
[...] name of firstline style to inherit from
alternative line word
n integer: number of words to affect
style Style Alternative
color IDENTIFIER: color name

Description

Define a style to apply only to the first line of a paragraph. Once defined, the style can be applied by invoking \setfirstline on a paragraph. One of two methods can be requested by setting the keyword alternative:

  • line applies the style to the entire line,
  • word applies the style only to the first n words of the first line.

NB: The style substitution takes place on node level, hence small capitals require a font which implements them as a feature, not as a separate file (e. g. as of 2013 Latin Modern won’t do).

Example

Typeset the first line once in bold, and then in small caps:

\setupbodyfont [heros] %% important: smallcaps capable font!

\definefirstline [italicfirstline] [
  alternative=line,
  style=italic,
]

\definefirstline [smallcapsfirstline] [
  alternative=line,
  color=darkred,
  style=smallcaps,
]

\starttext

  \setfirstline[italicfirstline]    \input knuth \par
  \setfirstline[smallcapsfirstline] \input knuth \par

\stoptext

To affect only the first three or six words change to the alternative word and set the parameter n to the desired value:

\definefirstline [threegreenwords] [
  alternative=word,
  color=green,
  n=3,
]

\definefirstline [sixbluewords] [
  alternative=word,
  color=blue,
  n=6,
]

\starttext

    \setfirstline[threegreenwords]  \input ward \par
    \setfirstline[sixbluewords]     \input ward \par

\stoptext

See also

Help from ConTeXt-Mailinglist/Forum

All issues with: