Ayuda:Listas
![]() |
Nota: Al editar esta página, aceptas liberar tu contribución bajo la licencia Creative Commons CC0. Consulta las páginas de ayuda sobre el dominio público para obtener más información.
|
![]() |
Esta página trata acerca de crear listas en MediaWiki.
Conceptos básicos de listas
MediaWiki Ofrece tres tipos de listas: listas ordenadas, listas desordenadas, y listas de definiciones. En las secciones siguientes, se usan listas ordenadas para los ejemplos. Las listas desordenadas darían resultados correspondientes.
Wikitexto | Representación |
---|---|
* Las listas son fáciles de hacer: ** empieza cada línea * con un asterisco ** más asteriscos significan *** niveles más profundos |
|
* Un salto de línea * en una lista marca el fin de la lista. Naturalmente * puedes * empezar otra vez. |
marca el fin de la lista. Naturalmente
|
# Las listas numeradas son buenas ## muy organizadas ## fáciles de seguir |
|
* Puedes también ** romper líneas ** de este modo |
|
; Listas de definición ; Elemento : definición ; punto y coma más el término : dos puntos más la definición |
|
; Listas de definición mixta ; elemento 1 : definición :; sub-elemento 1 más el término :: dos veces dos puntos más la definición :; sub-elemento 2 : dos puntos más la definición ; elemento 2 : De vuelta a la lista principal |
|
* O crear listas mixtas *# y anidarlas *#* así *#*; definiciones *#*: trabajo: *#*; manzana *#*; banana *#*: frutas |
|
Párrafos en listas
Por simplicidad, los elementos de una lista en código wiki no pueden ser más largos que un párrafo. Un salto de línea acabará la lista y reiniciará el contador en las listas ordenadas. Separar los elementos en listas desordenadas no tiene efectos visibles normalmente.
Los párrafos pueden ser forzados en las listas usando etiquetas de HTML. Dos símbolos de salto de línea, <br /><br />
, creará el efecto deseado. También lo hará envolver todo excepto el primer párrafo con <p>...</p>
.
Para una lista con elementos de más de un párrafo de largo, añadit una línea en blanco entre los elementos puede ser necesario para evitar confusión.
Continuar un elemento de lista después de un sub-elemento
En HTML, un elemento de lista puede contener varias sub-listas, no necesariamente adyacentes; así, puede haber partes del elemento de lista no sólo antes de la primera sub-lista, sino también entre sub-listas, y después de la última. Sin embargo, en la sintaxis wiki, las sub-listas siguen las mismas reglas que las secciones de una página: la única parte posible del elemento de lista que no esté en una sub-lista es antes de la primera sub-lista.
En el caso de una lista no-numerada de primer nivel en wikitexto, esta limitación puede superarse separando la lista en múltiples listas; un texto "sangrado" entre las listas parciales puede parecer visualmente como parte de un elemento después de una sub-lista; sin embargo, esto puede traer consigo, según el CSS, una línea en blanco antes y después de cada lista, en cuyo caso, para uniformidad, cada elemento de lista de primer nivel podría convertirse en una lista separada.
Las listas numeradas ilustran que, lo que podría parecer una lista, para el software consiste de múltiples listas; las listas desordenadas dan el resultado correspondiente, excepto que el problema de reiniciar con 1 no aplica.
<ol> <li>elemento de lista A1 <ol> <li>elemento de lista B1</li> <li>elemento de lista B2</li> </ol>continuando elemento de lista A1 </li> <li>elemento de lista A2</li> </ol> |
|
vs. | |
#elemento A1 ##elemento B1 ##elemento B2 #:continuando elemento A1 #elemento A2 |
|
En un nivel más profundo, con un elemento de sub-lista continuando después de una sub-sub-lista, se consiguen aún más líneas en blanco; sin embargo, la continuación de la lista de primer nivel no se afecta:
#elemento A1 ##elemento B1 ###elemento C1 ##:continuando elemento B1 ##elemento B2 #elemento A2
da
- elemento A1
- elemento B1
- elemento C1
- continuando elemento B1
- elemento B2
- elemento B1
- elemento A2
Véase también m:Template:List demo.
It is possible to embed unnumbered bullets inside enclosing numbered items:
# list item A #* nested bullet A1 #* nested bullet A2 # continuing list item B #* nested bullet B1 #* nested bullet B2
gives
- list item A
- nested bullet A1
- nested bullet A2
- continuing list item B
- nested bullet B1
- nested bullet B2
Cambiando el tipo de lista
El tipo de lista (qué tipo de marcador aparece antes del elemento de lista) puede ser cambiado en CSS usando la propiedad list-style-type:
Wikitexto | Representación |
---|---|
<ol style="list-style-type:lower-roman"> <li>Sobre el autor</li> <li>Prefacio a la primera edición</li> <li>Prefacio a la segunda edición</li> </ol> |
|
<ol style="list-style-type:lower-alpha"> <li>Sobre el autor</li> <li>Prefacio a la primera edición</li> <li>Prefacio a la segunda edición</li> </ol> |
|
Sangría extra de listas
In a numbered list in a large font, some browsers do not show more than two digits, unless extra indentation is applied (if there are multiple columns: for each column). This can be done with CSS:
ol { margin-left: 2cm}
or alternatively, like below.
Wikitext | Rendering | Comments |
---|---|---|
:#abc :#def :#ghi |
|
A list of one or more lines starting with a colon creates a definition list without definition terms, and with the items as definition descriptions, hence indented. However, if the colons are in front of the codes "*" or "#" of an unordered or ordered list, the list is treated as one definition description, so the whole list is indented. |
<ul> <ol> <li>abc</li> <li>def</li> <li>ghi</li> </ol> </ul> |
|
MediaWiki translates an unordered list (ul) without any list items (li) into a div with a style="margin-left: 2em" , causing indentation of the contents. This is the most versatile method, as it allows starting with a number other than 1, see below.
|
<ul> #abc #def #ghi </ul> |
|
Like above, with the content of the "unordered list without any list items", which itself is an ordered list, expressed with # codes. The HTML produced, and hence the rendering, is the same. This is the recommended method when starting the list at 1. |
To demonstrate that all three methods show all digits of 3-digit numbers, see List demo.
Specifying a starting value
Specifying a starting value is possible with HTML syntax.
<ol start="9"> <li>Amsterdam</li> <li>Rotterdam</li> <li>The Hague</li> </ol> |
|
Or:
<ol> <li value="9">Amsterdam</li> <li value="8">Rotterdam</li> <li value="7">The Hague</li> </ol> |
|
Comparison with a table
Apart from providing automatic numbering, the numbered list also aligns the contents of the items, comparable with using table syntax:
{| |- | align=right | 9.|| Amsterdam |- | align=right | 10.|| Rotterdam |- | align=right | 11.|| The Hague |}
gives:
9. | Amsterdam |
10. | Rotterdam |
11. | The Hague |
This non-automatic numbering has the advantage that if a text refers to the numbers, insertion or deletion of an item does not disturb the correspondence.
Multi-column lists
See also Template:Col-begin, Template:Col-break, Template:Col-end.
Multi-column bulleted list
<div style="column-count:2;-moz-column-count:2;-webkit-column-count:2"> * apple * carpet * geography * mountain * nowhere * postage * ragged * toast </div>
gives:
- apple
- carpet
- geography
- mountain
- nowhere
- postage
- ragged
- toast
<div style="column-count:3;-moz-column-count:3;-webkit-column-count:3"> * apple * carpet * geography * mountain * nowhere * postage * ragged * toast </div>
gives:
- apple
- carpet
- geography
- mountain
- nowhere
- postage
- ragged
- toast
Multi-column numbered list
<div style="column-count:3;-moz-column-count:3;-webkit-column-count:3"> #apple #carpet #geography #mountain #nowhere #postage #ragged #toast </div>
gives:
- apple
- carpet
- geography
- mountain
- nowhere
- postage
- ragged
- toast
Below a starting value is specified, with HTML-syntax (for the first column either wiki-syntax or HTML-syntax can be used).
In combination with the extra indentation explained in the previous section:
{| valign="top" |- |<ul><ol start="125"><li>a<li>bb<li>ccc</ol></ul> |<ul><ol start="128"><li>ddd<li>ee<li>f</ol></ul> |}
gives
|
|
Using m:Template:multi-column numbered list the computation of the starting values can be automated, and only the first starting value and the number of items in each column except the last has to be specified. Adding an item to, or removing an item from a column requires adjusting only one number, the number of items in that column, instead of changing the starting numbers for all subsequent columns.
{{Multi-column numbered list|125|a<li>bb<li>ccc|3|<li>ddd<li>ee<li>f}}
gives:
|
|
{{Multi-column numbered list|lst=lower-alpha|125|a<li>bb<li>ccc|3|<li>ddd<li>ee|2|<li>f}}
gives:
|
|
|
{{Multi-column numbered list|lst=lower-roman|125|a<li>bb<li>ccc|3|<li>ddd<li>ee|2|<li>f}}
gives:
|
|
|
{{Multi-column numbered list|lst=disc||a<li>bb<li>ccc||<li>ddd<li>ee||<li>f}}
gives:
|
|
|
Streamlined style or horizontal style
It is also possible to present short lists using very basic formatting, such as:
''Title of list:'' example 1, example 2, example 3
Title of list: example 1, example 2, example 3
This style requires less space on the page, and is preferred if there are only a few entries in the list, it can be read easily, and a direct edit point is not required. The list items should start with a lowercase letter unless they are proper nouns.
Tables
A one-column table is very similar to a list, but it allows sorting. If the wikitext itself is already sorted with the same sortkey, this advantage does not apply. A multiple-column table allows sorting on any column.
See also When to use tables.
Changing unordered lists to ordered ones
With the CSS
ul { list-style: decimal }
unordered lists are changed to ordered ones. This applies (as far as the CSS selector does not restrict this) to all ul-lists in the HTML source code:
- those produced with *
- those with <ul> in the wikitext
- those produced by the system
Since each special page, like other pages, has a class based on the pagename, one can separately specify for each type whether the lists should be ordered, see User contributions and What links here.
However, it does not seem possible to make all page history lists ordered (unless one makes all lists ordered), because the class name is based on the page for which the history is viewed.
See also
- w:Help:List
- Module:Sort definition list - A Scribunto module that allows to sort definition lists by the term defined, useful on multilingual wikis.