The Mathematica Book

A Practical Introduction to Mathematica

Input and Output in Notebooks

1.10.1    Entering Greek Letters
1.10.2    Entering Two-Dimensional Input
1.10.3    Editing and Evaluating Two-Dimensional Expressions
1.10.4    Entering Formulas
1.10.5    Entering Tables and Matrices
1.10.6    Subscripts, Bars and Other Modifiers
1.10.7    Special Topic: Non-English Characters and Keyboards
1.10.8    Other Mathematical Notation
1.10.9    Forms of Input and Output
1.10.10    Mixing Text and Formulas
1.10.11    Displaying and Printing Mathematica Notebooks
1.10.12    Creating Your Own Palettes
1.10.13    Setting Up Hyperlinks
1.10.14    Automatic Numbering
1.10.15    Exposition in Mathematica Notebooks

1.10.6 Subscripts, Bars and Other Modifiers

Here is a typical palette of modifiers.

[Graphics:HTMLFiles/1.10.6_Scripts_1.gif]

Mathematica allows you to use any expression as a subscript.

In[1]:=

Expand[(1 + x_ (1 + n))^4]

Out[1]=

1 + 4 x_ (1 + n) + 6 x_ (1 + n)^2 + 4 x_ (1 + n)^3 + x_ (1 + n)^4

Unless you specifically tell it otherwise, Mathematica will interpret a superscript as a power.

In[2]:=

Factor[x_n^4 - 1]

Out[2]=

(-1 + x_n) (1 + x_n) (1 + x_n^2)

[CTRL]-[_]  or  [CTRL]-[-] go to the position for a subscript
[CTRL]-[+]  or  [CTRL]-[=] go to the position underneath
[CTRL]-[^]  or  [CTRL]-[6] go to the position for a superscript
[CTRL]-[&]  or  [CTRL]-[7] go to the position on top
[CTRL]-[_] return from a special position (Control-Space)

Special input forms based on control characters. The second forms given should work on any keyboard.

This enters a subscript using control keys.

In[3]:=

Expand[(1 + x[CTRL]-[_]1+n[CTRL]-[_])^4]

Out[3]=

1 + 4 x_ (1 + n) + 6 x_ (1 + n)^2 + 4 x_ (1 + n)^3 + x_ (1 + n)^4

Just as [CTRL]-[^] and [CTRL]-[_] go to superscript and subscript positions, so also [CTRL]-[&] and [CTRL]-[=] can be used to go to positions directly above and below. With the layout of a standard English-language keyboard [CTRL]-[&] is directly to the right of [CTRL]-[^] while [CTRL]-[=] is directly to the right of [CTRL]-[_].

key sequence displayed form expression form
x[CTRL]-[&]_ Overscript[x, _] OverBar[x]
x[CTRL]-[&]:vec: Overscript[x, →] OverVector[x]
x[CTRL]-[&]~ Overscript[x, ~] OverTilde[x]
x[CTRL]-[&]^ Overscript[x,^] OverHat[x]
x[CTRL]-[&]. Overscript[x, .] OverDot[x]
x[CTRL]-[=]_ Underscript[x, _] UnderBar[x]

Ways to enter some common modifiers using control keys.

Here is Overscript[x, _].

In[4]:=

x [CTRL]-[&]_ [CTRL]-[_]

Out[4]=

Overscript[x, _]

You can use Overscript[x, _] as a variable.

In[5]:=

Solve[a^2 == %, a]

Out[5]=

{{a→ -Overscript[x, _]^(1/2)}, {a→Overscript[x, _]^(1/2)}}

key sequence displayed form expression form
x _ y x_y Subscript[x, y]
x + y Underscript[x, y] Underscript[x, y]
x ^ y x^y Superscript[x, y] (interpreted as Power[x, y])
x & y Overscript[x, y] Overscript[x, y]
x &_ Overscript[x, _] OverBar[x]
x &[RightVector] Overscript[x, →] OverVector[x]
x &~ Overscript[x, ~] OverTilde[x]
x &^ Overscript[x,^] OverHat[x]
x &. Overscript[x, .] OverDot[x]
x +_ Underscript[x, _] UnderBar[x]

Ways to enter modifiers without control keys. All these forms can be used only inside !( … ).