Template:Gaps/doc

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

Script error: No such module "Message box". Template:Lua

Template:Gaps outputs its unnamed arguments in order, applying the margin-left: 0.25em CSS rule to all but the first, so that there will be gaps of 0.25 em between the arguments. The whole output has the white-space: nowrap rule so that it will not be broken across several lines.

It supports up to twenty unnamed arguments. In addition, it supports the base and e arguments which can be used for numbers in exponential notation. The base will be assumed to be 10 unless otherwise specified; a hyphen-minus "-" in the exponent will be automatically substituted by a minus sign "−". It also supports the arguments lhs and u for putting left-hand sides and units within the non-breaking span (see examples below).

See Wikipedia:Manual of Style (dates and numbers) § Delimiting (grouping of digits) for information about where to put the gaps in numbers.

Usage

Input Output
{{gaps|−2.002|319|304|3622|(15)}} Script error: No such module "Gaps".
{{gaps|299|792|458|u=m/s}} Script error: No such module "Gaps".
{{gaps|lhs=π|3.14159|26535|89793|23846|26433|83279|...}} Script error: No such module "Gaps".
{{gaps|P.|A.|M.}} Dirac Script error: No such module "Gaps". Dirac
{{nowrap|1={{gaps|sin|2''φ''}} = 2 {{gaps|sin|''φ''}} {{gaps|cos|''φ''}}}} Script error: No such module "Gaps". = 2 Script error: No such module "Gaps". Script error: No such module "Gaps".
"She disputed his statement that 'Voltaire never said "I disapprove of what you say, but I will defend to the death your right to say {{gaps|it."|'|"}} "She disputed his statement that 'Voltaire never said "I disapprove of what you say, but I will defend to the death your right to say Script error: No such module "Gaps".
{{gaps|1.602|176|487|(40)|e=-19|u=C}} Script error: No such module "Gaps".
64 MB ({{gaps|64|base=2|e=20}} bytes) 64 MB (Script error: No such module "Gaps". bytes)
{{gaps|A|B|C|gap=10em}} Script error: No such module "Gaps".

Some of these examples are technically correct as to behavior of this template, but not recommendable uses:

  • MOS:INITIALS requires literal spaces between human initials (except in unusual circumstances). Thus, use P. A. M. Dirac. To prevent line wrapping within initials, use either P. A. M. Dirac or Template:Tlp Dirac. The latter should not be used within a citation template.
  • For spacing-apart of contiguous quotation marks, as in the Voltaire example, we have simpler dedicated templates: ... right to say it.Template:Tl

Performance impact

Template:Gaps allows any number of parameters, and displays the gaps by setting the left margin space of each group. The gaps are not actual spaces, so a copy/paste of the text is treated as connected, consecutive text. Although the text, as displayed, is consecutive as on-screen text, {gaps} for a number cannot be used in a calculation because the internal markup contains the invisible <span> tags which would be invalid text in typical numeric processing.

See also

  • Template:Tl to format a number to show commas, but decimal gaps of three or four digits.

Template:Inline spacing templates