Jump to content

Template talk:Chem

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
(Redirected from Template talk:Chem/sandbox)

Protection & charges

[edit]

This template should be protected soon, since almost 150 articles allready use it. Also, I would like to have a feature for writing charges (something like if you start the number with a + or a -, it will put it automatically as sup instead of sub). Or possibly add another option such as the link one, say charge, which will come automatically at the end as a superscript. Thanks, and great template. Nergaal (talk) 04:49, 30 January 2008 (UTC)[reply]

There's a version in the sandpit which can handle charges. If there is no objection, I'll put it in after a bit of testing. It can also handle atomic number & mass number. P.S. not if it starts but if it ends with a + or - (hyphen not a minus sign).
*{{chem/sandbox|H|2|O}}
*{{chem/sandbox|2|H|2|O}}

*{{chem/sandbox|H|3|O|+|link=hydronium}}
*{{chem/sandbox|1|2|A}}

*{{chem/sandbox|1|A}}
*{{chem/sandbox|14|2|A|3}}

*{{chem/sandbox|1|A|3}}
*{{chem/sandbox|1|2|A|3|2+}}

*{{chem/sandbox|1|A|3|-}}
*{{chem/sandbox|A|1|B|2|C|3|D|4|E|5|F|6|G|7|H|8|I|9|J|10}} 

*{{chem/sandbox|A|1|B|2|C|3|D|4|E|5|F|6|G|7|H|8|I|9|J}} 
*{{chem/sandbox|A|1|B|2|C|3|D|4|E|5|F|6|G|7|H|8|I|9}} 

*{{chem/sandbox|A|1|B|2|C|3|D|4|E|5|F|6|G|7|H|8|I}} 
*{{chem/sandbox|A|1|B|2|C|3|D|4|E|5|F|6|G|7|H|8}} 

*{{chem/sandbox|A|1|B|2|C|3|D|4|E|5|F|6|G|7|H}} 
*{{chem/sandbox|A|1|B|2|C|3|D|4|E|5|F|6|G|7}} 

*{{chem/sandbox|A|1|B|2|C|3|D|4|E|5|F|6|G}} 
*{{chem/sandbox|A|1|B|2|C|3|D|4|E|5|F|6}} 

*{{chem/sandbox|A|1|B|2|C|3|D|4|E|5|F}} 
*{{chem/sandbox|A|1|B|2|C|3|D|4|E|5}} 

*{{chem/sandbox|A|1|B|2|C|3|D|4|E}} 
*{{chem/sandbox|A|1|B|2|C|3|D|4}} 

*{{chem/sandbox|A|1|B|2|C|3|D}} 
*{{chem/sandbox|A|1|B|2|C|3}} 

*{{chem/sandbox|A|1|B|2|C}} 
*{{chem/sandbox|A|1|B|2}} 

*{{chem/sandbox|A|1|B}} 
*{{chem/sandbox|A|1}}

*{{chem/sandbox|A}} 
  • H
    2
    O
  • 2
    H
    2
    O
  • H
    3
    O+
  • 2
    1
    A
  • 1
    A
  • 14
    2
    A
    3
  • 1
    A
    3
  • 2
    1
    A2+
    3
  • 1
    A
    3
  • A
    1
    B
    2
    C
    3
    D
    4
    E
    5
    F
    6
    G
    7
    H
    8
    I
    9
    J
    10
  • A
    1
    B
    2
    C
    3
    D
    4
    E
    5
    F
    6
    G
    7
    H
    8
    I
    9
    J
  • A
    1
    B
    2
    C
    3
    D
    4
    E
    5
    F
    6
    G
    7
    H
    8
    I
    9
  • A
    1
    B
    2
    C
    3
    D
    4
    E
    5
    F
    6
    G
    7
    H
    8
    I
  • A
    1
    B
    2
    C
    3
    D
    4
    E
    5
    F
    6
    G
    7
    H
    8
  • A
    1
    B
    2
    C
    3
    D
    4
    E
    5
    F
    6
    G
    7
    H
  • A
    1
    B
    2
    C
    3
    D
    4
    E
    5
    F
    6
    G
    7
  • A
    1
    B
    2
    C
    3
    D
    4
    E
    5
    F
    6
    G
  • A
    1
    B
    2
    C
    3
    D
    4
    E
    5
    F
    6
  • A
    1
    B
    2
    C
    3
    D
    4
    E
    5
    F
  • A
    1
    B
    2
    C
    3
    D
    4
    E
    5
  • A
    1
    B
    2
    C
    3
    D
    4
    E
  • A
    1
    B
    2
    C
    3
    D
    4
  • A
    1
    B
    2
    C
    3
    D
  • A
    1
    B
    2
    C
    3
  • A
    1
    B
    2
    C
  • A
    1
    B
    2
  • A
    1
    B
  • A
    1
  • A
It's working. JIMp talk·cont 00:42, 15 July 2009 (UTC)[reply]

No-subscript (implied 1) breaks rest of formula

[edit]

I just noticed someone correcting mis-rendering on noble gas. Having to play special games to make the formula display correctly goes against the point of having the template to do it automatically. Say we want "XeF8". The page previously had {{chem|Xe||F|8}}. I assume that worked at one time.[cite needed] But now the result of that is just "Xe". None of the other likely chemically correct approaches work either: {{chem|Xe|F|8}} breaks the template badly, but one shouldn't expect it to work once one reads the template docs, and {{chem|Xe|1|F|8}} actually displays the 1, which again makes sense with respect to parsing.

The "solution" was {{chem|XeF|8}}, but that's weird from a chemistry standpoint. "XeF" isn't anything real except a text string (suppose some day we want to enable auto-linking to each element's webpage?). Is it possible to make {{chem|Xe||F|8}} work correctly? The template syntax appears to use an undefined parameter to indicate the end of the formula...could it look ahead a second position as well. Or could fix {{chem|Xe|1|F|8}} by having subscript be omitted if it's "1" (which could be over-ridden by some allsubscripts=yes template parameter if there are cases where one wants to see it).

I reverted it to the previous setup. Nergaal (talk) 22:56, 16 July 2009 (UTC)[reply]
Hmm, was it intended for every atom to be specifically delineated in this manner? Perhaps I came late to the scene, but I had assumed that the formula only needed to be separated when subscripts (or superscripts) are needed, i.e., {{chem|CH|3|COOH}} rather than {{chem|C|H|3|C|O|O|H}}, which seems to be a very cumbersome way to type a formula. Besides, I question the value of autolinking every element in a formula, especially if the same elements occur multiple times (IMHO that would qualify as a case of WP:overlink).—Tetracube (talk) 01:02, 17 July 2009 (UTC)[reply]
Linking is not necessary. The problem with Xe||F|4 typw formulas is that this template was started quite a while ago and that way worked well; so in many instances it is used like that. Is it hard to fix that? Can't you say to ignore the fields that have nothing in them? Nergaal (talk) 01:38, 17 July 2009 (UTC)[reply]
I don't know how hard it is to fix that, since I wasn't the one who made the changes. Just sayin' that many articles use the template the other way, including some that are now broken because they use the new superscript feature. Maybe User:Jimp could fix the new version of the template to ignore empty arguments, then we'll both be happy. :-)—Tetracube (talk) 15:46, 17 July 2009 (UTC)[reply]
Linking indeed is not necessary, was more of a "future idea" supporting why I thought keeping it "chemistry-like" was worthwhile. Another future-feature that relies on keeping each element distinct is the ability to automatically color each one using standard colors (a style used in some infoboxes). Again, "I wouldn't want it that way in many cases" and I don't think the limited present us of this format makes it worth implementing in such a potentially widely used template. DMacks (talk) 19:43, 18 July 2009 (UTC)[reply]

XeF
8

It seems to be fixed. I'm putting the new version in before we get people wondering what's going on. JIMp talk·cont 17:17, 17 July 2009 (UTC)[reply]

sweet! Nergaal (talk) 17:53, 17 July 2009 (UTC)[reply]
I saw that the new addition is a minor one; I am pretty sure it does not fix all the instances: I remember putting myself formulas like "{chem|C|x|H|y|N||O|}". Can you make sure the instances get fixed for all empty spots in use? Nergaal (talk) 18:01, 17 July 2009 (UTC)[reply]
Or request a bot to fix those uses. Nergaal (talk) 18:02, 17 July 2009 (UTC)[reply]
Here are some tests:
HSO
4
H
2
PO2−
4
(NH+
4
)
3
PO
4
(CH
3
NH+
3
)
2
SO2−
4
NH+
3
CH
2
CO
Looks OK to me. Thanks Jimp!—Tetracube (talk) 18:32, 17 July 2009 (UTC)[reply]

