テンプレートの解説[表示] [編集] [履歴] [キャッシュを破棄]

記事ページ内の目次を作るテンプレートです。目次の内容は英字のAからZのアルファベット順表示で、引数の指定によって関連項目や外部リンク節を含めることもできます。Vector2022外装でも専用の場所ではなく本文内に表示されます。

目的 編集

これはアルファベットリストを表形式の目次(TOC: Table-of-Contents)に置き換えるものです:

  • 横並びのコンパクトな形式にします: A B C D E F G H I J K L ...
  • オプションを指定すると、中央揃えにするかどうか、また目次に並べる見出しの数などを指定できます: center=yes, num=yes.
  • 「目次」の表示位置は、既定の画面上か横か、選べます:上(デフォルト), 横(side=yes).
  • 表示する頭文字の範囲も設定できます。(下の#文字を参照): A B C-F G H-K L...
  • アルファベット26文字を全て置かずに、いくつか省いて非表示にもできます。
  • TOCの中に、頭文字以外の見出しを並べることも可能(下の 見出しをカスタム化した目次の書き方を参照)
  • 大文字の見出しを使うには、"ABCDEF"の前に、pre1, pre2, ... pre8 と書きます。(#サンプル集節を見てください。)
  • "ABCDEF"の後ろに小文字の見出しを置くには、custom1, custom2, ... custom8 と書きます。(サンプル集を見てください。)
  • 下位の見出しへのリンク文を非表示にするには、"pre1link" の代わりに "pre1name"、"custom1link" の代わりに "custom1name" を指定するなどします。
  • その他のオプションもあります。配置(top=yes)のほか、関連項目節(seealso=yes)や出典節(refs=yes)、外部リンク節(extlinks=yes)その他を目次の項目にするかどうか。テンプレートには目次テンプレートが備えたその他の機能もあり、オプションで "Top" "0–9" を見出しにしたり、さらに 部分の指定もできます。

使い方 編集

一般的:

{{Compact ToC|symnum=yes}}


アルファベット順に限定する。

{{Compact ToC}}


よく使われる記述。

{{Compact ToC|center=yes|seealso=yes|refs=yes|further=yes}}

見出しを水平に配置。
{{Compact ToC
 |center  = yes
 |seealso = yes
 |refs    = yes
 |further = yes
}}


要素を最大まで採用して中央揃えにする場合(要素を無効にするにはパラメータをコメントアウトするか、空欄に置き換えるか、等号の右に「no」と記入)

{{Compact ToC
 |name=
 |side=yes
 |center=yes
 |right=
 |align=center
 |nobreak=yes
 |top=yes
 |num=yes
 |sym=yes
 |symnum=
 |pre1=
 |pre1name=
 |pre1link=
 ...
 |pre8=
 |pre8name=
 |pre8link=
 |prebreak=<br>
 |custom1=
 |custom1name=
 |custom1link=
 ...
 |custom8=
 |custom8name=
 |custom8link=
 |seealso=yes
 |notesfirst=
 |refs=yes
 |notes=yes
 |further=yes
 |extlinks=yes
 |a=
 ...
 |z=
}}

Parameters 編集

  • name=: change the heading to an alternative name instead of "Contents", or hide it completely by entering name=no
  • side=yes: put the "Contents" heading on the left side with a colon, instead of the top without one
  • center=yes: float TOC centered in the horizontal middle of the page, instead of floated left
  • right=yes: align the TOC horizontally to the right of the page (may require <br style="clear:right;" /> after it, depending on page layout), instead of floated left (this parameter is mutually exclusive with the "center" option above, and should be used sparingly and with good reason)
  • nobreak=yes: no linebreak between the A-B-C-etc. stuff and the See also/References/etc. stuff (note: does not affect the heading; use side= for that)
  • top=yes: enable the "Top" link; this is only useful if this copy of the TOC is a secondary TOC not at the top of the page, e.g. in the middle of a long glossary. (Every rendered page has a hidden <a name="top" id="top"></a> above the sitenotice which makes this link work without having to do anything but enable it in the template.)
  • num=yes: enable the "0–9" link for numeric entries section (create a heading of ==0&ndash;9== for the link to work)
  • sym=yes: enable the "!$@" link for symbolic entries section
  • symnum=yes: enable the "!–9" link for combined symbolic and numeric entries section (create a heading of ==!&ndash;9== for the link to work)
  • letters=no: suppresses the "A", "B", ..., "Z" entries.
  • pre1 to pre12: list up to 12 extra section headers before (pre-list) the "ABCDEF" list. These appear as [[:en:Template:Compact_TOC/doc#pre1|pre1]].
  • pre1name to pre12name: modifies the way the pre-list section headers appear: [[:en:Template:Compact_TOC/doc#pre1|pre1name]]
  • pre1link to pre12link: modifies the targets of the pre-list headers: [[:en:pre1link|pre1]].
  • prebreak=yes: set break-line after all pre-list headers
  • custom1 to custom12: add up to 12 extra "custom" sections after the "ABCDEF" list. These appear as [[:en:Template:Compact_TOC/doc#custom1|custom1]].
  • custom1name to custom12name: modifies the way the custom section headers appear: [[:en:Template:Compact_TOC/doc#custom1|custom1name]]
  • custom1link to custom12link: modifies the targets of the custom sections: [[:en:custom1link|custom1]]. Use this only for linking to another page. Use sparingly! About the only legitimate use for this is connecting the sub-pages of multi-page articles, like long lists that have been broken up. Do not repurpose the TOC as a makeshift navbox.
  • seealso=yes: enable link to the "See also" section
  • notesfirst=yes: enable link to the "Notes" section, but placed before "References"; do not use with notes (and do observe that it is plural)
  • refs=yes: enable link to the "References" section (observe that it is plural)
  • notes=yes: enable link to the "Notes" section (observe that it is plural)
  • further=yes: enable link to the "Further reading" section
  • extlinks=yes: enable link to the "External links" section
  • a= through z=: individually disable particular letters that have no entries. Use with caution and check regularly to make sure that new entries do not require the removal of these parameters. Can also be used to create range links, e.g. "X-Z". (See following section for more detailed documentation of this feature.)
    • The equivalent of this for numbers is 0-9= - note this is a hyphen and not a dash (the heading uses a dash)
  • allowtoc=yes: disables the hiding of the automatically-generated table of contents that __NOTOC__ usually hides. (Since this template's purpose is usually to replace the existing table of contents, this functionality is usually only necessary on Wikipedia guideline pages that use this template in examples.)

文字 編集

いずれの頭文字も省略が可能で(つまりそれに属するエントリがない場合)、次のように必ず小文字で 記し、パラメータの値が空であることを示します(訳注:次のサンプルでは「J」「Q」が非表示。)  {{Compact ToC|side=yes|j=|q=}}

あるいはリンクをつけない文字に置換できます(大文字で記入)。(訳注:次のサンプルでは「J」「Q」にリンクがありません。)

{{Compact ToC|side=yes|j=J|q=Q}}

注記:安全策として常に空欄のプレースホルダを設けます(例えばそれぞれの文字がページ内に存在していて、見出しとして目次に置く場合、<span id="Q" /> と記述。ほとんどの場合、将来的にその頭文字の記事ができる可能性を否定できないため。合わせて、span-id を採用すると、目次のテンプレート TOC で一部の文字には一覧がないと気づかなくても、新規利用者を混乱させない工夫として有効。)

範囲のリンクを作成するには、文字の割り当て機能が使えます。

{{Compact ToC|side=yes|x=[[#X-Z|X-Z]]|y=|z=}}

この機能はまた、下位ページの記事にリンクを書くこともできます(例:long lists(英語)など複数の記事に分割された場合など。手間はかかる。)

{{Compact ToC|name=[[記事名]]|side=yes|n=[[記事名 (N–Z)#N|N]]|o=[[Articlename (N–Z)#O|O]]|...|z=[[記事名 (N–Z)#Z|Z]]}}

同じ結果を示す別の記述法の例。

{{Compact ToC|side=yes|n=[[記事名 (N–Z)|&nbsp;N–Z (next page)]]|o=|p=|...|z=}}

目次に示す見出しをカスタム化 編集

オプションのパラメータとして pre1...pre8 ならびに custom1...custom8 を当てると、目次に最大16件まで別の節見出しを示すことができます。その位置は、アルファベット順に整理した見出し「ABCDEF」の前もしくは後を指定します。 {{Compact ToC|name=no|center=yes|top=yes|seealso=yes|notes=yes|custom1=新しい節|custom2=その他の節}}

{{Compact ToC|name=no|center=yes|top=yes|seealso=yes|notes=yes|custom1=新しい節|custom1name=カスタム化した節名|custom2=外部リンク|custom2link=メインページ}}


見出しの配置は、「ABCDE」順一覧の前でも後でも指定できます。

{{Compact ToC|center=yes|align=center|top=yes|seealso=yes
|pre1=一覧の範囲|pre2=使用する略号|prebreak=<br>
|custom1=汎用される項目名|custom2=除外した項目名|notes=yes}}


"sep=&middot;" を使うと、区切り文字は半角中グロ記号に置き換わります[訳語疑問点]

{{Compact ToC|center=yes|align=center|top=yes|seealso=yes
|pre1=一覧の範囲|pre2=使用する略号|prebreak=<br>
|custom1=汎用される項目名|custom2=除外した項目名|sep='''&middot;'''}}

省略形 編集

  • short1 をいちばん最初のパラメータに指定すると(name=の直前)省略形の記述ができます。

標準の表記で{{Compact ToC|side=yes|center=yes|nobreak=yes|refs=yes}}と記すところを、以下の省略形で代替します。

{{Compact ToC|short1}}

サンプル集 編集

{{Compact ToC|top=yes}}

{{Compact ToC|side=yes|sym=yes|num=yes|refs=yes|seealso=yes|custom1=その他}}

{{Compact ToC|name=Directory|top=no|refs=yes|notes=yes|extlinks=yes}}

{{Compact ToC|name=no|side=yes|right=yes|symnum=yes|seealso=yes}}


{{Compact ToC|short1|num=yes|sym=yes|seealso=yes|notesfirst=yes|further=yes|extlinks=yes}}

別名 編集

  • {{TOC}}

関連項目 編集

  • Help:マジックワード#目次 - 既定の目次を表示させない「__NOTOC__」や表示場所を指定する「__TOC__」など、目次に関するマジックワードの説明

関連テンプレート 編集