Manual:目次

This page is a translated version of the page Manual:Table of contents and the translation is 57% complete.
このページはウィキページの目次について扱っています。MediaWiki の技術的マニュアルの本文ページについては、Manual:コンテンツ を参照してください。

普通、目次(TOCと略されることもある)は、3つ以上のセクションヘッダを使っているページに自動的に付けられます。

一般的に、目次はページのすべてのヘッダに番号をつけて表示します。

目次では、見出し内の HTML は以下のタグ以外はすべて取り除かれます:

  • ‎<sup>, ‎<sub>[1]
  • ‎<i>[2]
  • ‎<b>[3]
  • ‎<bdi>[4]
  • <span dir="rtl">, <span dir="ltr">[5]
  • ‎<s>, ‎<strike>[6]
  • ‎<q>[7]

The table of contents is not generated for section headings that are found within html tags (Manual:$wgRawHtml ).

目次を隠す

Place __NOTOC__ anywhere you want on the page to hide its TOC.

Using certain templates, such as Template:Compact ToC (found on English Wikipedia), will replace the regular Table of Contents functionality.

目次の位置を決める

目次の既定の位置は、最初の節見出しの直前です。 最初の見出しより前にあるテキストはすべて目次の前に置かれます。 それ以外の所に目次を配置するには、置きたい所でマジックワード __TOC__ を使います。

外装は Extension:DeToc を使って、目次を無くしたりページの他の節に移動できます。

目次の追加

もし、そのページが3つ未満のヘッダしか持っていなくても目次が欲しいなら、どこかに __FORCETOC__ と書いて標準位置に配置するか、置きたい場所に __TOC__ と書いてそこに配置するかの2つの方法があります。

目次のカスタマイズ

An extenuating circumstance may require the width of a TOC width to be adjusted as a percentage of a page. 例: {{TOC left|width=30%}}

深さ

目次に表示することができる最大のヘッダ数は、$wgMaxTocLevel によって定義されます。 To customize this for individual pages, the TOC can be enclosed in an element with class toclimit-<limit>, if the appropriate CSS rules are defined in the pages CSS.

実装例は、 Template:TOC/limit-styles.css の中の Template:TOC とそれに関係するルールを参照して下さい。

自動で番号を付ける

普通、目次は節に自動で番号を付けます。 節の見出し自体に番号は付けられません。 目次の番号の付け方は、次のいくつかの方法でカスタマイズ出来ます。

  • MediaWiki:Common.css.tocnumber { display: none; } として定義された適切なクラスが存在する場合、目次での自動の番号付けをさせないことができます。

To do this selectively, a wrapper element can be placed around the TOC, as in <div class="noautonum">__TOC__</div> on the page, and .noautonum .tocnumber { display: none; } at MediaWiki:Common.css.

It is also possible to add numbering to headings themselves using JavaScript, as explained at Snippets/Auto-number headings .

国際化

Different languages have different ways of expressing TOCs and how its (sub)section numbering is done. Also, the different style guides of many languages differ in what style of TOC and TOC (sub)section numbering scheme they recommend for writers to use.

The different w:style guides of each language sometimes recommend different typographic conventions to follow.

It's important to note that most languages don't even have any style guide for writing in that language (and many languages don't have a written form entirely), so people usually use the most common style based on existing written convention (not prescribed, but simply 'standard' due to popular usage), which makes the written use of many languages have a sort of 'fluid' punctuation, spelling/orthography and even [personal changes of the very] grammar [of that particular language]. w:Westernization has influenced alphabet and non-alphabet writing systems, with many languages simply copying or being artificially converted to European-style typographic and w:punctuational conventions.

An example on how to change the style of a TOC to a localized one is given below:

Some languages put a dot after a (sub)section ordinal number, e.g. they do not use the following TOC style:

Contents
1 Section [1]
1.1 Subsection [1.1]
2 Section [2]
2.1 Subsection [2.1]
3 Section [3]
3.1 Subsection [3.1]
3.1.1 Subsubsection [3.1.1]
3.1.2 Subsubsection [3.1.2]

But use one like so:

Contents
1. Section [1.]
1.1. Subsection [1.1.]
2. Section [2.]
2.1. Subsection [2.1.]
3. Section [3.]
3.1. Subsection [3.1.]
3.1.1. Subsubsection [3.1.1.]
3.1.2. Subsubsection [3.1.2.]

(Notice the addition of dots after ordinal numerals before the section names!)

It's possible to produce that effect using w:CSS. Put the following CSS code in a shared CSS file of your MediaWiki installation and it should work:

.tocnumber:after { content: '.' }

where the symbol between the single quotation marks is the sign after a (sub)section number.

Also, see bugzilla:43494 and bugzilla:33450 for details on related i18n problems of TOCs.

フローティング

The TOC can be made to display as a floating element on the page, with text flowing around it.

For this, enclose the TOC in an element with the CSS style float:left; or float:right;.

実装例は Template:TOC を参照してください。

拡張機能

The behavior of the table of contents can be further adjusted using extensions.

一覧は Category:TOC extensions を参照してください。

外部リンク

  1. MediaWiki 1.11 (2007年9月) 以降。 phab:T10393 を参照してください。
  2. MediaWiki 1.19 (2011年11月) 以降。 phab:T28375 を参照してください。
  3. MediaWiki 1.19 (2011年12月) 以降。. phab:T28375 を参照してください。.
  4. MediaWiki 1.25/wmf14 () 以降。 phab:T74884 を参照してください。
  5. From MediaWiki 1.21/wmf1 (). See phab:T37167.
  6. From MediaWiki 1.28/wmf.21 (). See phab:T35715.
  7. From MediaWiki 1.39.0-wmf.6 (). See phab:T251672.