Help:リスト

This page is a translated version of the page Help:Lists and the translation is 63% complete.
PD 注意: このページを編集すると、編集内容が CC0 のもとで公開されることに同意したと見なされます。詳細はパブリック・ドメインのヘルプ ページを参照してください。
このページの古い版の一部は、CC BY-SA ライセンスのもとで取り込まれました。 新しい編集のみがパブリックドメインと見なされます。
PD

このページでは MediaWiki でのリスト (一覧、列挙) の作成を扱います。

リストの基本

MediaWiki では、以下に示す3種類のリストをつくることができます: 番号なしリスト番号つきリスト定義リスト

基本事項

番号なしリスト
各リスト項目は、アスタリスク * で始まる行に記します。例: * item
番号つきリスト
各リスト項目は、ハッシュ # で始まる行に記します。例: # item
定義リスト
各項目は 用語説明 の2つの部分で構成されています。
The term is on a new line starting with a semicolon ; e.g. ; term.
説明 は、同じ行でコロン : に続けて記します。例:; 用語 : 説明
または、説明 を、コロン : で始まる独立した行に記します。例:: 説明(各用語には複数の説明を設けることもでき、それぞれの説明文はコロンで始まる行に記します)。

もう少し詳細な話

以下の表に、いくつかの事例について記述方法を表示結果を示します。

ウィキテキスト 表示結果
* リストで簡単に処理できる内容とは:
** 各行の先頭に
* 星印を使う
** 星印を増やすと
*** インデント (字下げ) が深くなる
  • リストで簡単に処理できる内容とは:
    • 各行の先頭に
  • 星印を使う
    • 星印を増やすと
      • インデント (字下げ) が深くなる
* リストに
* 新しい行を加えると
リスト形式を終了。
もちろん
* リストの再開も
* 可能。
  • リストに
  • 新しい行を加えると

リスト形式を終了。 もちろん

  • リストの再開も
  • 可能。
# 数字付きリストは有効
## スッキリして見え
## 順序がわかりやすい
  1. 数字付きリストは有効
    1. スッキリして見え
    2. 順序がわかりやすい
* このように
** リストの<br>途中で<br>改行もできる
  • このように
    • リストの
      途中で
      改行もできる
; 定義リスト
; 用語 : 定義
; セミコロンの後に単語
: コロンの後に定義
定義リスト
項目
定義
セミコロンの後に単語
コロンの後に定義
; 要素が混在する定義リスト
; 項目 1 : 定義
:; 下位項目 1 の後に用語
:: コロン2個の後に定義
:; 下位項目 2 : コロンの後に定義
; 項目 2 
: メインのリスト形式に戻る
要素が混在する定義リスト
項目 1
定義
下位項目 1 の後に用語
コロン2個の後に定義
下位項目 2
コロンの後に定義
項目 2
メインのリスト形式に戻る
* あるいは要素が混在するリストを作成し
*# このように
*#* 入れ子にする
*#*; 定義
*#*: 作業:
*#*; 林檎
*#*; バナナ
*#*: くだもの
  • あるいは要素が混在するリストを作成し
    1. このように
      • 入れ子にする
        定義
        作業:
        林檎
        バナナ
        くだもの

複数行を含むリスト

簡略化のために、wikiマークアップのリスト項目は段落より長くすることはできません。リストの後に空白行があるとリストは終了し、番号付きリストの番号はリセットされます。番号なしリスト項目を分離しても、通常は特に目立った効果はありません。

HTMLタグを使えば、リスト内に段落を強制的に挿入することができます。 複数行のテキストを記述したいなら、改行記号を2つ、つまり <br /><br /> を追加してください。 テキストを‎<p>...‎</p>で囲むと、そのテキストは新しい段落となり、独立した行として表示されます。

サブリスト項目の後にメインリスト項目を続けるには

HTMLの場合、リスト項目にはいくつかのサブリストを含めることができ、必ずしも隣接している必要はありません。したがって、リスト項目の一部が、最初のサブリストの前だけでなく、サブリストの間や、最後のサブリストの後にも存在する可能性があります。しかし、wiki構文の場合、サブリストはページの節と同じ規則に従います。つまり、メインリストの項目は最初のサブリストの前にしか記述できません。

第1レベルの番号なしリストをウィキテキストコードで書くとき、リストを複数のリストに分割することによりこの制限は回避できます。メインリストの一部分の間に記したインデントつきテキストは、サブリストの後に置かれたメインリスト項目の一部のように見えます。しかし、これはCSSの設定によっては、各リストの前後に空行を表示してしまうかもしれません。この場合、すべての第1レベルリスト項目を別々のリストとすれば体裁を統一できます。

番号つきリストは、一見一つのリストに見えるものが、ソフトウェア上では複数のリストで構成されていることを示しています。番号なしリストも、番号が再び1から始まるという問題がないことを除けば、同様の結果になります。

ウィキテキスト 表示結果
<ol>
  <li>リスト項目 A1
    <ol>
      <li>リストアイテム B1</li>
      <li>リスト項目 B2</li>
    </ol>リスト項目の続き A1
  </li>
  <li>リストアイテム A2</li>
</ol>
  1. リスト項目 A1
    1. リストアイテム B1
    2. リスト項目 B2
    リスト項目の続き A1
  2. リストアイテム A2
vs.
#リスト項目A1
##リスト項目B1
##リスト項目B2
#:リスト項目A1の続き
#リスト項目A2
  1. リスト項目A1
    1. リスト項目B1
    2. リスト項目B2
    リスト項目A1の続き
  2. リスト項目A2

