Jump to content

Help:Advanced table formatting

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Wikid77 (talk | contribs) at 18:05, 21 April 2009 (created, as rapid draft, to begin describing many techniques). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

This essay, Wikipedia:Advanced table formatting describes some techniques to improve the display or editing of wikitables in Wikipedia. Most of the tips involve use of standard text-editors. While some special software packages exist, to allow customized editing, they are typically not available when travelling to other computers for wiki-editing.

A quick multi-column table with spacing

The quickest way to create multiple columns of text is as follows:

AA BB CC
DD EE FF

However, readers often prefer a vertical listing of data, down each column:

AA CC EE
BB DD FF

Note that the default background color is lighter, so a shade of light-bluegreen can be specified on each row, using hex-color code "#fafeff" (or "#FAFEFF"), although the color might not matter in large lists:

AA CC EE
BB DD FF

For long lists of data, the quick way is to use "*" bullets on separate lines, with vertical-bar "|"
between groups, and separate the data-columns with spacer-colums:

  • AA
  • BB
  • CC
 
  • DD
  • EE
  • FF

Even though the coding might seem a little awkward, the results are easily controlled for spacing and alignment. The width of the table will, by default, remain the same for wider or narrowed windows, retaining the alignment with the left-side text (or section titles) outside the table.

Compressing to one-line row format

Each row can be compressed, as a single line, by joining columns with double-bars "||" between them and ending each row with "<tr>".

Example row 1: fmtspec|AA||fmtspec|CC||fmtspec|EE<tr>
Example row 2: fmtspec|BB||fmtspec|DD||fmtspec|FF<tr>

(The fmtspec can be bgcolor=beige or style="font-size:91%" etc.)

This is done sometimes because it can be easier to re-arrange or preview rows that are coded as separate lines of text. Multiple columns are joined by double-bars "||" between them, while each single-bar "|" along a line allows a format-specifier before each data-item which ends at a double-bar. However, the wikitable code for a new row ("|-") must be omitted by adding "<tr>" at the end of the prior row above it.

Moving or exchanging columns

Sometimes columns of data need to be listed in a different order, such as different contents in the 2nd column. Yet, because a wikitable is coded in markup language, the columns cannot simply be dragged across the screen as with a column-oriented editor. Instead, the harsh reality is that the tedious hand-editing of each item is often required as the fastest solution, in the long run.

However, some text editors do allow a repetition-loop to be defined to locate and shift every 7th line or such, as a repeated pattern that could re-arrange the columns in a large table. In another method sometimes used, every data-item is first prefixed with an alphabetic code, hand-coded for the eventual sequence, then those lines are sorted, and afterward all the leading-text prefixes are removed. Sorting can be done in separate files, such as using a DOS-prompt command: SORT myfile.DAT > myfile2.DAT, or else use a text-editor such as Notetab, which has a modify-lines-sort option. Again, bear in mind, the tedious hand-editing of each item is often faster, than the potential of automated edits gone awry.


[ This essay is a draft to be expanded later. ]