Difference between revisions of "Verse"

From Wiki
Jump to navigation Jump to search
m
(Filled in some details and put more examples in.)
 
Line 1: Line 1:
 
= Verse =
 
= Verse =
 +
 +
The usual way to set verse in ConTeXt is to enclose it in {{cmd|startlines}} {{cmd|stoplines}}, which ensures that each new line in the code produces a line break in the compiled output. Additionally, {{cmd|startlines}} has some arguments that can be used to configure how the lines of text look, such as their indentation patterns. As usual in ConTeXt, these arguments can be separated and applied throughout the document with {{cmd|setuplines}} (and optionally {{cmd|definelines}}).
  
 
== A simple example ==
 
== A simple example ==
 
+
For example, to set an excerpt from ''The Monks and the Giants'' by John Hookham Frere:
<texcode>
+
<context source="yes" text="produces">
 
\startlines
 
\startlines
 
But chiefly, when the shadowy moon had shed
 
But chiefly, when the shadowy moon had shed
Line 14: Line 16:
 
Nor David Hartley's doctrine of vibrations.
 
Nor David Hartley's doctrine of vibrations.
 
\stoplines
 
\stoplines
</texcode>
+
</context>
 +
 
 +
== Indenting lines ==
 +
The {{cmd|startlines}} command has several useful options for configuring the overall look of the text that it applies to. To specify the indentation pattern, you can use the {{code|indenting}} argument, which can take on values that you would use for {{cmd|setupindenting}}. For example:
  
<context>
+
<context source="yes" text="produces">
\startlines
+
\startlines[indenting={yes, small, even}]
 
But chiefly, when the shadowy moon had shed
 
But chiefly, when the shadowy moon had shed
 
O'er woods and waters her mysterious hue,
 
O'er woods and waters her mysterious hue,
Line 29: Line 34:
 
</context>
 
</context>
  
== Indenting lines ==
+
The {{code|yes}} turns the indenting on, the {{code|small}} makes it a small amount, and the {{code|even}} makes it only for even-numbered lines.
 
 
You could give the output in the lines environment a special look with indenting of odd or even lines. You could do this with the <code>indenting</code> key for <code>\setuplines</code>, the arguments are the same as you could use for <code>\setupindenting</code>.
 
  
<texcode>
+
However, if you are planning to do this several times throughout your document, it is preferable to configure those options once globally with {{cmd|setuplines}}. For example:
\setuplines[indenting={yes,medium,odd}]
 
</texcode>
 
  
<context>
+
<context source="yes" text="produces">
\setuplines[indenting={yes,medium,odd}]
+
\setuplines[indenting={yes, small, even}]
  
 
\startlines
 
\startlines
Line 49: Line 50:
 
Subjection not from Locke's associations,
 
Subjection not from Locke's associations,
 
Nor David Hartley's doctrine of vibrations.
 
Nor David Hartley's doctrine of vibrations.
 +
\stoplines
 +
 +
And then we can also typeset a nursery rhyme with the same formatting:
 +
\startlines
 +
Hey diddle diddle, the cat played the fiddle,
 +
The cow jumped over the moon.
 +
The little dog laughed to see such craft,
 +
And the dish ran away with the spoon.
 
\stoplines
 
\stoplines
 
</context>
 
</context>
  
<texcode>
+
That way, if you later decide to change the look of the verses in the document, you can do it globally with a single change.
\setuplines[indenting={yes,medium,even}]
+
 
</texcode>
+
If you have different indentation patterns that you would like to use for verse in your documents, it would be good to give each one a defined name to refer to with {{cmd|definelines}}. Then you can still make global adjustments to a single look with a single change, without affecting all the other looks that you have defined. For example:
  
<context>
+
<context source="yes" text="produces">
\setuplines[indenting={yes,medium,even}]
+
\definelines[ottavaRima][][indenting={yes, small, even}]
 +
\definelines[nurseryRhyme][][indenting={yes, big, even}]
  
\startlines
+
\startottavaRima
 
But chiefly, when the shadowy moon had shed
 
But chiefly, when the shadowy moon had shed
 
O'er woods and waters her mysterious hue,
 
O'er woods and waters her mysterious hue,
Line 68: Line 78:
 
Subjection not from Locke's associations,
 
Subjection not from Locke's associations,
 
Nor David Hartley's doctrine of vibrations.
 
Nor David Hartley's doctrine of vibrations.
\stoplines
+
\stopottavaRima
 +
 
 +
And now we can typeset a nursery rhyme with its own formatting:
 +
 
 +
\startnurseryRhyme
 +
Hey diddle diddle, the cat played the fiddle,
 +
The cow jumped over the moon.
 +
The little dog laughed to see such craft,
 +
And the dish ran away with the spoon.
 +
\stopnurseryRhyme
 
</context>
 
</context>
  
== Preventing pagebreaks ==
+
Note that {{cmd|definelines}} has ''three'' sets of arguments: the first is the name that you are defining, the second is blank [ ], and the third is the one to use to specify the indenting. From the documentation, it is unclear what the second argument does, but omitting it entirely sometimes (but not always) causes problems.
 +
{{howto}}
  
Text in the lines environment is normally split at the end of the page, to prevent this you could enclose the block with a framedtext.
 
  
 +
== Preventing pagebreaks ==
 +
The commands {{cmd|startlines}}, {{cmd|setuplines}}, and {{cmd|startuplines}} have many other options to configure the look of verse.
 +
For example, you can specify commands to be executed before and after the verse with the {{code|before}} and {{code|after}} arguments. One way that this can be used is to prevent pagebreaks by enclosing the verse in {{cmd|startframedtext}} {{cmd|stopframedtext}}, as in:
 
<texcode>
 
<texcode>
\setuplines
+
\startlines[before={\startframedtext[frame=off]}, after=\stopframedtext]
  [before={\startframedtext[frame=off]},
+
But chiefly, when the shadowy moon had shed
  after=\stopframedtext]
+
O'er woods and waters her mysterious hue,
 +
Their passive hearts and vacant fancies fed
 +
With thoughts and aspirations strange and new,
 +
Till their brute souls with inward working bred
 +
Dark hints that in the depths of instinct grew
 +
Subjection not from Locke's associations,
 +
Nor David Hartley's doctrine of vibrations.
 +
\stoplines
 
</texcode>
 
</texcode>
 +
 +
See the documentation for {{cmd|setuplines}} for further details of what can be customized.
 +
  
 
[[Category:Basics]]
 
[[Category:Basics]]

Latest revision as of 18:14, 20 October 2020

Verse

The usual way to set verse in ConTeXt is to enclose it in \startlines \stoplines, which ensures that each new line in the code produces a line break in the compiled output. Additionally, \startlines has some arguments that can be used to configure how the lines of text look, such as their indentation patterns. As usual in ConTeXt, these arguments can be separated and applied throughout the document with \setuplines (and optionally \definelines).

A simple example

For example, to set an excerpt from The Monks and the Giants by John Hookham Frere:

\startlines
But chiefly, when the shadowy moon had shed
O'er woods and waters her mysterious hue,
Their passive hearts and vacant fancies fed
With thoughts and aspirations strange and new,
Till their brute souls with inward working bred
Dark hints that in the depths of instinct grew
Subjection not from Locke's associations,
Nor David Hartley's doctrine of vibrations.
\stoplines

produces

Indenting lines

The \startlines command has several useful options for configuring the overall look of the text that it applies to. To specify the indentation pattern, you can use the indenting argument, which can take on values that you would use for \setupindenting. For example:

\startlines[indenting={yes, small, even}]
But chiefly, when the shadowy moon had shed
O'er woods and waters her mysterious hue,
Their passive hearts and vacant fancies fed
With thoughts and aspirations strange and new,
Till their brute souls with inward working bred
Dark hints that in the depths of instinct grew
Subjection not from Locke's associations,
Nor David Hartley's doctrine of vibrations.
\stoplines

produces

The yes turns the indenting on, the small makes it a small amount, and the even makes it only for even-numbered lines.

However, if you are planning to do this several times throughout your document, it is preferable to configure those options once globally with \setuplines. For example:

\setuplines[indenting={yes, small, even}]

\startlines
But chiefly, when the shadowy moon had shed
O'er woods and waters her mysterious hue,
Their passive hearts and vacant fancies fed
With thoughts and aspirations strange and new,
Till their brute souls with inward working bred
Dark hints that in the depths of instinct grew
Subjection not from Locke's associations,
Nor David Hartley's doctrine of vibrations.
\stoplines

And then we can also typeset a nursery rhyme with the same formatting:
\startlines
Hey diddle diddle, the cat played the fiddle,
The cow jumped over the moon.
The little dog laughed to see such craft,
And the dish ran away with the spoon.
\stoplines

produces

That way, if you later decide to change the look of the verses in the document, you can do it globally with a single change.

If you have different indentation patterns that you would like to use for verse in your documents, it would be good to give each one a defined name to refer to with \definelines. Then you can still make global adjustments to a single look with a single change, without affecting all the other looks that you have defined. For example:

\definelines[ottavaRima][][indenting={yes, small, even}]
\definelines[nurseryRhyme][][indenting={yes, big, even}]

\startottavaRima
But chiefly, when the shadowy moon had shed
O'er woods and waters her mysterious hue,
Their passive hearts and vacant fancies fed
With thoughts and aspirations strange and new,
Till their brute souls with inward working bred
Dark hints that in the depths of instinct grew
Subjection not from Locke's associations,
Nor David Hartley's doctrine of vibrations.
\stopottavaRima

And now we can typeset a nursery rhyme with its own formatting:

\startnurseryRhyme
Hey diddle diddle, the cat played the fiddle,
The cow jumped over the moon.
The little dog laughed to see such craft,
And the dish ran away with the spoon.
\stopnurseryRhyme

produces

Note that \definelines has three sets of arguments: the first is the name that you are defining, the second is blank [ ], and the third is the one to use to specify the indenting. From the documentation, it is unclear what the second argument does, but omitting it entirely sometimes (but not always) causes problems.


The author of this entry is looking for a solution for the described problem. (See: How to?)


Preventing pagebreaks

The commands \startlines, \setuplines, and \startuplines have many other options to configure the look of verse. For example, you can specify commands to be executed before and after the verse with the before and after arguments. One way that this can be used is to prevent pagebreaks by enclosing the verse in \startframedtext \stopframedtext, as in:

\startlines[before={\startframedtext[frame=off]}, after=\stopframedtext]
But chiefly, when the shadowy moon had shed
O'er woods and waters her mysterious hue,
Their passive hearts and vacant fancies fed
With thoughts and aspirations strange and new,
Till their brute souls with inward working bred
Dark hints that in the depths of instinct grew
Subjection not from Locke's associations,
Nor David Hartley's doctrine of vibrations.
\stoplines

See the documentation for \setuplines for further details of what can be customized.