Template:Auto TOC link/doc

This template generates an appropriate TOC link template for a page number when supplied with parameters for a particular work. It is intended to automate the process of creating page links when a large number are required (normally in a book index).

In particular, this template automates the process of setting the scan page link and the chapter title, which would otherwise need to be done manually for every instance of TOC link. Because it uses an offset for the page number and a single switch to determine the correct chapter, can be substituted in for every page number by a simple regex query.

Usage
To use this template in a particular work, a subpage of the template needs to be created containing a function that will return the appropriate subpage of the work for a given page number, e.g.:

Three parameters are required:
 * : The page number
 * : The offset of the corresponding page in the Page namespace, e.g. 3 if page 1 is located at Page:…/4
 * : The title of the relevant subpage of this template.

Example
→


 * Auto TOC link/EinC contains a switch that will return the correct chapter for a given page number in Europe in China. Page 55 is in Chapter 6 of the work, so on this page the template links to Template:Auto TOC link/Chapter 6.