Difference between revisions of "Command/defineenumeration"
Yatskovsky (talk | contribs) m (→Description) |
|||
(21 intermediate revisions by 7 users not shown) | |||
Line 3: | Line 3: | ||
|attributes= | |attributes= | ||
}} | }} | ||
+ | |||
+ | == [[Help:Reference|Syntax]] (autogenerated) == | ||
+ | <syntax>defineenumeration</syntax> | ||
== [[Help:Reference|Syntax]] == | == [[Help:Reference|Syntax]] == | ||
Line 19: | Line 22: | ||
<tr valign="top" class="third"> | <tr valign="top" class="third"> | ||
<td class="cmd">[...,...=...,...]</td> | <td class="cmd">[...,...=...,...]</td> | ||
− | <td>see [[ | + | <td>see [[Command/setupenumerations|\setupenumerations]] </td> |
</tr> | </tr> | ||
</table> | </table> | ||
Line 25: | Line 28: | ||
== Description == | == Description == | ||
− | With <code>\defineenumeration</code> you can | + | With <code>\defineenumeration</code> you can define the commands for a numbered text element, like remarks or questions. For example, if you want numbered remarks in your document you can define the environment as follows: |
− | |||
− | For example, if you want | ||
− | |||
<texcode> | <texcode> | ||
\defineenumeration | \defineenumeration | ||
[remark] | [remark] | ||
− | [location=top, | + | [location=top, % use alternative=top in MKIV |
− | text=Remark, | + | text=Remark, % Display header as "Remark 1" |
− | inbetween=\blank, | + | headstyle=bold, % Bold remark headers |
− | after=\blank] | + | inbetween={\blank[nowhite]}, % No blank line between remark header and remark |
+ | after=\blank] % Blank line after the remark. | ||
</texcode> | </texcode> | ||
− | + | This creates the new commands <code>\remark</code>, <code>\resetremark</code>, <code>\nextremark</code>, and <code>\startremark</code> ... <code>\stopremark</code>, as well as the same commands for <code>subremark</code> and <code>subsubremark</code>. | |
+ | |||
+ | == Examples == | ||
+ | |||
+ | <context source="yes" text="Gives:"> | ||
+ | |||
+ | \setupindenting[yes,small,first] | ||
+ | |||
+ | \defineenumeration | ||
+ | [remark] | ||
+ | [location=top,text=Remark,inbetween={\blank[nowhite]},after=\blank,headstyle=bold,margin=1in] | ||
+ | |||
+ | \starttext | ||
+ | \remark | ||
+ | An enumeration (\tex{remark}, in this case) takes the paragraph that follows | ||
+ | it as its argument. | ||
+ | |||
+ | \remark | ||
+ | This is the first paragraph after \tex{remark}. It is part of the remark. | ||
+ | |||
+ | This is the second paragraph after \tex{remark}. It is not part of the remark. | ||
+ | |||
+ | \startremark | ||
+ | This is the first paragraph inside \tex{startremark}. It is part of the remark. | ||
+ | |||
+ | This is the second paragraph inside \tex{startremark}. It is part of the remark. | ||
+ | \stopremark | ||
+ | |||
+ | \subsubremark Presto! | ||
+ | |||
+ | \stoptext | ||
+ | </context> | ||
+ | |||
+ | The heading can be placed on the same line as the text that follows by using the value 'left' for the location property (or alternative in MKIV). The width of the header is controlled by the 'width' parameter, and the spacing to the text by the 'distance' parameter. The text on the left side of the number is defined by 'left' and the text on the right by the 'right' parameter. Below the chapter number is appended before the enumeration number. The text before the number can be overridden with the 'text' parameter. Before we override the default text 'remark' with no value. | ||
− | < | + | <context source="yes" text="Gives:"> |
− | \ | + | \starttext |
− | \ | + | |
− | </ | + | \chapter[chpt1]{Chapter 1} |
+ | |||
+ | \defineenumeration[remark] | ||
+ | [location=left,left={\in[chpt1]}.,right=:,width=0.3in,distance=0.02in,text=] | ||
+ | |||
+ | \remark | ||
+ | An enumeration (\tex{remark}, in this case) takes the paragraph that follows | ||
+ | it as its argument. | ||
+ | |||
+ | \remark | ||
+ | This is the first paragraph after \tex{remark}. It is part of the remark. | ||
+ | |||
+ | This is the second paragraph after \tex{remark}. It is not part of the remark. | ||
+ | |||
+ | \startremark | ||
+ | This is the first paragraph inside \tex{startremark}. It is part of the remark. | ||
+ | |||
+ | This is the second paragraph inside \tex{startremark}. It is part of the remark. | ||
+ | \stopremark | ||
+ | |||
+ | \stoptext | ||
+ | </context> | ||
+ | |||
+ | Having the chapter number automatically prefixed can also be achieved using the "prefix" key (instead of putting in the text with the "left" key): | ||
− | + | <context source="yes" text="This code produces the following document:"> | |
− | + | \setuphead[chapter][page=no] % to fit example on one page | |
+ | \defineenumeration[problem][way=bychapter, prefix=chapter, text=Problem] | ||
− | + | \starttext | |
− | + | \chapter{Chapter One} | |
− | |||
− | + | \startproblem | |
− | \ | + | Easy problem. |
− | + | \stopproblem | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | \startproblem | |
− | + | Hard problem. | |
− | + | \stopproblem | |
− | |||
− | |||
− | |||
− | \ | ||
− | |||
− | |||
− | + | \chapter{Chapter Two} | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
+ | \startproblem | ||
+ | Easy problem in chapter 2. | ||
+ | \stopproblem | ||
− | + | \stoptext | |
− | < | + | </context> |
== See also == | == See also == | ||
− | + | * {{cmd|defineenumeration}} for creating new kinds of numbered objects. | |
+ | * {{cmd|setupenumerations}} for setting up looks and behaviour. | ||
+ | * {{cmd|enumeration}} for single-paragraph numbered objects. | ||
+ | * {{cmd|startenumeration}} for multiple-paragraph numbered objects. | ||
+ | * {{cmd|defineseparatorset}} for formatting sets. | ||
+ | |||
+ | == Help from ConTeXt-Mailinglist/Forum == | ||
+ | All issues with: | ||
+ | {{Forum|{{SUBPAGENAME}}}} | ||
− | [[Category: | + | [[Category:Command/Numbered objects|defineenumeration]] |
Revision as of 13:45, 18 November 2019
\defineenumeration
Syntax (autogenerated)
\defineenumeration[...][...][...=...,...] | |
[...] | name |
[...] | name |
...=...,... | inherits from \setupenumeration |
Syntax
\defineenumeration[...,...,...][...][...,...=...,...] | |
[...,...,...] | name |
[...] | name |
[...,...=...,...] | see \setupenumerations |
Description
With \defineenumeration
you can define the commands for a numbered text element, like remarks or questions. For example, if you want numbered remarks in your document you can define the environment as follows:
\defineenumeration [remark] [location=top, % use alternative=top in MKIV text=Remark, % Display header as "Remark 1" headstyle=bold, % Bold remark headers inbetween={\blank[nowhite]}, % No blank line between remark header and remark after=\blank] % Blank line after the remark.
This creates the new commands \remark
, \resetremark
, \nextremark
, and \startremark
... \stopremark
, as well as the same commands for subremark
and subsubremark
.
Examples
\setupindenting[yes,small,first] \defineenumeration [remark] [location=top,text=Remark,inbetween={\blank[nowhite]},after=\blank,headstyle=bold,margin=1in] \starttext \remark An enumeration (\tex{remark}, in this case) takes the paragraph that follows it as its argument. \remark This is the first paragraph after \tex{remark}. It is part of the remark. This is the second paragraph after \tex{remark}. It is not part of the remark. \startremark This is the first paragraph inside \tex{startremark}. It is part of the remark. This is the second paragraph inside \tex{startremark}. It is part of the remark. \stopremark \subsubremark Presto! \stoptext
Gives:
The heading can be placed on the same line as the text that follows by using the value 'left' for the location property (or alternative in MKIV). The width of the header is controlled by the 'width' parameter, and the spacing to the text by the 'distance' parameter. The text on the left side of the number is defined by 'left' and the text on the right by the 'right' parameter. Below the chapter number is appended before the enumeration number. The text before the number can be overridden with the 'text' parameter. Before we override the default text 'remark' with no value.
\starttext \chapter[chpt1]{Chapter 1} \defineenumeration[remark] [location=left,left={\in[chpt1]}.,right=:,width=0.3in,distance=0.02in,text=] \remark An enumeration (\tex{remark}, in this case) takes the paragraph that follows it as its argument. \remark This is the first paragraph after \tex{remark}. It is part of the remark. This is the second paragraph after \tex{remark}. It is not part of the remark. \startremark This is the first paragraph inside \tex{startremark}. It is part of the remark. This is the second paragraph inside \tex{startremark}. It is part of the remark. \stopremark \stoptext
Gives:
Having the chapter number automatically prefixed can also be achieved using the "prefix" key (instead of putting in the text with the "left" key):
\setuphead[chapter][page=no] % to fit example on one page \defineenumeration[problem][way=bychapter, prefix=chapter, text=Problem] \starttext \chapter{Chapter One} \startproblem Easy problem. \stopproblem \startproblem Hard problem. \stopproblem \chapter{Chapter Two} \startproblem Easy problem in chapter 2. \stopproblem \stoptext
This code produces the following document:
See also
- \defineenumeration for creating new kinds of numbered objects.
- \setupenumerations for setting up looks and behaviour.
- \enumeration for single-paragraph numbered objects.
- \startenumeration for multiple-paragraph numbered objects.
- \defineseparatorset for formatting sets.
Help from ConTeXt-Mailinglist/Forum
All issues with: