Difference between revisions of "Command/commalistsentence"

From Wiki
Jump to navigation Jump to search
m (Added settings for setuplabeltext)
m (Removed some words. This reflects the idea better. There is no need for the list to be in a single line, it can become a paragraph using \crlf as separator.)
 
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), with the option of changing the separator of the items and have a distinct separator for the last item of the list.
  
  
Line 22: Line 22:
  
 
<!--
 
<!--
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:  
+
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">
 
<context source="yes">

Latest revision as of 05:10, 24 January 2023


\commalistsentence

Summary

The command \commalistsentence is used to present a comma separated list of values (like an author list, for example), 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

OptionExplanation
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:

Notes

See also

Help from ConTeXt-Mailinglist/Forum

All issues with: