Difference between revisions of "Command/writebetweenlist"

From Wiki
Jump to navigation Jump to search
(Created page with "Documentation for \writebetweenlist")
 
m (default TOC settings)
 
Line 20: Line 20:
 
   </cd:command>
 
   </cd:command>
 
</cd:variants>
 
</cd:variants>
<cd:description>Insert something in that is not a list element in the middle of a list. Most often a command such as {{cmd|hrule}}, or a header.
+
<cd:description>Insert something in that is not a list element in the middle of a list. Most often a command such as {{cmd|hrule}}, or a header.
 +
 
 +
The default table of contents is combined list. To write to it one has to choose the level to which it should be inserted: <tt>\writebetweenlist[chapter][location=here]{\hrule}</tt>, <tt>\writebetweenlist[section][location=here]{\hrule}</tt>, etc.
 
</cd:description>
 
</cd:description>
 
<cd:examples><cd:example title=""><context source="yes">
 
<cd:examples><cd:example title=""><context source="yes">
Line 39: Line 41:
 
* sometimes direct flushing is needed, sometimes delayed
 
* sometimes direct flushing is needed, sometimes delayed
  
An option has been added to (1) the flushers and (2) the list placers. (as december 14, 2010).  
+
An option has been added to (1) the flushers and (2) the list placers. (as december 14, 2010).
  
 
Regular list entries are bound to a specific location in order to
 
Regular list entries are bound to a specific location in order to
Line 52: Line 54:
 
pushes commands into the right order, and <code>all</code> orders all
 
pushes commands into the right order, and <code>all</code> orders all
 
entries (which might be too much). In this case no specific
 
entries (which might be too much). In this case no specific
location is needed with the inbetween method.  
+
location is needed with the inbetween method.
  
 
The following example shows this:
 
The following example shows this:
Line 64: Line 66:
 
\starttext
 
\starttext
  
     \subject{normal}
+
     \subject{normal}
 
     (Ordering all entries, whether created with \tex{writetolist} or \tex{writebetweenlist})
 
     (Ordering all entries, whether created with \tex{writetolist} or \tex{writebetweenlist})
 
     \placelist[testlist]
 
     \placelist[testlist]
  
     \subject{command}  
+
     \subject{command}
 
     (Ordering the \tex{writebetweenlist} items, retaining the order of the entries)
 
     (Ordering the \tex{writebetweenlist} items, retaining the order of the entries)
 
     \placelist[testlist][order=command]
 
     \placelist[testlist][order=command]
 
+
 
     \subject{all}    
+
     \subject{all}
 
     (Placing all entries in order of appearance)
 
     (Placing all entries in order of appearance)
 
     \placelist[testlist][order=all]
 
     \placelist[testlist][order=all]
Line 78: Line 80:
 
     % --- and now we put write the entries to the list ---
 
     % --- and now we put write the entries to the list ---
  
     \writetolist    [testlist]              {1}  
+
     \writetolist    [testlist]              {1}
 
         {1/3 -- 1/6 -- (location=here)}
 
         {1/3 -- 1/6 -- (location=here)}
  
 
     \writebetweenlist[testlist]{
 
     \writebetweenlist[testlist]{
         \framed[width=\hsize, frame=off,  
+
         \framed[width=\hsize, frame=off,
 
                 background=color, backgroundcolor=red,
 
                 background=color, backgroundcolor=red,
 
                 align=flushleft]
 
                 align=flushleft]
         {\blackrule[width=2.5em, height=0em]  
+
         {\blackrule[width=2.5em, height=0em]
 
         1/3 -- 2/6 -- (location=...)}}
 
         1/3 -- 2/6 -- (location=...)}}
  
 
     \writebetweenlist[testlist][location=here]{
 
     \writebetweenlist[testlist][location=here]{
         \framed[width=\hsize, frame=off,  
+
         \framed[width=\hsize, frame=off,
 
                 background=color, backgroundcolor=cyan,
 
                 background=color, backgroundcolor=cyan,
 
                 align=flushleft]
 
                 align=flushleft]
         {\blackrule[width=2.5em, height=0em]  
+
         {\blackrule[width=2.5em, height=0em]
 
         2/3 -- 3/6 -- location=here}}
 
         2/3 -- 3/6 -- location=here}}
  
     \writetolist    [testlist]              {2}  
+
     \writetolist    [testlist]              {2}
 
         {2/3 -- 4/6 -- (location=here)}
 
         {2/3 -- 4/6 -- (location=here)}
  
     \writetolist    [testlist][location=none]{W}  
+
     \writetolist    [testlist][location=none]{W}
 
         {3/3 -- 5/6 -- location=none}
 
         {3/3 -- 5/6 -- location=none}
  
 
     \writebetweenlist[testlist]{
 
     \writebetweenlist[testlist]{
         \framed[width=\hsize, frame=off,  
+
         \framed[width=\hsize, frame=off,
 
                 background=color, backgroundcolor=yellow,
 
                 background=color, backgroundcolor=yellow,
 
                 align=flushleft]
 
                 align=flushleft]
         {\blackrule[width=2.5em, height=0em]  
+
         {\blackrule[width=2.5em, height=0em]
 
         3/3 -- 6/6 -- (location=...)}}
 
         3/3 -- 6/6 -- (location=...)}}
  

Latest revision as of 15:40, 19 January 2021


\writebetweenlist

Summary

The command \writebetweenlist is used for putting some non-item in a list.

Settings

\writebetweenlist[...][...=...,...]{...}
[...]list
...=...,...inherits from \setuplist
{...}command

Description

Insert something in that is not a list element in the middle of a list. Most often a command such as \hrule, or a header.

The default table of contents is combined list. To write to it one has to choose the level to which it should be inserted: \writebetweenlist[chapter][location=here]{\hrule}, \writebetweenlist[section][location=here]{\hrule}, etc.

Examples

Example 1

\setuppapersize[A7,landscape]
\definelist[Reprints][criterium=all]

\starttext
\completelist[Reprints]
  \writetolist[Reprints]{1.}{List entry A}
  \writebetweenlist[Reprints][location=here]{\hrule}
  \writetolist[Reprints]{2.}{List entry B}
  %\writetolist[Reprints]{3.}{List entry C}
\stoptext

Example 2

According to http://archive.contextgarden.net/message/20101213.221208.577b0e51.en.html \writebetweenlist has multiple usage and these are conflicting:

  • in order to get the right page info associated it needs to be anchored in the text stream
  • in that case a node can interfere with spacing and can come unexpected
  • sometimes direct flushing is needed, sometimes delayed

An option has been added to (1) the flushers and (2) the list placers. (as december 14, 2010).

Regular list entries are bound to a specific location in order to get the right pagenumber etc. associated. When pushing something inbetween (in mkiv) it ends up directly in the list. This is the default because otherwise users will wonder why spacing might get messed up (due to an unseen but present node). It is possible to force a location by explicitly setting location to here.

Another way to force a certain order is to set the order variable when placing a list. The command option only pushes commands into the right order, and all orders all entries (which might be too much). In this case no specific location is needed with the inbetween method.

The following example shows this:

\definepapersize[scroll][width=12cm, height=20cm]
\setuppapersize[scroll]

\definelist[testlist][criterium=all]

\starttext

    \subject{normal}
    (Ordering all entries, whether created with \tex{writetolist} or \tex{writebetweenlist})
    \placelist[testlist]

    \subject{command}
    (Ordering the \tex{writebetweenlist} items, retaining the order of the entries)
    \placelist[testlist][order=command]

    \subject{all}
    (Placing all entries in order of appearance)
    \placelist[testlist][order=all]

    % --- and now we put write the entries to the list ---

    \writetolist     [testlist]               {1}
        {1/3 -- 1/6 -- (location=here)}

    \writebetweenlist[testlist]{
        \framed[width=\hsize, frame=off,
                background=color, backgroundcolor=red,
                align=flushleft]
        {\blackrule[width=2.5em, height=0em]
         1/3 -- 2/6 -- (location=...)}}

    \writebetweenlist[testlist][location=here]{
        \framed[width=\hsize, frame=off,
                background=color, backgroundcolor=cyan,
                align=flushleft]
        {\blackrule[width=2.5em, height=0em]
         2/3 -- 3/6 -- location=here}}

    \writetolist     [testlist]               {2}
        {2/3 -- 4/6 -- (location=here)}

    \writetolist     [testlist][location=none]{W}
        {3/3 -- 5/6 -- location=none}

    \writebetweenlist[testlist]{
        \framed[width=\hsize, frame=off,
                background=color, backgroundcolor=yellow,
                align=flushleft]
        {\blackrule[width=2.5em, height=0em]
         3/3 -- 6/6 -- (location=...)}}

\stoptext

Notes

See also

Help from ConTeXt-Mailinglist/Forum

All issues with: