利用者:Sat.d.h./改ページ

Page breaks
This page explains solutions to common problems relating to text being broken across pages in the Page: namespace.

Page breaks can cause several problems when transcluding texts, even if the individual pages render well in the Page: namespace.

Templates across page breaks 編集

If you have a template that spans a page break, you cannot just put the opening of the template (eg {{fine block| on the first page and the closing }} on the next page. This is because the Wikimedia software first renders the wikicode on each page, before transclusion, so the software never notices that a template is closed in a later page: it treats it as normal text.

To get around this you need to use a "split" form of this template, along with the header and footer fields in the Page: namespace edit view (if you don't have these visible, click the [+] button in the toolbar). This means that only a single "start" and "end" template appear in the transclusion, but the contained text is not actually inside a template. Each page is also wrapped in the Page: namespace, using the header and footer fields, so it appears correctly both before and after transclusion.

Method 編集

First page 編集

Body
{{fine block/s}}
First page text
Footer
{{fine block/e}}

Middle pages 編集

Header
{{fine block/s}}
Body
Middle page text
Footer
{{fine block/e}}

Last page 編集

Header
{{fine block/s}}
Body
Last page text
{{fine block/e}}

Templates that use this system 編集

This method is used by many templates. These are "block" level templates like {{fine block}}, as "span" level templates like {{smaller}} don't cause a line break when they are ended. If you need to run a span template across page, simply terminate the first template on the first page, and start a new one on the second.

If the block template you would like to use across a page break doesn't have a split variant, create it using one of the templates above as a reference. Remember to transclude the documentation from the unsplit template page.

Tables across page breaks 編集

Tables split over pages are done the same way as the split templates above, using the table syntax of {| and |} instead of {{template/s}} and {{template/e}}. For some commonly used table formatting, split templates such as {{block center/s}} and {{TOC begin}} already exist, and are used as described above.

For a one-off split-table, you don't need to make a template.

Method 編集

First page 編集

Body
{| class="class?" style="table styling here"
|-
|Table contents
|-
Footer
|}

Middle pages 編集

Header
{| class="class?" style="table styling here" (same as first page, or this page will render wrongly in the page view)
|-
Body
{{nop}}
|More table rows
|-
Footer

|}

Last page 編集

Header
{| class="class?" style="table styling here" (same as first page, or this page will render wrongly in the page view)
|-
Body
{{nop}}
|More table rows
|}

Footer content beneath a table which crosses pages 編集

Distinct from but related to the above is the case where footer content ought to appear (typically a footnote or page number) beneath a "first" or "middle" component of a multi-page-crossing table. The following code looks like it ought to work but in fact fails:

First page Middle page
Body
{| class="class?" style="table styling here"
|-
|Table contents
|-
Footer
|}
<references/>
Header
{| class="class?" style="table styling here" (same as first page, or this page will render wrongly in the page view)
|-
Body
{{nop}}
|More table rows
|-
Footer
|}
<references/>

Under the current software the footnotes are frustratingly rendered above the top of the table instead of where you might expect them to appear.

Method 編集

The solution is to insert a {{nop}} into the footer just above the |} like this:

First page Middle page
Body
{| class="class?" style="table styling here"
|-
|Table contents
|-
Footer
{{nop}}
|}
<references/>
Header
{| class="class?" style="table styling here" (same as first page, or this page will render wrongly in the page view)
|-
Body
{{nop}}
|More table rows
|-
Footer
{{nop}}
|}
<references/>

Footnotes across page breaks 編集

Footnotes that span more than one page are handled in a similar way to normal. The method below will display correctly both in the Page namespace and when transcluded into the Main namespace.

Method 編集

First page 編集

Body
Lorem ipsum dolor sit amet,<ref name="p76">dolorem ipsum, quia dolor sit amet,</ref>
Footer
{{smallrefs}}

Subsequent pages 編集

Body
…est laborum.<ref follow="p76">consectetur, adipisci velit…</ref>
Footer
{{smallrefs}}

Potential problems 編集

  • The <ref name=…> can be anything, but the use of the page number is preferred.
  • Normally the <ref follow=…> is at the end of the page. However, if there is a change of section – for transcluding in a different chapter – then continued footnote should be moved to the top of the page, or else it will not be transcluded.
  • Long footnotes may have multiple paragraphs; the use of double carriage returns to start a new paragraph will not work in the transcluded footnotes – it has to be forced by wrapping the second and subsequent paragraphs with the HTML paragraph tags <p>…</p>.

Newlines across pagebreaks 編集

The default behavior for transclusion is to just add a space between the text of two pages, even when there should be a paragraph break, or when there should be no space at all. There are a few templates to assist in such cases.

Template You type You get
{{Hyphenated word start}} or {{hws}} This page ends with the split word "{{Hyphenated word start|abso|absolutely}} This page ends with the split word "abso-
{{Hyphenated word end}} or {{hwe}} {{Hyphenated word end|lutely|absolutely}}," split between two pages. -lutely," split between two pages.
{{nop}} Used where the end of a page is also end of a paragraph.

NB: The hyphenated word start and hyphenated word end should be paired across two pages in the Page namespace. They will appear correctly as one, unhyphenated word when transcluded to the main namespace.