Template talk:Tmath
Behavior of parser functions [either extensions or not] when the parameter is not provided
[edit]The #tag
parser function extension returns 1
instead of {{{1}}}
when the parameter is not provided. Do all the parser functions and/or parser function extensions behave in this way? Just asking. — TentaclesTalk or ✉ mailto:Tentacles 15:26, 30 March 2016 (UTC)
Using magic words, parser functions [either extensions or not] and/or templates inside the tmath template
[edit]Should I mention (or not) on the doc page that one may use magic words, parser functions [either extensions or not] and/or templates inside the {{tmath}} template, with an example such as:
The code
{{tmath| \frac{1}{\zeta(2)} {{=}} \frac{6}{\pi^2} {{=}} {{#expr: 6 / (pi^2) }}\ldots }}
yields
-
Or is this discouraged? — TentaclesTalk or ✉ mailto:Tentacles 15:43, 30 March 2016 (UTC)
- You may see that parser functions are ignored ans stripped. So there is no point in using them.
-- [[User:Edokter]] {{talk}}
21:13, 30 March 2016 (UTC)
- The parser function [extension]
{{#expr: 6 / (pi^2) }}
used in the {{tmath}} example above yielded0.60792710185402
so it did work. — TentaclesTalk or ✉ mailto:Tentacles 23:31, 30 March 2016 (UTC)
- The parser function [extension]
Improving the template
[edit]This template documentation as the users above noted is downplaying its potential quite a bit in my opinion. Compared to using <math></math>
there's plenty of positives such as
- Allowing templates and semantic mediawiki properties inside it is a VERY strong feature. Example:
<math>{{#expr:{{CURRENTYEAR}} + 1}}</math>
yields Failed to parse (syntax error): {\displaystyle {{#expr:{{CURRENTYEAR}} + 1}}} , it should of course show which{{Tmath}}
successfully did. As the calculations imply; supporting templates, parser functions and SMW properties allows creating advanced math examples that will stay synchronized with the wiki even if the variables changes. - Controlling styles and background colors can easily be done in templates. Maybe not that useful for this wiki in particular.
The issue with equal signs isn't that big of a deal with named parameters, if it allowed the named parameter "formula":
{{TMath|formula= {{CURRENTYEAR}} + 1 = {{#expr: {{CURRENTYEAR}} + 1}} }}
And if you expand the template a bit to include {{NumBlk}}
and {{EquationRef}}
you can create numbered equations by just adding "nr=1" as a named parameter and then reference them with {{EquationNote}}
. Here's the code suggestion, taken from here:
{{#vardefine:math| {{#tag:math | \pagecolor[RGB]{15,15,15} \color[RGB]{163,141,109} {{{1|{{{formula|{\color{Red}error} }}}}}} | display="{{{display|}}}" | style="background-color:transparent; padding:0;" }} }} {{#if: {{{nr|}}} | {{NumBlk|1=:|2={{#var:math}}|3={{EquationRef|{{{nr}}}}}}} | {{#var:math}} }}
Remove \pagecolor[RGB]{15,15,15} \color[RGB]{163,141,109}
if it's not needed.--Illviljan (talk) 20:46, 22 January 2017 (UTC)
Not to print "1" in the case of empty argument
[edit]I think it is not necessary to print "1" in the case of empty argument for this template, so I add "|" in the end of it.
But it is reverted. What other friends think about this change (adding "|") in this template?
Thanks, Hooman Mallahzadeh (talk) 16:44, 27 September 2020 (UTC)
Oops
[edit]@Quondum: Oops. I mean, saying that it sprinkles |display= everywhere is not exactly how I would describe it (sure it makes sense on the #tag: level, but the real issue is <math display>
). Turns out that is not equivalent to <math>
: the original thing feeds {\displaystyle blah} to the render, while the new thing feeds just "blah".
I thought it's going to be okay because I only visually checked that it looked taller than the \textstyle version. Welp.
Anyways. I would still appreciate if this template can forward every attribute that <math>
accepts as a named parameter, but the sheer number of #if: requried is starting to scare me. Or perhaps I should just open a ticket on Phab so they simply do this nobreak thing on the output from the extension itself. --Artoria2e5 🌉 16:43, 21 June 2025 (UTC)
- Apologies for undoing multiple edits on the doc page. I thought I'd checked that it was only the specific part on the
|display=
parameter, but the other parts of the diff were off the bottom of my screen and I failed to scroll. Thanks for restoring your wrapping illustration. - Maybe we should see what it is that you're trying to do. My familiarity with
<math>
attributes admittedly does not extend beyond<math display="block">
and<math display="inline">
, so it seemed that the only real use would be optionally adding the\textstyle
, which can be done just as easily explicitly. You mention "every attribute that<math>
accepts as a named parameter" – what are these? - Getting the nobreak thing fixed properly makes sense to me; it is a pain that a workaround is needed. But that is orthogonal to this change, as I see it. —Quondum 17:06, 21 June 2025 (UTC)