Re: Chemical notation
- To: mathgroup@smc.vnet.net
- Subject: [mg12374] Re: Chemical notation
- From: Carl Woll <carlw@fermi.phys.washington.edu>
- Date: Sun, 10 May 1998 02:04:56 -0400
- Organization: University of Washington
- References: <6imhlr$gv1@smc.vnet.net> <6itell$14n@smc.vnet.net>
Hi Paul, There is one problem with using SubsuperscriptBox to solve this problem, which is that the numbers are not automatically aligned to the right. So, you need to do something like add spaces as you did. What about using GridBox instead? For example, you could create a Button just as you did. DisplayForm[ButtonBox[RowBox[{ StyleBox[ GridBox[{{"\[Placeholder]"},{"\[Placeholder]"}}, RowSpacings->0, ColumnAlignments->{Right}], FontSize->9], "\[NegativeThinSpace]","SelectionPlaceholder"}], Active->True]] This button produces output similar to the button you suggested, but the numbers are aligned to the right. On the other hand, SubsuperscriptBox seems like a more natural approach. Do you know if there is there a way to align SubsuperscriptBox's? Carl Woll Dept of Physics U of Washington On 7 May 1998, P.J. Hinton wrote: > On 5 May 1998, Nicolas Martignoni wrote: > > > I would like to typeset a chemical element notation, with Z and A > > numbers, like the following: > > > > 214 > > Po > > 84 > > > > Is there a way to do this in Mathematica 3.0.x ? > > This requires a little trickery. There is a SubsuperscriptBox construct > that can align the atomic and mass numbers as you wish, but you have to > use an empty string as the "anchor" for the sub and superscripts. > Evaluating the following expression will demonstrate an example of how > you might create this effect.: > > RowBox[{ > RowBox[{ > SubsuperscriptBox[""," 84", "214"]}], > "Po"}] // DisplayForm > > Here is an example which uses the ChemicalFormula style inline within a > Text cell. The ChemicalFormula contains some option settings which > distinguish it from typical typeset math cells. Since this is an > inline cell, it will use the setting for Default Inline Format Tyle > under the Cell menu, which is TraditionalForm, meaning that the text > will be set in whatever font is used by the style sheet for > TraditionalForm (in this case -- Times). > > Cell[TextData[{ > "The decay of the isotope ", > Cell[BoxData[ > FormBox[ > RowBox[{ > SubsuperscriptBox["", > RowBox[{" ", "84"}], "214"], "Po"}], ChemicalFormula]]] }], > "Text"] > > Try pasting this cell in a notebook which uses one of the following > style sheets: > > ArticleClassic ArticleModern > Classic Report > Textbook TutorialBook > > When the front end asks you whether the cell expression should be > interpreted, click "Yes." > > And as an added bonus, here is an expression that generates a button to > speed the entry of the box: > > DisplayForm[ > ButtonBox[StyleBox[RowBox[{SubsuperscriptBox["", > "\[Placeholder]","\[Placeholder]"], > "\[SelectionPlaceholder]"}],"ChemicalFormula"], > Active\[Rule]True]] > > Paste the above in an Input cell and evaluate it to make the button. > > Here are the instructions for using the button. > > 1) Enter the element name "Po." > > 2) Select the element name text with your mouse. > > 3) Click on the button. > > 4) Enter the subscript number. > > 5) Hit the Tab key. > > 6) Enter the superscript number. > > 7) Hit Ctrl-Space twice to escape the math editor. > > 8) Continue typing the text. > > Hope that helps. > > -- > P.J. Hinton > Mathematica Programming Group paulh@wolfram.com Wolfram > Research, Inc. http://www.wolfram.com/~paulh/ > Disclaimer: Opinions expressed herein are those of the author alone. > > > >