Difference between revisions of "Command/commalistsentence"
< Command
Jump to navigation
Jump to search
(Created the page with initial edit.) |
m (Added settings for setuplabeltext) |
||
Line 1: | Line 1: | ||
<cd:commandgroup name="commalistsentence" xmlns:cd="http://wiki.contextgarden.net/commanddoc/20200807"> | <cd:commandgroup name="commalistsentence" xmlns:cd="http://wiki.contextgarden.net/commanddoc/20200807"> | ||
<cd:shortdesc><!-- a short command summary goes here --> | <cd:shortdesc><!-- a short command summary goes here --> | ||
− | The command <tt>\commalistsentence</tt> is used to present a comma separated list of values (like an author list, for example) in a single line, with the option of changing the separator of the items and have a distinct separator for the last item of the list. | + | The command <tt>\commalistsentence</tt> is used to present a comma separated list of values (like an author list, for example) in a single line, with the option of changing the separator of the items and have a distinct separator for the last item of the list. |
Line 19: | Line 19: | ||
</cd:command> | </cd:command> | ||
</cd:variants> | </cd:variants> | ||
− | <cd:description>This is | + | <cd:description>This is an useful command for creating lists where you want to output the last item in a different way than the rest, for example, on a list of authors, or publishers. |
− | If you want you can setup labels for the default behavior, using <tt>\setuplabeltext</tt> | + | <!-- |
+ | If you want you can setup labels for the default behavior, using <tt>\setuplabeltext</tt>, and the properties <tt>and-1</tt> and <tt>and-2</tt>, like so: | ||
+ | |||
+ | <context source="yes"> | ||
+ | \setuplabeltext [de] [and-1={{, }}, and-2={{ und }}] % 1, 2 und 3 | ||
+ | \setuplabeltext [es] [and-1={{, }}, and-2={{ y }}] % 1, 2 y 3 | ||
+ | </context> | ||
+ | --></cd:description> | ||
<cd:examples><cd:example title="Some simple lists"><context source="yes" text="Result:"> | <cd:examples><cd:example title="Some simple lists"><context source="yes" text="Result:"> | ||
\commalistsentence[aap,noot,mies] | \commalistsentence[aap,noot,mies] |
Revision as of 16:28, 3 December 2021
Contents
\commalistsentence
Summary
The command \commalistsentence is used to present a comma separated list of values (like an author list, for example) in a single line, with the option of changing the separator of the items and have a distinct separator for the last item of the list.
Settings
\commalistsentence[...,...][...,...] | |
[...,...] | text |
[...,...] | text |
Option | Explanation |
---|---|
A comma separated list of items. Use {} to group items that contain commas, spaces or other special characters. | |
text | a,b,c,d,e,{f, g, h},i,j |
An array with two (2) items, describing the separator for each item, and the separator between the last element and the one preceding it. This item is optional. | |
text | [{ \& },{ and }] % result: a & b & c & d & e & f, g, h & i and j |
Description
This is an useful command for creating lists where you want to output the last item in a different way than the rest, for example, on a list of authors, or publishers.
Examples
Some simple lists
\commalistsentence[aap,noot,mies] \commalistsentence[aap,noot] \commalistsentence[aap] \commalistsentence[a,b,c] \commalistsentence[a,b,c][{ \& },{ and }] \commalistsentence[a,b,c][+,-]
Result:
A list of authors
\def\Authors{% {John Smith, Ph.~D.}, {Michel Witggenstein, M.~Sc.}, {Zoraya Montoya-Velásquez, M.~Sc.}, {Satoshi Ota, Ph.~D.}, {Oba Odumo, M.~Sc.}, {Ivan Ilich, Ph.~D}% } \starttext \commalistsentence[\Authors][{;\space},{\space\letterampersand\space}]: authors. \stoptext
Result: