Difference between revisions of "Template:Autocol long"
(re-aligned the autonumbers in range 100-149) |
m (1 revision) |
(No difference)
|
Latest revision as of 07:25, 22 August 2014
Template:Autocol_long - autowrap table columns: {{autocol long | n=3 |ncols=2 |colgap=7 | row1 | row2 | row3 | }} |
{{{1}}} {{{2}}} {{{3}}} {{{4}}} {{{5}}} {{{6}}} {{{7}}} {{{8}}} {{{9}}} {{{10}}} {{{11}}} {{{12}}} {{{13}}} {{{14}}} {{{15}}} {{{16}}} {{{17}}} {{{18}}} {{{19}}} {{{20}}}
{{{21}}} {{{22}}} {{{23}}} {{{24}}} {{{25}}} {{{26}}} {{{27}}} {{{28}}} {{{29}}} {{{30}}} {{{31}}} {{{32}}} {{{33}}} {{{34}}} {{{35}}} {{{36}}} {{{37}}} {{{38}}} {{{39}}} {{{40}}}
{{{41}}} {{{42}}} {{{43}}} {{{44}}} {{{45}}} {{{46}}} {{{47}}} {{{48}}} {{{49}}} {{{50}}} {{{51}}} {{{52}}} {{{53}}} {{{54}}} {{{55}}} {{{56}}} {{{57}}} {{{58}}} {{{59}}} {{{60}}}
The table formatter Template:Autocol can auto-columnize n items into ncols=2 or more columns, with or without item numbers, on any type of web browser. The number of items, such as n=46, must be specified, but if n is set larger, then the exact count is shown by later numbered items extending beyond the actual items. Option "wrap=y" will wrap entries to separate lines when not dot-bullets. Option "num=y" will auto-number the entries, with a count number across all columns.
|
|
In practice the template is very easy to use, with the exact count of items shown by setting higher, such as n=64, and it allows setting the inter-column spacing as colgap=9 spaces, or colgap=5 (default), or such.
Contents
Parameters
Template {Autocol long} allows several parameters (default: n=60) as follows:
- ncols: the number of columns, any number (default: ncols=3)
- n : the total number of items, can be 1 larger (default: 60)
- wrap=y: option to wrap the entries as 1 per line, else fill (default: off)
- num=y: option to number the items, 1 to n (default: off)
- colgap: the number of spaces between columns (default: 5)
When num=y, then also set wrap=y to put each entry onto a separate line.
Setting count n=64
Setting the exact count of "n" items might seem a bother, so empty items can be placed in a list to allow easier expansion. The final bar "|" always allows adding one more item (anywhere) for the same count n. To prepare for adding future items, then "empty" items can be placed at the end of the template, such as "*enditem| | | |}}" to allow 4 more items, for a given "n=" count. As items are added, anywhere in the list, then the empty items at the end are ignored, falling beyond count n. For those reasons, setting the count of items, in practice, is not actually a major problem, mostly an imagined fear. When many new items are expected, then pad the end of the list with more bars "| | | |}}" and set n a few items higher. When in doubt, a note could be inserted, at the end of the list, to "<!--Be sure to set n higher when more in list-->". In any event, if the count is too low, then the template will warn when non-empty items exceed the list (such as: "{Autocol long} - Found item "xx" beyond count n=32").
Column alignment tactics
To better balance the columns, then items of similar width should be placed in the same column, such as long phrases in column 1 or 2; otherwise, the long phrases would wrap on narrow windows, with a conflict for space in adjacent columns. Individual long phrases can be force-wrapped by placing a "<br>" in the middle, to narrow that column, such as "[[Very long wordy phrase|Very long<br>wordy phrase]]".
With option "wrap=y", then {Autocol} can display several columns of short words. However, for long phrases, then the bullet-style items are preferred, with a lead asterisk and end-bar (such as "* phrase |"). In fact, some editors prefer the bullet-style items for all lists, and might insist on their use in some articles. When not using {Autocol}, then long lists of words can be very tedious, because {Autocol} inserts the "<br>" break at each word and pads the spacing between items. For those reasons, most multi-column lists in articles use bullet-style items.
Examples
Auto-numbering: Option "num=y" can auto-number items in all columns, used with option "wrap=y".
|
Blank items in short columns: In some cases, a column can be "shortened" by placing blank items at the bottom of some columns. That would allow some columns to be longer than the others. The following example shows 10 items arranged in 4 columns, where 12 items would fit.
|
Groups of bullets: When bullets must be separated into groups, then bolded names can be placed at the start of each group of bullets in the same table.
|
Performance considerations
Because {Autocol} is limited to 64 items, it runs very quickly, and can format a list of 64 items within 1/8 second. The larger template, {Autocol_big} runs 2x slower, using 1/4 second. For both, the expansion depth has been kept to a minimum, as only 4 levels of the 41-level MediaWiki wp:expansion depth limit. Spacing for colgap=5, between columns, consists of  's, repeated by function {{padleft:|{{#expr:{{{colgap}}}*6}} | }}, which runs at 1,200 per second, so the colgap size does not affect the speed of formatting the table. For that reason, an article could have 2 full tables of {Autocol} items and use only 1/4 second.
See also
- Help:Table—introduction and examples of other table formatting
- WP:Advanced table formatting—explanation of more complex features
- {{Convert/spell}}—convert numbers but show amount(s) in words
The above documentation is transcluded from Template:Autocol/doc. (edit | history) Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages. Subpages of this template. |