The new addition you saw was a minor one. The dozen or so which you didn't see were also minor. As for linking individual elements, {{chem|[[Hydrogen|H]]|2|[[Oxygen|O]]}} does a fine job. Optionally colouring the elements in standard colours is also possible. As for the case of using lower case letter in place of numbers, I'm afraid it would probably be best to fix these by bot. It's not that it's not possible to accommodate this; the software can tell a lower case from an upper case & so could treat the lower case as a plain number. The problem is that if we have {{chem|C|x|H|y}} give us "CxHy", then people are going to expect {{chem|Fe|a+}} to give "Fea+" and come here complaining that the template is broken when they get "Fea+" (we can't read the "+" after a letter, same goes for a "-") ... then there's A
Z
X. JIMp talk·cont 09:41, 25 July 2009 (UTC)[reply]

Make sure these tips go into the documentation of the template. Nergaal (talk) 16:52, 25 July 2009 (UTC)[reply]
Is there a way to make italicized subscripts (e.g. {{chem|Si|''n''|O|2''n''}})? Last I checked, this doesn't produce the expected result.—Tetracube (talk) 17:17, 27 July 2009 (UTC)[reply]
It's working. Si
n
O
2n
JIMp talk·cont 20:09, 29 July 2009 (UTC)[reply]
Thanks!!—Tetracube (talk) 14:35, 30 July 2009 (UTC)[reply]

Not quite working with italicized subscripts

[edit]

The formula S2−
n−1
isn't quite working: S2−
n−1
. No idea how to fix it, though. Jimp? :-)—Tetracube (talk) 00:03, 18 September 2009 (UTC)[reply]

Hmm, the above formula is now working, but something seems to have been broken in Tetrafluoroammonium (template error halfway down the article).—Tetracube (talk) 16:56, 23 September 2009 (UTC)[reply]

Is it working all right now? JIMp talk·cont 21:06, 24 September 2009 (UTC)[reply]

Let's see:
Si4−
n+1
Sim-
n+1
Sim+
2
Si4+
2m
Si
n+m
O2−
Hmm, better than before, for sure, but not quite there yet. The last case is messed up; and also, variable charges like Sin+ aren't working, with or without simultaneous subscripts (is it too hard to do variable charges?).—Tetracube (talk) 21:48, 24 September 2009 (UTC)[reply]

NuclideTemplates

[edit]

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)[reply]

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)[reply]

IE6 support?

[edit]

Someone using the very old and antiquated IE6 browser noted that simultaneous sub/superscripts (like SO2−
4
) don't show up correctly
. Any hope of making this work? Or is IE6 just too outdated and too non-standards-compliant?—Tetracube (talk) 00:13, 1 April 2010 (UTC)[reply]

That's probably me you're talking about. But IE 7 did not come out until 2006 and IE 6 still runs on 29% of the computers out there, so it's not like this is just me, the last holdout: [1] IE 6 is being killed off slowly by Twitter and a videosites that don't support it any more (as of last month) but I think it's completely ridiculous that I have to give it up because somebody decided some new chem template on Wikipedia looks "slightly better" than using the simple wiki-markup down at the bottom of your screen that we all already know how to use. That's madness. And why yes, I can hope that the next version of Windows doesn't screw up my files the way Vista did. Or I can change to some other browser in which I cannot read all my old email, which I had the bad fortune (due to not having a TIME MACHINE) to have sent and recieved with MS Outlook, way back when that was the best email program. So I'll have to upgrade and lose stuff at some point, but I'm not going to do it because somebody decided some weenie templates on Wikipedia were "a little cooler", and forgot to make them backwards compatible. The "dusty child in Africa" really doesn't appreciate this. Oh, wait-- I forgot. He's running the latest version of Ubuntu, right? Or at least IE 8. SBHarris 21:43, 21 April 2010 (UTC)[reply]
That wasn't you I was talking about (it was another user who encountered the same problem), but the problem stands: IE6 doesn't properly display whatever it is the physics template is being used to do that simultaneous super/subscript thingy. I think it looks neat when it does work, but we really should implement a fallback mechanism so that it doesn't fail horribly when it doesn't work. Whatever happened to graceful degradation in HTML and all that?—Tetracube (talk) 16:33, 22 April 2010 (UTC)[reply]
I have just discovered the same problem. This is serious. It means that anyone using a system that they are not allowed to update will get the wrong formulas. Q Science (talk) 21:16, 20 December 2010 (UTC)[reply]
  • The superscript output for parameter {3} is supposed to occur in Template:Su as parameter {p}, but only the subscript output for parameter {2} as {b} is appearing, such as "4". As a quick fix, I can edit Template:Su to display parameter {p} as a superscript in typical wiki-format:
<sup><span style="font-size:98%">{{{p|super}}}</span></sup>
Using the font-size as 98% will match the font size of the subscript "4" which seems like a logical fix. The result will appear as: "SO
4
2-. I realize that some prefer the aligned superscript+subscript format, but it does not work in IE6. Are there any objections to supporting users of Internet Explorer 6 with this change? -Wikid77 03:24, 21 December 2010 (UTC)[reply]
Here's one hearty vote of encouragement! It looks fine to me. Now if they should just fix the fonts, so that IE6 users see the correct rams-horn upsilon (ϒ) as a letter that is different from a Y, without having to resort to LaTeX. SBHarris 03:45, 21 December 2010 (UTC)[reply]
{{su}} is used by many other templates, please do not make random changes to it without checking the consequences.     — SkyLined (talk) 10:02, 22 December 2010 (UTC)[reply]
The whole point of using {{su}} here was to align the subscripts and superscripts. I think that's the whole point of {{su}}'s existence. JIMp talk·cont 01:38, 23 December 2010 (UTC)[reply]
This issue has been resolved in {{su}}, see the talk page for details.     — SkyLined (talk) 08:40, 23 December 2010 (UTC)[reply]

Problem with CH3F and CH4

[edit]

Such uses as CH
3
F
and CF
4
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)[reply]

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)[reply]
This is not actually a bug, though. If you use {{chem|CH|3|F}} (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)[reply]
However, if you must separate them, a double pipe, e.g. {{chem|C||H|3|F}}, will work. JIMp talk·cont 04:50, 29 February 2012 (UTC)[reply]
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 {{chem|SO|2}} 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)[reply]
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)[reply]
I've completely rewritten the template. The version in the sandbox handles {{chem|C|H|3|F}}. I've also made an adjustment so that it will handle metastable isomers e.g. {{chem/sandbox|58m|27|Co}}58m
27
Co
. JIMp talk·cont 05:55, 1 March 2012 (UTC)[reply]
This version has problems; Uranium#Aqueous chemistry, for example: fails on sup-tags. Alarbus (talk) 12:45, 1 March 2012 (UTC)[reply]
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. Sim+
2
). That's also been fixed. JIMp talk·cont 16:35, 1 March 2012 (UTC)[reply]

Parentheses

[edit]

{{chem|Th(NO|3|)|4}}Th(NO
3
)
4
but should be similar to Th(NO3)4 - see recent edit to Thorium. --Redrose64 (talk) 22:38, 3 March 2012 (UTC)[reply]

Fixed. JIMp talk·cont 16:23, 4 March 2012 (UTC)[reply]
Square brackets work too thanks to Headbomb. JIMp talk·cont 16:24, 5 March 2012 (UTC)[reply]
Thank you Smashing. --Redrose64 (talk) 19:39, 5 March 2012 (UTC)[reply]

Subscripts not working

[edit]

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 H
2
O
generated by {{chem|[[hydrogen|H]]|<sub>2</sub>|[[oxygen|O]]}}. The editor who inserted the explicit <sub> tag left the following note on my talkpage:

Yeah, {{tchem| without the <sub></sub> 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)[reply]

The results look correct for me (Firefox 11.0 OS X, and also tried Firefox 3.6.28 (an X11 manual build) on OS X). The actual subscripting happens via {{su}}, which uses small fontsize and shifted baseline rather than "actual" HTML subscript, so maybe simply a stylesheet platform-portability issue (or conflict with third-party browser extensions? DMacks (talk) 15:06, 21 March 2012 (UTC)[reply]

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)[reply]

It would have been more useful...

[edit]

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)[reply]

What <sub></sub> & <sup></sup> can't do is align the sub- & superscripts. What exactly were you hoping for? JIMp talk·cont 06:02, 9 June 2013 (UTC)[reply]

Inconsistent subscript size

[edit]

Viewing {{chem|H|9|O|4|+}}

H
9
O+
4

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))[reply]

The template now uses {{su}} 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)[reply]

Superscripts are a bit too tall

[edit]

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 <sup>...</sup> See:

Lorem ipsum blabla gallia omnia
Lorem ipsum blabla gallia omnia
Lorem ipsum blabla gallia omnia
Lorem ipsum CH+
3
gallia omnia
Lorem ipsum blabla gallia omnia
Lorem ipsum blabla CH+ omnia
Lorem 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 {{su}} 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)[reply]

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)[reply]
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)[reply]
What this template does that can't be done simply with <sup></sup> and <sub></sub> is align the super- and subscripts. This is done using {{su}} 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 {{su}}). JIMp talk·cont 05:42, 9 June 2013 (UTC)[reply]

I get that, that is what it does. But it messes up the line spacing. That is a much worse reading faux pas than SO42-. People type all the time in Word or the like and never notice an issue with it. This template is like cramming LaTex into regular prose lines. You can't do it. Needs to be on a separate line. Well, if you keep it there, then fine.

Actually part of the main problem is that Wiki has such tight line spacing from line to line and then between paras. Look how much nicer the space is between paras in edit mode as compared to display mode. This, I think, is similar to the way over-tiny font. It is because Wikipedia thinks it makes them look smarter.TCO (talk) 06:43, 9 June 2013 (UTC)[reply]

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)[reply]
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)[reply]

In the subtemplate {{su}} of {{chem}}, I have changed the default sub/superscript size to 70% from 85%, eliminating the extra line spacing. Also fixed passing the fontsize parameter, in case this appears too small for other applications. −Woodstone (talk) 09:04, 22 July 2013 (UTC)[reply]

Wikipedia API

[edit]

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)[reply]

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)[reply]

Mg2+

[edit]

In the article on eclampsia, the magnesium ion appears to absorb the following space, Mg2+
like so.
Perhaps this effect is specific to my browser, which is IE.
99.247.1.157 (talk) 03:25, 16 December 2013 (UTC)[reply]

Electron?

[edit]

How to write an electron? Instead of "e" (or "e"), {{chem|e|-}} produces a very strange result "-
e
" (-
e
), and {{chem|e||-}} produces "e

" (e

). — Mikhail Ryazanov (talk) 22:10, 20 December 2013 (UTC)[reply]

Mikhail Ryazanov; Use {{Subatomic particle}}, for an electron use {{Subatomic particle|Electron}} which gives
e
. If a link is wanted add the parameter link=yes Christian75 (talk) 14:00, 5 February 2014 (UTC)[reply]

Using subscript and superscript characters

[edit]

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)[reply]

Recent undo

[edit]

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)[reply]

Line spacing?

[edit]

This template still seems to have the problems with line spacing mentioned in the above discussions - see, for example, Tungsten carbide. Have there been any recent changes that might have reintroduced the problem, or was the problem not fixed in the first place? I'm seeing the issue in both Monobook and Vector, using IE11 and Chrome. Tevildo (talk) 19:18, 25 August 2015 (UTC)[reply]

Pinging @Jimp and Woodstone as active contributors. Tevildo (talk) 22:14, 30 August 2015 (UTC)[reply]

Examples

[edit]
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 {{chem}} - H
2
SO
4
. 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 <sub> - 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)[reply]

I thought it was fixed some time ago but if not, the problem is probably with {{su}}. Jimp 06:28, 9 September 2015 (UTC)[reply]

It was fixed at the cost of too small font sizes, which makes it inconsistent and illegible. Using {{su}} 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]] {{talk}} 13:46, 28 February 2016 (UTC)[reply]
@Edokter: 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)[reply]
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]] {{talk}} 18:59, 28 February 2016 (UTC)[reply]
I'm tweaking {{su}} to allow for a vertical-align parameter. Please stand by. -- [[User:Edokter]] {{talk}} 19:32, 28 February 2016 (UTC)[reply]
@Edokter: 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)[reply]
Yes, but need a little help in LUA syntax. -- [[User:Edokter]] {{talk}} 19:24, 1 March 2016 (UTC)[reply]

@Mike Christie: Should be fixed now. -- [[User:Edokter]] {{talk}} 17:05, 28 March 2016 (UTC)[reply]

That looks good. Thank you! Mike Christie (talk - contribs - library) 17:31, 28 March 2016 (UTC)[reply]

Right superscript and subscript alignment rationale

[edit]

Why is the aligned style used (CO2−
3
) when so many other resources, as far as I've researched, don't (SO42-[1])? Is there a standard form? Fizzwhiz (talk) 13:57, 11 November 2016 (UTC)[reply]

Prospects for adding a latex or readable text option?

[edit]

A latex option would be pretty obvious:

{chem|H|2|O|latex=true} → < math>H_2 O < /math> →

A readable text option would be:

{chem|H|2|O|text=true} → H Subscript 2 O

I'm not going to touch it unless I get a go-ahead. Is this an acceptable idea?

Akiva.avraham (talk) 12:35, 15 November 2016 (UTC)[reply]

A more appropriate tag than <math> for using LaTeX would be <chem>. For example:
<chem>H_2O</chem>
while
<math>H_2O</math>.
See Help:Displaying a formula#Chemistry. —Kri (talk) 15:23, 25 June 2017 (UTC)[reply]

How to write this?

[edit]

How do I write (i.e. a positively charged beta particle) with this template? I've tried {{chem|0|+1}}β and {{chem|+1|0}}β but they result in +1
0
β and +1
0
β (i.e. the same, incorrect notation). —Kri (talk) 14:58, 25 June 2017 (UTC)[reply]

Looking at the source code, chem tests for the mass number being higher than the atomic number. Instead, you could try {{su|p=0|b=+1|a=r}}β --> 0
+1
β , which is what chem uses anyway.  Stepho  talk  03:06, 2 January 2022 (UTC)[reply]

COinS

[edit]

The documentation says to not use this template in citations. {{chem2}} triggers dire warnings when used with {{cite}} 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)[reply]

It is still a problem as far as I can tell; if you render {{cite web|title={{chem|H|2|O}}}} 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)[reply]

Isotopes

[edit]

Tried this: thorium
232
or uranium
238
It did not go well. Help! Lfstevens (talk) 20:41, 15 June 2022 (UTC)[reply]

You are meant to use the chemical symbols, not the chemical names. Try {{Chem|232|Th}} or {{Chem|238|U}} to give 232
Th
or 238
U
.  Stepho  talk  11:34, 16 June 2022 (UTC)[reply]

Breaking triple-click mouse paragraph selection

[edit]

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)[reply]

deprecated?

[edit]

GKFX, if I understand your edits well [2], should we declare this template {{Deprecated}}/use{{Chem2}} formally? I could support. Or are there technical/usage issues to be resolved? DePiep (talk) 08:13, 26 November 2022 (UTC)[reply]

There are a couple of outstanding issues before I would look to fully deprecate {{chem}}. It doesn't stack super- and subscripts if they are done with the syntax for letters ({{chem2|X+_{n} }}X+n) 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 {{chem2}}. User:GKFXtalk 18:58, 27 November 2022 (UTC)[reply]
ok thx. DePiep (talk) 19:01, 27 November 2022 (UTC)[reply]

Ionic Formluae: Rendering and Copy/Paste Issues (using iOS Safari, but likely in all browsers)

[edit]

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

  1. (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.
  2. (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²⁻ ₃”).
  3. (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)[reply]

Staggered Charges

[edit]

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)[reply]

Interesting. I would support a change to stagger the charge. It would also reduce complexity of the processing of this template, as it would remove several invocations of the {{su}} template (or module). This processing complexity seems to be a problem presently. —Quondum 18:03, 18 July 2024 (UTC)[reply]