Template talk:Fraction
![]() | To help centralise discussions and keep related topics together, the following pages redirect here: |
![]() | Template:Fraction is permanently protected from editing because it is a heavily used or highly visible template. Substantial changes should first be proposed and discussed here on this page. If the proposal is uncontroversial or has been discussed and is supported by consensus, editors may use {{edit template-protected}} to notify an administrator or template editor to make the requested edit. Usually, any contributor may edit the template's documentation to add usage notes or categories.
Any contributor may edit the template's sandbox. Functionality of the template can be checked using test cases. |
![]() | This template (Template:Frac) was considered for deletion on 1 June 2010. The result of the discussion was "keep". |
|
||
This page has archives. Sections older than 90 days may be automatically archived by Lowercase sigmabot III when more than 4 sections are present. |
Unwanted plus sign
[edit]Comment: I was unaware of the fore mentioned move until I noticed The Naked Gun film series article had fraction display issues (see its talk page discussion). Template {{Frac}} does not function the same since I last used it. Previously, I could display 331⁄3 by putting the whole number inside {{Frac|33|1|3}}
, or outside 33{{Frac|1|3}}
the template. Apparently, this has changed, and whole numbers must go outside the template, otherwise a plus sign +
appears in the middle of the fraction. I have adjusted the documentation to reflect this change. — CJDOS, Sheridan, OR (talk) 07:26, 9 August 2021 (UTC)
- There are some problems because the template now uses template styles. For example, see #Sfrac conflict with wikilinks above. That is not related to the move from "Frac" to "Fraction". I looked at The Naked Gun but I can't see a version in history which shows a problem. Please describe the problem and give a permalink or time/date so it can be found. Johnuniq (talk) 11:30, 9 August 2021 (UTC)
- @Johnuniq: The Talk page link is already shown. Article talk page describes the problem, and includes a link to when I began correcting the article. — CJDOS, Sheridan, OR (talk) 19:14, 9 August 2021 (UTC)
- As mentioned, it is known that using template styles will cause issues in some strange places. However, obviously I looked at the link you gave but after a couple of minutes of mucking around I cannot see a problem. Can you see one now (in history)? It is also known that using a template in a heading will have some bad effects and I don't think it should be done. Perhaps a sandbox demonstration of the problem would need to be created. If there was a precise example, it might be worth asking for opinions at the talk page of MOS:FRAC which does not seem to say anything about fractions in article titles or headings. By the way, that ping did not work, see Help:Notifications. Johnuniq (talk) 23:59, 9 August 2021 (UTC)
- Ping did not work? Strange,
{{Reply to|Johnuniq}}
should work. In any case, in the talk page for The Naked Gun, I said "in this edit" with a link to the edit history. That precise link is the first edit I performed after noticing a problem. As mentioned,{{Frac|33|1|3}}
should produce the expected output, but it's been quite a while since I last used it (no idea how long ago, but probably sometime this year). Instead, it sticks a plus sign+
in the middle of the fraction. This is demonstrated in my edit link, because {{Main}} under each of the § Films subheadings adds a plus sign (maybe this should be expected when the templates are nested; another editor had done this before I spotted it), but further down in § Main characters, it does it to one of bullet points (O. J. Simpson), and further down still, it does it in the § Reception tables (note, the preceding § links will open the specified page history, not the article as it is now). - That was the first edit I performed, in which Template:Frac was in the label of a link. In many of those edits, the link target used a backslash fraction (e.g.
''[[Naked Gun 33 1/3: The Final Insult|Naked Gun {{frac|33|1|3}}: The Final Insult]]''
) which causes a redirect to''[[Naked Gun 33⅓: The Final Insult]]''
, the ASCII fraction. So, I had replaced several instances of the backslash fraction with ASCII. I have in the past included the Integer within {{Frac}} without issue (as per the template's doc). As the plus sign+
did not initially appear, I did not expect it to appear when replacing a forward slash fraction with an ASCII fraction... but as you can see from the page history, it showed up. - I soon discovered the new errors, and performed a further edit to the article, moving the Integer outside of {{Frac}}, which removed all the unwanted plus signs
+
in the fractions. It still wasn't 100% right, as {{Frac}} nested within {{Main}} was displaying a forward slash fraction, rather than the expected output; an IP editor corrected this after me by replacing {{Frac}} within {{Main}} with ASCII. - The point I'm trying to make is that, Template:Frac is supposed to be able to accommodate the Integer within the template, and I previously haven't had any issues doing so (excluding hatnote nesting of {{Frac}}, which I had not seen done before). When I raised the concern, putting the Integer outside {{Frac}} removed the unwanted plus sign
+
. That's all I'm trying to say—I only meant to report the issue. Does the documentation require clarification about where Template:Frac should not be implemented? — CJDOS, Sheridan, OR (talk) 06:28, 10 August 2021 (UTC)- OK, now I see some examples. 14:41, 25 July 2021 shows "The Naked Gun 2+1⁄2: The Smell of Fear (1991)" as item 1.2 in the table of contents. That was caused by a section heading using
{{frac|2|1|2}}
that produced 2+1⁄2 rather than using Unicode characters. I see that the articles are titled with Unicode: The Naked Gun 2½: The Smell of Fear and Naked Gun 33⅓: The Final Insult. It might be best to put up with the fact that the typography is not brilliantly clear because it's the best that can be achieved in wikitext. Being consistent with the article titles seems desirable. I was confused by the link you gave earlier because it has examples of {{frac}} being removed near the start. Thanks for the report but I don't think anything is going to change in the template because those problems are a side-effect of using WP:TemplateStyles and probably should be worked around. Regarding whether the documentation should be updated to say when not to use the template, that would be desirable. See other reports on this page. The template shows 33+1/3 (using a vinculum instead of a slash) when the template knows the 33 is the integer portion of the number—the + suggests the value is the sum of 33 and one third. Copying the displayed fraction in your browser copies the +. A successful ping requires a new message and a new signature. Editing an existing message does not generate a notification. Johnuniq (talk) 07:46, 10 August 2021 (UTC)- "using Unicode characters" is not a good way to express the opposite of using a template because all characters (including the ones the template generates) could be referred to as "Unicode characters" (except ones that have not yet been included in the Unicode standard). Rather you should contrast by saying "using a single glyph / single glyphs". Spel-Punc-Gram (talk) 22:42, 18 April 2024 (UTC)
- OK, now I see some examples. 14:41, 25 July 2021 shows "The Naked Gun 2+1⁄2: The Smell of Fear (1991)" as item 1.2 in the table of contents. That was caused by a section heading using
- Ping did not work? Strange,
- As mentioned, it is known that using template styles will cause issues in some strange places. However, obviously I looked at the link you gave but after a couple of minutes of mucking around I cannot see a problem. Can you see one now (in history)? It is also known that using a template in a heading will have some bad effects and I don't think it should be done. Perhaps a sandbox demonstration of the problem would need to be created. If there was a precise example, it might be worth asking for opinions at the talk page of MOS:FRAC which does not seem to say anything about fractions in article titles or headings. By the way, that ping did not work, see Help:Notifications. Johnuniq (talk) 23:59, 9 August 2021 (UTC)
- @Johnuniq: The Talk page link is already shown. Article talk page describes the problem, and includes a link to when I began correcting the article. — CJDOS, Sheridan, OR (talk) 19:14, 9 August 2021 (UTC)
@Johnuniq: This has become a problem again because per Talk:Naked_Gun 33 1/3: The Final Insult#Requested move 12 July 2022, it was established that the Unicode character ⅓ is not safe for screen readers. The article was moved to Naked Gun 33 1/3: The Final Insult with a DISPLAYTITLE to make it use superscripts and subscripts. I have been using {{frac}} to make the display text for links to this article, resulting in the unwanted "+". Sudiani reverted one of these, complaining about the "+" (see diff). I was hoping the template could be fixed to eliminate the "+" or otherwise handle links better. Is that possible? If not, should I just redo all those links to use the actual title with "33 1/3"? -- Beland (talk) 18:29, 22 July 2022 (UTC)
- @Beland:It seems to work ok on the film's page but not sure why on the one that you changed (List of 1994 box office number ones in Italy) that it does not, hence why I reverted it for now Sudiani (talk) 18:40, 22 July 2022 (UTC)
- @Sudiani: That's because the "+" only appears when the {{frac}} is used in a link. -- Beland (talk) 18:47, 22 July 2022 (UTC)
- As a reminder to myself and anyone investigating in the future, {{fraction}} now uses WP:TemplateStyles and that does not work if the first use of {{fraction}} is in a piped link. For example, if a page contains the following (and no earlier usages of the template), the template styles will not work and the display will be corrupted (each will display as "33+1/3" with a fraction slash instead of the plain slash I have used for clarity here). The template works if the order is reversed. That is, the following would be fine:
[[Example|{{frac|33|1|3}}]] {{frac|33|1|3}}
If there is no earlier usage of the template, a crude workaround is to place the required templatestyles wikitext before the link. This works:{{frac|33|1|3}} [[Example|{{frac|33|1|3}}]]
Since the Naked Gun people are having fun with fractions, another solution would be to work out what wikitext is needed to display the required fraction without using template styles. Then that wikitext can either be copy/pasted or put in a dedicated template. I don't know what would be best. Johnuniq (talk) 23:55, 22 July 2022 (UTC)<templatestyles src="Fraction/styles.css"/>[[Example|{{frac|33|1|3}}]]
Thank you, Johnuniq. As a followup, I recently performed a test regarding fractions in section headings, due issues with the Floppy disk article. I will recreate the test as subsections below, to demonstrate three two methods of displaying fractions in section headings, and how the links appear in an address bar...
Fraction heading test 1¼
[edit]=== Fraction heading test 1¼ ===
Address bar: https://en.wikipedia.org/wiki/Template_talk:Fraction#Fraction_heading_test_1%C2%BC
Fraction heading test 21/2
[edit]=== Fraction heading test 2<sup>1</sup>/<sub>2</sub> ===
Address bar: https://en.wikipedia.org/wiki/Template_talk:Fraction#Fraction_heading_test_21/2
— CJDOS, Sheridan, OR (talk) 02:13, 12 November 2022 (UTC)
- Per MOS:NOSECTIONLINKS, the example heading
{{Frac|3|3|4}}
isn't permitted (template transclusion). I have commented out said section here. — CJDOS, Sheridan, OR (talk) 05:54, 13 November 2022 (UTC)
I have noted the workaround "33 {{frac|1|3}}". -- Beland (talk) 02:24, 15 August 2023 (UTC)
Template-protected edit request on 14 January 2024
[edit]![]() | This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Could the first line be split for readability of the template structure? That is, please replace the first line
<templatestyles src="Fraction/styles.css" /><span class="frac">{{#if:{{{3|}}}<!-- if 3
with
<templatestyles src="Fraction/styles.css" /><span class="frac"><!--
-->{{#if:{{{3|}}}<!-- if 3
—Quondum 20:28, 14 January 2024 (UTC)
Done – Jonesey95 (talk) 00:53, 16 January 2024 (UTC)
Signing (plus or minus)
[edit]Why does the Documentation section say "the optional integer (may be signed)" when it appears that all three arguments can be given a sign (which is displayed as expected)? Spel-Punc-Gram (talk) 22:45, 18 April 2024 (UTC)
- This template is rather simple and is just taking whatever inputs you give it and turning them into superscripts and subscripts. It does not actually understand the inputs. Eg,
{{fraction|this|is|{{pi}}}}
gives this+is⁄π . Be careful not to confuse the intent of the template (what we want it to do) with the current implementation of the template (what it actually does at the moment that might change in the future). Stepho talk 23:00, 18 April 2024 (UTC)
Why is this still being used for common fractions?
[edit]Okay, in 2024 are there really any browsers in use that can't display ½ or ¼? Can we make those fractions, at least, point to the characters? —Chowbok ☠ 02:27, 20 April 2024 (UTC)
- MOS:FRAC has the guidelines. Using this template is not required in all circumstances. It would probably not be desirable for this template to output one style for a third and a different style for a half. If ½ is wanted (and MOS:FRAC applies), just type that. Johnuniq (talk) 03:04, 20 April 2024 (UTC)