• Home
  • Random
  • Nearby
  • Log in
  • Settings
Donate Now If Wikipedia is useful to you, please give today.
  • About Wikipedia
  • Disclaimers
Wikipedia

Template:Tmath

  • Template
  • Talk
  • Language
  • Watch
  • View source
Template documentation[view] [edit] [history] [purge]

This template wraps a math expression written in TeX code between <math>...</math> tags using the {{#tag:}} parser function magic word.

It further helps to avoid wrapping points at either end of expression that normally occurs with <math>...</math>, so avoiding being split from punctuation as would be normal for text.

Neither display="inline" nor TeX math mode \textstyle is set by this template. Where inline formatting is desired, use {{tmath|\textstyle ...}}.

Contents

  • 1 Usage
    • 1.1 Examples
    • 1.2 Wrapping behavior
    • 1.3 Use braces { and } with caution
    • 1.4 Uniform compatible formatting guideline
  • 2 See also

Usage

{{tmath|expression}}

Examples

  • {{tmath|a}} gives ⁠ a {\displaystyle a} {\displaystyle a}⁠
  • {{tmath|\pi}} gives ⁠ π {\displaystyle \pi } {\displaystyle \pi }⁠
  • {{tmath|x_0}} gives ⁠ x 0 {\displaystyle x_{0}} {\displaystyle x_{0}}⁠

The template is intended to be used for short LaTeX mathematical expressions like variables, and is useful for limiting awkward wrapping points. It is more cumbersome to use for equations or other expressions containing special signs that must be escaped or replaced, like the equal sign = with {{=}} and the vertical pipe | with \vert, \mid or {{!}}, and \| with \Vert:

  • {{tmath|E {{=}} mc^2}} gives ⁠ E = m c 2 {\displaystyle E=mc^{2}} {\displaystyle E=mc^{2}}⁠
  • {{tmath|x {{=}} {{!}} \vec x {{!}} }} gives ⁠ x = | x → | {\displaystyle x=|{\vec {x}}|} {\displaystyle x=|{\vec {x}}|}⁠
  • {{tmath|x = \Vert \vec x \Vert}} gives ⁠ x = ‖ x → ‖ {\displaystyle x=\Vert {\vec {x}}\Vert } {\displaystyle x=\Vert {\vec {x}}\Vert }⁠

Wrapping behavior

With {{tmath}} With <math>
Lorem ipsum dolor sit ⁠ amet {\displaystyle {\text{amet}}} {\displaystyle {\text{amet}}}⁠, consectetur adipiscing ⁠ elit {\displaystyle {\text{elit}}} {\displaystyle {\text{elit}}}⁠, ⁠ sed do eiusmod tempor incididunt ut labore et dolore magna aliqua {\displaystyle {\text{sed do eiusmod tempor incididunt ut labore et dolore magna aliqua}}} {\displaystyle {\text{sed do eiusmod tempor incididunt ut labore et dolore magna aliqua}}}⁠. Ut enim ad minim ⁠ veniam {\displaystyle {\text{veniam}}} {\displaystyle {\text{veniam}}}⁠, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Lorem ipsum dolor sit amet {\displaystyle {\text{amet}}} {\displaystyle {\text{amet}}}, consectetur adipiscing elit {\displaystyle {\text{elit}}} {\displaystyle {\text{elit}}}, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua {\displaystyle {\text{sed do eiusmod tempor incididunt ut labore et dolore magna aliqua}}} {\displaystyle {\text{sed do eiusmod tempor incididunt ut labore et dolore magna aliqua}}}. Ut enim ad minim veniam {\displaystyle {\text{veniam}}} {\displaystyle {\text{veniam}}}, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

See the difference? The punctuation stays. The block of math itself is still not amenable to line break, that we can't fix.

Use braces { and } with caution

Apart from using the {{(}} and {{)}} templates to get { and }, you may use the braces { and } as long as { is not preceded or followed by another {, and } is not preceded or followed by another }, e.g.

  • {{tmath|1= \zeta(2) = \frac{\pi^2}{6} }} parses (you added that space!) to ⁠ ζ ( 2 ) = π 2 6 {\displaystyle \zeta (2)={\frac {\pi ^{2}}{6}}} {\displaystyle \zeta (2)={\frac {\pi ^{2}}{6}}}⁠
  • {{tmath|1= \zeta(2) = \frac{\pi^2}{6}}} fails to parse (you forgot that space!), v.g. ⁠Failed to parse (syntax error): {\displaystyle \zeta(2) = \frac{\pi^2}{6} ⁠}
  • {{tmath|\frac{1}{ x^{2n+1} }}} parses (you added all those spaces!) to ⁠ 1 x 2 n + 1 {\displaystyle {\frac {1}{x^{2n+1}}}} {\displaystyle {\frac {1}{x^{2n+1}}}}⁠
  • {{tmath|\frac{1}{x^{2n+1 }}}} fails to parse (you forgot some of those spaces!), v.g. ⁠Failed to parse (syntax error): {\displaystyle \frac{1}{x^{2n+1} ⁠ }}

Uniform compatible formatting guideline

When converting between <math>...</math> and {{tmath|...}}, first adjusting the expression to be compatible with both can help. A guideline for such formatting is:

  • Do not use templates internally, such as {{=}}, {{!}}, {{(}}, etc.
  • Replace all pipe characters: | by \vert or \mid , and \| by \Vert .
  • Introduce a space between adjacent identical braces: replace all occurrences of {{ by { { and }} by } }
  • Ensure a space at the end – this removes the possibility that a trailing } will adjoin the closing braces of the {{tmath|...}}
  • Replace a display="inline" parameter with a leading \textstyle .
  • With these adjustments, it should be possible to interchange the tags <math>...</math> and a template {{tmath|1=...}}. Note the use of the parameter number 1= to avoid a problem with an equals sign in the expression. Any text, such as punctuation, that does not naturally form part of the expression should be moved out of the {{tmath|...}}.

See also

  • {{bigmath}}
  • {{math}}
  • {{mvar}}
  • v
  • t
  • e
Math templates
  • Functions
  • Numeral systems
Functions
  • elementary arithmetic
  • precision
  • val (value formatting)
  • percentage
Numeral systems
  • {{#invoke:BaseConvert|XtoY}}
  • binary
  • decimal2Base
  • hex2dec
  • hexadecimal
  • octal
  • quaternary
  • rn
  • roman
  • ternary
  • vigesimal
Conversions
convert many units (see: list)
cvt abbreviated {{convert}}
convinfobox {{convert}} for infoboxes
bbl to t barrels of oil to tonnes
long ton long hundredweights, quarters and pounds to kilograms;
long tons and hundredweights to pounds and metric tons
miles-chains miles and chains to kilometres linking "chains"
decdeg degrees, minutes, and seconds to decimal degrees
deg2dms decimal degrees to degrees, minutes, and seconds
deg2hms decimal degrees to hour angle (in hours, minutes, and seconds)
hms2deg hour angle (in hours, minutes, and seconds) to decimal degrees
inflation calculate inflation of Consumer Price Index-related prices
pop density population density in an area
track gauge railway track gauges
Notation and formatting
bigmath bigger font to match TeX \displaystyle (standalone formulas only) math short text-based formulas
mathcal [mathematical] calligraphic font; alternative to LaTeX \mathcal{...} tombstone symbol indicating the end of a proof
mvar individual italicized maths variables in normal text val measurement values, uncertainties and units
  • overline
  • underline
a line set above/below a sequence of characters vec various overarrows, underarrows, etc.
abs absolute values (paired vertical lines)
  • langle
  • rangle
  • angbr
  • angular brackets
  • bra-ket
  • braket
  • bra
  • ket
  • bra–ket notation
  • ldelim
  • rdelim
  • multiline delimiters (2–5 lines inclusive)
    ceil, floor calculations :mw:Help:#expr; formatting indicators ⌈3.14⌉, ⌊3.14⌋ (no calculation performed) pars parentheses that can be resized (∑)
    fraction slant fractions 3⁄5 (not for maths/science articles; use standing or upright fractions {{sfrac}} instead) sfrac "standing" or upright fractions ⁠3/5⁠ (use in maths/science articles instead of{{fraction}})
    intmath integral symbols
  • sub
  • sup
  • su
  • subscripts and superscripts
  • overset
  • underset
  • arbitrary characters/diacritics set above/below one another    
    tmath Wrap TeX in <math> tags
  • Boxes
  • Tags
  • Notices
  • BoxesTags
    • arithmetic operations
    • calculus
    • Infobox mathematical function
    • functions
    • metricate
    • undue precision
    • units attention
    • Category
    • Module:Math
    The above documentation is transcluded from Template:Tmath/doc. (edit | history)
    Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages.
    Add categories to the /doc subpage. Subpages of this template.
    Retrieved from "https://en.wikipedia.org/w/index.php?title=Template:Tmath&oldid=1299876955"
    Last edited on 10 July 2025, at 23:28

    Languages

      • العربية
      • বাংলা
      • Беларуская
      • Dansk
      • Ελληνικά
      • Español
      • فارسی
      • Galego
      • Bahasa Indonesia
      • ქართული
      • Bahasa Melayu
      • Português
      • Română
      • Српски / srpski
      • Svenska
      • தமிழ்
      • တႆး
      • తెలుగు
      • Türkçe
      • Українська
      • Tiếng Việt
      • 中文
      Wikipedia
      • Wikimedia Foundation
      • Powered by MediaWiki
      • This page was last edited on 10 July 2025, at 23:28 (UTC).
      • Content is available under CC BY-SA 4.0 unless otherwise noted.
      • Privacy policy
      • About Wikipedia
      • Disclaimers
      • Contact Wikipedia
      • Code of Conduct
      • Developers
      • Statistics
      • Cookie statement
      • Terms of Use
      • Desktop