One level deeper, with a sublist item continuing after a sub-sublist, one gets even more blank lines; however, the continuation of the first-level list is not affected:

ウィキテキスト 表示結果
#list item A1
##list item B1
###list item C1
##:continuing list item B1
##list item B2
#list item A2
  1. list item A1
    1. list item B1
      1. list item C1
      continuing list item B1
    2. list item B2
  2. list item A2

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
  1. list item A
    • nested bullet A1
    • nested bullet A2
  2. continuing list item B
    • nested bullet B1
    • nested bullet B2

リスト型の変更

リストごと

The list type (which type of marker appears before the list item) can be changed in CSS by setting the list-style-type property:

ウィキテキスト 表示結果
<ol style="list-style-type:lower-roman">
  <li>About the author</li>
  <li>Foreword to the first edition</li>
  <li>Foreword to the second edition</li>
</ol>
  1. About the author
  2. Foreword to the first edition
  3. Foreword to the second edition
<ol style="list-style-type:lower-alpha">
  <li>About the author</li>
  <li>Foreword to the first edition</li>
  <li>Foreword to the second edition</li>
</ol>
  1. About the author
  2. Foreword to the first edition
  3. Foreword to the second edition

Site-wide

The standard #, ##, ### wikitext can be used alongside CSS in MediaWiki:Common.css to produce the usual system of numbered lists (1, 2, 3; then a, b, c; then i, ii, iii):

ol { 
	list-style-type: decimal; 
}
ol li > ol { 
	list-style-type: lower-alpha; 
}
ol li > ol li > ol { 
	list-style-type: lower-roman; 
}

The first ol above is the default, so not necessary unless some other list-style-type is required.

Wikitext Rendering
#list item A1
##list item B1
###list item C1
###list item C2
##list item B2
#list item A2
  1. list item A1
    1. list item B1
      1. list item C1
      2. list item C2
    2. list item B2
  2. list item A2

リスト内の字下げを増やす

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 colons: for each colon). This can be done with CSS:

ol { margin-left: 2cm}

or alternatively, like below.

ウィキテキスト 表示結果 コメント
:#abc
:#def
:#ghi
 
  1. abc
  2. def
  3. ghi
A list of one or more lines starting with a colon creates a description 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>
  1. abc
  2. def
  3. ghi
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>
  1. abc
  2. def
  3. ghi
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.

開始番号を指定する

HTML構文を使って開始番号を指定することができます。

<ol start="9">
<li>アムステルダム</li>
<li>ロッテルダム</li>
<li>ハーグ</li>
</ol>
  1. アムステルダム
  2. ロッテルダム
  3. ハーグ

または:

<ol>
<li value="9">アムステルダム</li>
<li value="8">ロッテルダム</li>
<li value="7">ハーグ</li>
</ol>
  1. アムステルダム
  2. ロッテルダム
  3. ハーグ

表組みとの比較

Apart from providing automatic numbering, the numbered list also aligns the contents of the items, comparable with using table syntax:

{|
|-
| align=right |  9.|| アムステルダム
|-
| align=right | 10.|| ロッテルダム
|-
| align=right | 11.|| ハーグ
|}

gives:

9. アムステルダム
10. ロッテルダム
11. ハーグ

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.

複数列のリスト

Template:Col-begin, Template:Col-break, Template:Col-endも参照してください。

複数列の中黒付き箇条書き

<div style="column-count:2">
* 林檎
* じゅうたん
* 地理
* 山脈
* どこでもない
* 切手
* ぎざぎざ
* トースト
</div>

gives:

  • 林檎
  • じゅうたん
  • 地理
  • 山脈
  • どこでもない
  • 切手
  • ぎざぎざ
  • トースト
<div style="column-count:3">
* apple
* carpet
* geography
* mountain
* nowhere
* postage
* ragged
* toast
</div>

gives:

  • 林檎
  • じゅうたん
  • 地理
  • 山脈
  • どこでもない
  • 切手
  • ぎざぎざ
  • トースト

複数列の番号付き箇条書き

<div style="column-count:3">
* 林檎
* じゅうたん
* 地理
* 山脈
* どこでもない
* 切手
* ぎざぎざ
* トースト
</div>

gives:

  • 林檎
  • じゅうたん
  • 地理
  • 山脈
  • どこでもない
  • 切手
  • ぎざぎざ
  • トースト

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><li>bb</li><li>ccc</li></ol></ul>
|<ul><ol start="128"><li>ddd</li><li>ee</li><li>f</li></ol></ul>
|}

gives

    1. a
    2. bb
    3. ccc
      1. ddd
      2. ee
      3. f

      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:

        1. a
        2. bb
        3. ccc
          1. ddd
          2. ee
          3. f
          {{Multi-column numbered list|lst=lower-alpha|125|a<li>bb<li>ccc|3|<li>ddd<li>ee|2|<li>f}}
          

          gives:

            1. a
            2. bb
            3. ccc
              1. ddd
              2. ee
                1. f
                {{Multi-column numbered list|lst=lower-roman|125|a<li>bb<li>ccc|3|<li>ddd<li>ee|2|<li>f}}
                

                gives:

                  1. a
                  2. bb
                  3. ccc
                    1. ddd
                    2. ee
                      1. f
                      {{Multi-column numbered list|lst=disc||a<li>bb<li>ccc||<li>ddd<li>ee||<li>f}}
                      

                      gives:

                        1. a
                        2. bb
                        3. ccc
                          1. ddd
                          2. ee
                            1. f

                            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.

                            表組みを使う条件も参照してください。

                            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 also 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.

                            関連項目