Template talk:Chem

message: I was building similar functionality when I noticed this template. It seems some of the work on 
:Category:Nuclide templates
could be merged with this template into one set of templates. Reusing code reduces the time it takes to maintain these templates and maybe there are some features in one that could benefit the other and vice versa. For instance, I think this template could benefit from the automatic linking in NuclideTemplates (you specify only the element's name or symbol and the "link" argument and the right link for that element is automatically added).    — SkyLined (talk) 12:30, 27 November 2009 (UTC)
replies: text: There are a couple of things to sort out but I think it's very doable. JIMp talk·cont 06:30, 23 December 2010 (UTC)
thread_title:  NuclideTemplates 

message: Such uses as  and  do not work. I changed what I thought to be a bug, but this does not help. Incnis Mrsi (talk) 21:23, 28 February 2012 (UTC)
replies: text: You say the edits you made don't work.  I've reverted them (at least till we figure out what's going wrong). JIMp talk·cont 00:34, 29 February 2012 (UTC)

text: This is not actually a bug, though.  If you use  (i.e. no pipe between letters like in the sulphate example on the doc), everything should be fine. I guess we should make this more clear. JIMp talk·cont 04:35, 29 February 2012 (UTC)

text: However, if you must separate them, a double pipe, e.g. , will work. JIMp talk·cont 04:50, 29 February 2012 (UTC)
replies: text:  Thanks. I did not consider a possibility that such intricate code may be not ready to handle Symbol-Symbol sequences. Such intended syntax for, say, SO2 as  is absolutely counter-intuitive to me and undermines the legitimation of this template because makes future semantic-based customization unlikely. Why not recommend to use a double separation for this case? Incnis Mrsi (talk) 04:58, 29 February 2012 (UTC)
replies: text: I see where you're coming from. Yes, it is somewhat counter intuitive.  I'll see what can be done to remedy this. JIMp talk·cont 05:18, 29 February 2012 (UTC)
replies: text: I've completely rewritten the template.  The version in the sandbox handles .  I've also made an adjustment so that it will handle metastable isomers e.g. . JIMp talk·cont 05:55, 1 March 2012 (UTC)

text: This version has problems; Uranium#Aqueous chemistry, for example: fails on sup-tags. Alarbus (talk) 12:45, 1 March 2012 (UTC)
replies: text: Alarbus was referring to sup tags within the template parameter.  These actually shouldn't have been there; superscripting is automatic (one of the main points of the template).  I fixed that. The other problem was that it would stumble when there was non-numeric input to be superscripted (e.g. ).  That's also been fixed. JIMp talk·cont 16:35, 1 March 2012 (UTC)
thread_title:  Problem with CH3F and CH4 

message: →  but should be similar to Th(NO3)4 - see . --Redrose64 (talk) 22:38, 3 March 2012 (UTC)
replies: text: Fixed. JIMp talk·cont 16:23, 4 March 2012 (UTC)
replies: text: Square brackets work too thanks to Headbomb. JIMp talk·cont 16:24, 5 March 2012 (UTC)
replies: text:  Smashing. --Redrose64 (talk) 19:39, 5 March 2012 (UTC)
thread_title:  Parentheses 

message: Based on some edits on March 20, there appears to be a problem with how subscripts in formulas are displayed for some users. The specific example there is the "2" in  generated by . The editor who inserted the explicit  tag left the following note on my talkpage:
:Yeah, {{tchem| without the  tags is not causing my browser (Firefox 3.6.28 with a bunch of add-ons on Windows 2000) to render the formulae properly. It does render correctly in Chrome. I'm too security-conscious to even launch IE. St John Chrysostom Δόξατω Θεώ 17:52, 20 March 2012 (UTC)
replies: text: I tried disabling Noscript, Requestpolicy, Adblock, Tamperdata, and Ghostery (stuff that can potentially interfere with rendering using JS, CSS, etc., even though it's all set to allow Wikipedia's operation) and still receive the same result. I tried a clean install of Firefox 11.0 (ugh! what an interface! that's why I stick with 3.x.x) in process sandbox, with no add-ons. It renders correctly. On some formulae (it seems that H2O renders correctly, as does H2O2, but CH3, CH4 and TiO2 don't - maybe something to do with two letters back-to-back?). A clean install of 3.6.28 does not render correctly. The latest version of Chrome renders correctly as well. (So it's not my archaic Windows install - at least it doesn't seem to be). St John Chrysostom Δόξατω Θεώ 23:43, 21 March 2012 (UTC)
thread_title:  Subscripts not working 

message: if we had made this template to produce,
* simple reactions
* represent polymers
Now this template has no meaning than just being an alternative to the sup and sub syntax, I think. It might be complex and hard to do, but would be of great use. Vanischenu mTalk 11:46, 13 July 2012 (UTC)
replies: text: What  &  can't do is align the sub- & superscripts.  What exactly were you hoping for? JIMp talk·cont 06:02, 9 June 2013 (UTC)
thread_title:  It would have been more useful... 

message: Viewing 
:
in IE 9 the subscript "9" is much smaller than the "4".  It looks ugly.
—DIV (138.194.11.244 (talk) 00:49, 24 July 2012 (UTC)
replies: text: The template now uses  for all sub- & superscripts (instead of only where you have both). This should fix the problem. JIMp talk·cont 05:58, 9 June 2013 (UTC)
thread_title:  Inconsistent subscript size 

message: This template is wonderful (perhaps the only template in all Wikipedia that is actually good).  However it has a bad effect on line spacing, because the formulas come out a bit too tall. This problem does not occur with ordinary ...  See:
: Lorem ipsum blabla gallia omniaLorem ipsum blabla gallia omniaLorem ipsum blabla gallia omniaLorem ipsum  gallia omniaLorem ipsum blabla gallia omniaLorem ipsum blabla CH+ omniaLorem ipsum blabla gallia omnia
I can provide a screenshot if you can't see the problem above. (I am using Chrome with the default "vector" skin for Wikipedia.)Would it be possible to reduce the font size of sub/sup scripts, and/or push them closer together, and/or lie to the browser about the height of the result to avoid this problem? (I have just left this request on the  talk page, but perhaps it is just a matter of setting some parameter?)Thanks, and all the best, --Jorge Stolfi (talk) 01:04, 22 February 2013 (UTC)
replies: text: I don't think this template is that helpful.  I think sub and super script make more sense to the untrained reader than knowing this template.  And it messes up line spacing (I had to delete on in an article and do it the old fashioned way).  Kind of a solution looking for a problem.TCO (talk) 01:58, 7 June 2013 (UTC)
replies: text: It's nice if you are writing reactions (could use math text also), but definitely causes problems when in lined text.  (Like using math text in regular prose would.)TCO (talk) 19:57, 8 June 2013 (UTC)
replies: text: What this template does that can't be done simply with  and  is align the super- and subscripts.  This is done using  so if there's a problem to be fixed, it'll obviously have to be tackled over there. I'm afraid I can't really help much. My knowledge of the workings of this template only expends as far as its own subpages (i.e. not as far as the workings of ). JIMp talk·cont 05:42, 9 June 2013 (UTC)

text: Well, we can only hope they get it right someday.  Of course, in the meantime do we use the template and hope for the best, wait till things are fixed and then go through and start adding it or what?  JIMp talk·cont 07:01, 9 June 2013 (UTC)
replies: text: I would get rid of it.  It is OK only when in reactions (on separate lines).  But people are using it in regular text as if it were a convert template.  And the damage from messing up the line spacing, to the eye, is much more than SO42-.  Honest, people never even notice that being off.  I just went and culled all the tempates out of an article that I am sweating over.  They make it look worse.  Sorry, man.  :-(  TCO (talk) 07:29, 9 June 2013 (UTC)
thread_title:  Superscripts are a bit too tall 

message: This template break something for the wikipedia API. See [ http://en.wikipedia.org/w/api.php?action=query&prop=description&titles=Water&prop=extracts&exintro&explaintext&exsentences=10&format=xml query of the first sentence]. And query of the lead section. Yug (talk) 23:45, 17 October 2013 (UTC)
replies: text: Agreed.  the Chem template isn't properly parsing in the Wikipedia API.  It appears that in some cases, subscript markup is converted into line breaks. --  Preston stone (talk) 19:30, 4 December 2013 (UTC)
thread_title:  Wikipedia API 

message: In the article on eclampsia, the magnesium ion appears to absorb the following space,  like so.
Perhaps this effect is specific to my browser, which is IE.
99.247.1.157 (talk) 03:25, 16 December 2013 (UTC)
thread_title:  {{chem|Mg|2+}} 

message: How to write an electron? Instead of "e−" (or "e−"),  produces a very strange result "" (-e), and  produces "" (e−). — Mikhail Ryazanov (talk) 22:10, 20 December 2013 (UTC)
replies: text: ; Use , for an electron use  which gives . If a link is wanted add the parameter link=yes Christian75 (talk) 14:00, 5 February 2014 (UTC)
thread_title:  Electron? 

message: Maybe spacing problems can be resolved using subscript characters as ₁₂₃₄₅₆₇₈₉₀ instead of characters in subscript tag (1234567890), the same for superscript (¹²³⁴⁵⁶⁷⁸⁹⁰⁺⁻ instead of 1234567890+-)? --Sbisolo (talk) 09:55, 4 April 2014 (UTC)
thread_title:  Using subscript and superscript characters  

message: I undid the recent change to the font size for superscript characters; the change meant that linespacing is increased in text using this template.  To see an example, preview radiocarbon dating with the version I reverted from. Mike Christie (talk - contribs -  library) 17:02, 30 December 2014 (UTC)
thread_title:  Recent undo 

message: ::::::Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Using  - . Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
::::::Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Using  - H2SO4. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Tevildo (talk) 19:29, 25 August 2015 (UTC)
replies: text: It was fixed at the cost of too small font sizes, which makes it inconsistent and illegible. Using  has inherent spacing requirements, but should generally not be noticable (especially since the typography update). If you do notice increased line height, your default font may be at fault, or too small. -- User:Edokter  13:46, 28 February 2016 (UTC)
replies: text:  I see you reverted the font size change.  Take a look at radiocarbon dating, which looks to me much worse now; the line spacing is visibly erratic.  I'm using Vector on Chrome, if that makes a difference. Mike Christie (talk - contribs -  library) 16:15, 28 February 2016 (UTC)
replies: text: The more important issue is legibility. At default font sizes, 70% beccomes unreadable. What I could do is tweak the lineheight, asuming only numbers are used in the sub/sup values. But readability should not suffer because of a purely aesthetic reason. -- User:Edokter  18:59, 28 February 2016 (UTC)

text: I'm tweaking  to allow for a vertical-align parameter. Please stand by. -- User:Edokter  19:32, 28 February 2016 (UTC)
replies: text:  Are you still tweaking?  I have to say it still looks ugly to me.  Is there more that can be done? Mike Christie (talk - contribs -  library) 10:57, 1 March 2016 (UTC)
replies: text: Yes, but need a little help in LUA syntax. -- User:Edokter  19:24, 1 March 2016 (UTC)

text: That looks good.  Thank you!  Mike Christie (talk - contribs -  library) 17:31, 28 March 2016 (UTC)
thread_title:  Examples 

message: Why is the aligned style used () when so many other resources, as far as I've researched, don't (SO42-Gold Book)? Is there a standard form? Fizzwhiz (talk) 13:57, 11 November 2016 (UTC)
thread_title:  Right superscript and subscript alignment rationale 

message: How do I write _{+1}^0\beta (i.e. a positively charged beta particle) with this template? I've tried  and  but they result in β and β (i.e. the same, incorrect notation). —Kri (talk) 14:58, 25 June 2017 (UTC)
replies: text: Looking at the source code, chem tests for the mass number being higher than the atomic number. Instead, you could try β --> β , which is what chem uses anyway.  Stepho  talk  03:06, 2 January 2022 (UTC)
thread_title:  How to write this? 

message: The documentation says to not use this template in citations.  triggers dire warnings when used with  but chem doesn't. Is this a solved problem that is waiting for documentation to catch-up or is it a hidden problem waiting to catch us out?  Stepho  talk  03:11, 2 January 2022 (UTC)
replies: text: It is still a problem as far as I can tell; if you render  the COinS (starting span title="ctx_ver=) contains a lot of mangled HTML from this template which shouldn't be there. User:GKFXtalk 19:09, 27 November 2022 (UTC)
thread_title:  COinS 

message: Tried this:  or  It did not go well. Help! Lfstevens (talk) 20:41, 15 June 2022 (UTC)
replies: text: You are meant to use the chemical symbols, not the chemical names. Try  or  to give  or  .  Stepho  talk  11:34, 16 June 2022 (UTC)
thread_title:  Isotopes 

message: In nitromethane, when I triple-click to section the entire lead paragraph, an instance of {chem} is dividing the paragraph into three pieces: before chem, inside chem, and after chem. 
This particular box has a somewhat outdated FF installed, but use of triple-click is near universal across many browsers and OSes and it's rare in my experience to see this not work as expected. — MaxEnt 21:20, 19 August 2022 (UTC)
thread_title:  Breaking triple-click mouse paragraph selection  

message: , if I understand your edits well , should we declare this template /use formally? I could support. Or are there technical/usage issues to be resolved? DePiep (talk) 08:13, 26 November 2022 (UTC)
replies: text: There are a couple of outstanding issues before I would look to fully deprecate . It doesn't stack super- and subscripts if they are done with the syntax for letters () and there is a MediaWiki bug with using it in links (phab:T200704, although you can use the link= parameter as a substitute). In most other cases yes I would switch to . User:GKFXtalk 18:58, 27 November 2022 (UTC)
replies: text: ok thx. DePiep (talk) 19:01, 27 November 2022 (UTC)
thread_title:  deprecated? 

message: I’ve just come across multiple issues related to this template while browsing using iOS Safari, both in Google’s reprinting of Wikipedia content in infoboxes (e.g. a search for “sulfite” returns a Wikipedia infobox for Sulfite beside Google search results), but also on the Wikipedia pages themselves.  Yes, Google is not Wikipedia, but the content they are reproducing comes directly from Wikipedia, and though I’m not privy to Wikipedia’s web analytics, I would wager that a huge amount of contemporary traffic comes straight from Google, specifically the Wikipedia infoboxes I am talking about, and therefore the preview of content that is shown in these boxes is of utmost importance to the project.  In case it is important to know, I have observed these unexpected and unwanted behaviors while using an iPad with a slightly older version of iOS/iPadOS, 15.6.1.  I have yet to test this in other browsers, but as you may gather from the behaviors described below, this is almost certainly also occurring in all browsers, because it must be related to the way the template itself is encoded into display content. 
Actual Behavior
# (image) The charge/superscript appears after the final subscript in chemical formulae of ions displayed in Google infoboxes that reprint content from Wikipedia.  Additionally, there appears to be extra space between the superscript and subscript.  I thought the spacing issue may be a bug either on Google’s end or on Apple’s in iOS Safari, but as explained below in (3), the space is present when copying /pasting directly from Wikipedia as well.  Thus both the incorrect order in which the superscripts/subscripts appear and the extra space is obviously encoded incorrectly in the first place, in the Wikipedia content itself. The backwards ordering is exacerbated by the presence of this extra space, which has the charge/superscript directly adjacent to the final element, with that element’s subscript orphaned and distanced from it.
# (image) Copying and pasting a chemical formula of an ion from Wikipedia content reproduced in Google’s infoboxes results in a backwards ordering of charge/superscript and any formula-final subscript, along with the aforementioned extra space. (e.g. copying and pasting the chemical formula for the sulfite ion gives “SO²⁻ ₃”).
# (image) Even worse, copying and pasting the chemical formula of an ion directly from its Wikipedia article results in both the same backwards ordering of charge/superscript followed by formula-final subscript (which proves that the template itself on Wikipedia is encoding the order of formula-final subscripts and charge/superscript incorrectly, and it isn’t merely a rendering issue on Google or iOS Safari—even the extra space is present when pasting directly from Wikipedia), but additionally the complete loss of the subscripts themselves, such that they cannot be copied and pasted at all (e.g. copying and pasting the chemical formula for the sulfite ion directly from Wikipedia text gives the terrible result “SO2− 3”). I feel that users would hope and expect that Wikipedia be a resource they can trust and successfully use to quickly copy a chemical formula to use in their own work, for example a student who needs to write a science paper and can’t be bothered, doesn’t have the capability, or doesn’t know how to manually format chemical formulae on whatever device they happen to be using.
Expected Behavior
Both the display and the result of copying and pasting chemical formulae accessed from Wikipedia content using this template should be accurate, standardized, and consistent, no matter where the Wikipedia content was originally displayed.  The order, spacing, and superscripts/subscripts should correct and consistent.
Recommended Fix
The template itself, by the order in which it accepts arguments, seems to acknowledge the proper order of formula-final subscript followed by an ion’s charge/superscript, so it is clear that it is rather the way in which the template is being parsed and encoded to display text, whether that is by using Unicode superscripts/subscripts or / HTML tags, that is the actual problem.  However it is being rendered should be reversed, and the extra space removed.  Also, if this is a problem for ions, I imagine there are related problems with this template for other types of chemical formulae that end in both subscripts and superscripts.
Hermes Thrice Great (talk) 07:02, 31 May 2023 (UTC)
thread_title:  Ionic Formluae: Rendering and Copy/Paste Issues (using iOS Safari, but likely in all browsers) 

message: Isn't the IUPAC recommendation to stagger the charges? e.g. SO42-
See section 2.10.1 iv p51 of IUPAC (2007) Quantities, Units and Symbols in Physical Chemistry, Third Edition (The “Green Book”)
https://iupac.org/wp-content/uploads/2019/05/IUPAC-GB3-2012-2ndPrinting-PDFsearchable.pdf
Ewen (talk) 06:57, 19 February 2024 (UTC)
thread_title: Staggered Charges