Template:Tmath/doc

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 ...}}.

Usage

{{tmath|expression}}

Examples

  • {{tmath|a}} gives
  • {{tmath|\pi}} gives
  • {{tmath|x_0}} gives

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
  • {{tmath|x {{=}} {{!}} \vec x {{!}} }} gives
  • {{tmath|1= x = \Vert \vec x \Vert}} gives

Wrapping behavior

With {{tmath}} With <math>
Lorem ipsum dolor sit , consectetur adipiscing , . Ut enim ad minim , quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Lorem ipsum dolor sit , consectetur adipiscing , . Ut enim ad minim , 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
  • {{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
  • {{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.
  • Name the parameter |1= if the formula contains an equals sign (=). This removes the need to use the magic word {{=}}.
  • Replace all pipe characters: | by \vert or \mid , and \| by \Vert . This is clearer than using the magic word {{!}} since it doesn't mix wiki markup with TeX.
  • 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=...}}. Any text, such as punctuation, that does not naturally form part of the expression should be moved out of the {{tmath|...}}.

See also


Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.