Template:Anchor: Difference between revisions
Create a minimal anchor template (no ParserFunctions on this wiki, so single-anchor form) (via create-page on MediaWiki MCP Server) |
Sync from repo (wiki-pages) |
||
| (One intermediate revision by one other user not shown) | |||
| Line 2: | Line 2: | ||
'''Usage:''' <code><nowiki>{{anchor|Anchor_name}}</nowiki></code> creates the link target <code>#Anchor_name</code> on the current page. | '''Usage:''' <code><nowiki>{{anchor|Anchor_name}}</nowiki></code> creates the link target <code>#Anchor_name</code> on the current page. | ||
'''Every heading already gets a link target automatically.''' A heading that mixes text and math is normalised: the <code>$…$</code> math is dropped (a heading that is ONLY math keeps it), and the characters that cannot appear in a fragment — <code># < > [ ] | { }</code> — become <code>_</code>. So this needs no template call: | |||
<code><nowiki>=== Symmetric groups $\mathcal{S}_{n}$ ===</nowiki></code> → <code><nowiki>[[Page#Symmetric_groups]]</nowiki></code> | |||
The anchor must not contain | The section's <code>[Copy internal mention]</code> and <code>[Copy URL]</code> use that anchor. | ||
Use this template when you want a different, readable anchor — especially for a math-only heading or a long heading. It '''wins''' over the automatic anchor: | |||
<code><nowiki>=== {{anchor|sign composition}} $\operatorname{sign}(\sigma_1 \circ \sigma_2)$ ===</nowiki></code> → <code><nowiki>[[Permutation#sign composition]]</nowiki></code> | |||
The anchor must not contain any of <code># < > [ ] | { }</code>; prefer <code>_</code> instead of spaces (the automatic anchors use it). This wiki does not have ParserFunctions, so there is no multi-anchor form: call the template once per anchor. | |||
Place the call at the start of the heading (<code>=== <nowiki>{{anchor|Name}}</nowiki>Heading ===</code>) or at the start of the section body on the same line as the text. A call alone on its own line produces an empty paragraph. | |||
</noinclude> | </noinclude> | ||
Latest revision as of 11:48, 19 October 2026
Usage: {{anchor|Anchor_name}} creates the link target #Anchor_name on the current page.
Every heading already gets a link target automatically. A heading that mixes text and math is normalised: the $…$ math is dropped (a heading that is ONLY math keeps it), and the characters that cannot appear in a fragment — # < > [ ] | { } — become _. So this needs no template call:
=== Symmetric groups $\mathcal{S}_{n}$ === → [[Page#Symmetric_groups]]
The section's [Copy internal mention] and [Copy URL] use that anchor.
Use this template when you want a different, readable anchor — especially for a math-only heading or a long heading. It wins over the automatic anchor:
=== {{anchor|sign composition}} $\operatorname{sign}(\sigma_1 \circ \sigma_2)$ === → [[Permutation#sign composition]]
The anchor must not contain any of # < > [ ] | { }; prefer _ instead of spaces (the automatic anchors use it). This wiki does not have ParserFunctions, so there is no multi-anchor form: call the template once per anchor.
Place the call at the start of the heading (=== {{anchor|Name}}Heading ===) or at the start of the section body on the same line as the text. A call alone on its own line produces an empty paragraph.