No categories assigned

Tables

Revision as of 13:44, 3 April 2018 by Fbaeckmann (talk | contribs) (Komplexere Tabellen)

Here we describe the editing of tables in the wiki code. For fast editing of tables, the WYSIWYG editor is recommended. Nevertheless, in some cases, the classic editing with wiki tags may be necessary.

Functionality

Tables are a very important tool for designing wiki pages. Besides from displaying content in a structured way, tables occasionally are used to design whole pages. The basic structure of the main page or the topic portal page for example are based on a table. However, tables should only be used very carefully to structure entire pages. The source code quickly becomes confusing for outsiders and for the reading devices of the visually impaired, they represent a barrier. Therefore, Wikipedia advises their users quite fundamentally from using tables as a graphical element for entire pages.

MediaWiki has its own syntax for displaying tables. This syntax is similar to common HTML but much simpler.

Nevertheless, the editing of tables remains complex. The use of editors produces HTML code that is a barrier to editing by others.

Simple tables

Input Result Comment
{| 
| Cell 1
| Cell 2
|-
| Cell 3
| Cell 4
|}
Cell 1 Cell 2
Cell 3 Cell 4

This is the syntax for a simple table.

{|
|- 
||Cell 1 ||Cell 2
|- 
||Cell 3 ||Cell 4
|- 
||Cell 5 ||Cell 6
|}
Cell 1 Cell 2
Cell 3 Cell 4
Cell 5 Cell 6

To save space it is possible to write several cells in one line of code. In this case the cells have to be separated by ||. A table with tree rows can be created like this.

Notice:
To begin a new row put a hyphen ("-") after the leading pipe symbol ("|"). Repeat as often as needed.

To create a simple table quickly in BlueSpice Wiki, use the Button "Insert a Table" Btn-WYSIWYG-Tabelle einfügen.png in any editor view.

More complex tables

A Wikipedia article about this can be found here: [1]

Borders

Input Result Comment
{| border="1"
| Cell 1
| Cell 2
|-
| Cell 3
| Cell 4
|}
Cell 1 Cell 2
Cell 3 Cell 4

The border must be set in the first line of the table (directly after the {|). The frame thickness is specified in pixels: border = "x"

Note: The classic table borders may look a little old-fashioned. Therefore there you can use layout templates for your tables.


Title rows

Input Result Comment
{|
|-
! Last Name
! First Name
|-
| Karstadt
| Liesl
|-
| Valentin
| Karl
|}
Last Name First Name
Karstadt Liesl
Valentin Karl

Title rows are specified with ! instead of |.


Combining cells: Rowspanning and Colspanning

Input Result Comment
{|
|-
! A
! B
! C
|-
| Cell 1
| colspan="2" align="center"|Cell 2
|-
| Cell 3
| Cell 4
| Cell 5
|}
A B C
Cell 1 Cell 2
Cell 3 Cell 4 Cell 5

This is a table containing a cell which spans tow columns. The command colspan="2" is entered before the corresponding cell and separated by |. The following command (align="center") is there to center the cell content and is used only to better demonstrate the effect.

{|
|-
! A
! B
|-
| rowspan="2" align="center"|Cell 1
| Cell 2
|-
| Cell 4
|}
A B
Cell 1 Cell 2
Cell 4

A Table containing a cell which spans two rows (rowspan="2").

Note: Empty cells won't get a border automatically. In some browsers you can force a border with a nonbreaking space   inside these cells.

Nested tables

Input Result Comment
{| border="1"
|-
| Cell 1
|
 {| border="1"
 | Cell A
 |-
 | Cell B
 |}
| Cell 3
|}
Cell 1
Cell A
Cell B
Cell 3

A table inside another table. To nest tables simply use an additional opening {| where you want the inner table to be. But make sure there is no pipe symbol at the beginning of that line.

Caption

Input Result Comment
{| 
|+ This is a nice table
|-
| Table
| nice
|-
| Nice
| table
|}
+ This is a nice table
Table nice
Nice table

It is possible to add a centered caption above the table with |+ my caption at the beginning.

Aufzählungszeichen

Eingabe Ergebnis Kommentar dazu
File:HilfeTabelle9.jpg
Aufzählung richtig Aufzählung falsch
  • erster Eintrag
  • zweiter Eintrag
* erster Eintrag
  • zweiter Eintrag

Will man Aufzählungszeichen in einer Tabelle verwenden, so muss der erste Listeneintrag in einer neuen Zeile beginnen. Andernfalls wird beim ersten Eintrag anstatt eines Aufzählungszeichens ein Sternchen angezeigt.

Sortierbare Tabellen

Eingabe Ergebnis Kommentar dazu
File:HilfeTabelle10.jpg
Spalte 1 Spalte 2 Spalte 3
12346 € 234,44 SuSe
98765 € 77,55 IBM

Tabellen können auch nach ihren Werten pro Spalte sortiert werden. Dazu muss class="sortable" im Tabellenkopf angegeben werden.
Klicken Sie einmal auf das kleine Kästchen im Spaltenkopf!

Einschränkungen:
  • Damit Zahlen nach ihren numerischen Werten korrekt sortiert werden, dürfen sie bislang weder ein Tausendertrennzeichen noch Einheiten (außer den Währungszeichen € und $) oder andere Beschriftungen enthalten. Ein Hinweis auf die verwendeten Einheiten sollte daher in der Kopfzeile angegeben werden.
  • Bei komplexen Tabellen (d. h. solchen mit ungleichmäßigen Reihen und Spalten) ist eine Sortierung nicht möglich.

Spaltenbreiten

Eingabe Ergebnis Kommentar dazu
File:HilfeTabelle11.jpg
10 % 20 % 40 %
A B C

Spaltenbreiten können relativ und absolut angegeben werden, wobei absolute Angaben in Pixeln nur beim Einbinden von Grafiken eingesetzt werden sollten. Die Breitenangabe ist nur bei einer Zelle der Spalte notwendig und sinnvoll.

File:HilfeTabelle12.jpg
50 100 200
A B C

Zellenabstände mit cellspacing und cellpadding

Eingabe Ergebnis Kommentar dazu
350px
Alpha Beta Gamma
Delta Epsilon Zeta

Mit cellspacing kann der Abstand zwischen den Zellen festgelegt werden. Je größer der Cellspacing-Wert, desto breiter wird der Steg zwischen den Zellen. Mit cellpadding bestimmt man den Abstand des Zellinhaltes vom Zellrahmen.

350px
Alpha Beta Gamma
Delta Epsilon Zeta

Ausrichtung

Eingabe Ergebnis Kommentar dazu
File:HilfeTabelle15.jpg
  Links Zentriert Rechts
Oben xx xxx xx
Mitte x x x
Unten x x x

Genau wie in HTML kann man den Inhalt von Zellen in der Tabelle unterschiedlich ausrichten. Dabei kann man die Attribute einzelnen Zellen oder auch ganzen Zeilen zuweisen. Das valign gilt jeweils für die ganze Zeile, das align nur für die jeweilige Zelle.

Formatvorlagen

Eingabe Ergebnis Kommentar dazu
File:HilfeTabelle16.jpg
Text linke Spalte Text rechte Spalte

Einige Benutzer haben Vorlagen erstellt, um die Formatierung zu vereinfachen. Anstatt sich an die Tabellenparameter erinnern zu müssen, kann eine Formatvorlage verwendet werden. Diese ist nach dem {| einzufügen. Die Verwendung ermöglicht ein konsistentes Tabellenlayout, eine Erleichterung beim Fehlerhandling sowie einfache Anpassung des Layouts bei allen Tabellen.

Attachments

Discussions