HOW TO
In ArcGIS Pro, it may occasionally be necessary to add superscripts or subscripts to your text. For example, when labelling chemical compounds on an environmental map, you might need to include CO2 for carbon dioxide emissions. Similarly, in demographic maps, subscripts can be used to denote specific population subsets, such as P18-24 for the population aged 18 to 24. These superscripts or subscripts help ensure clarity and precision in maps and data.
There are several ways to add superscripts or subscripts to text in ArcGIS Pro. These methods vary based on whether you want to modify attribute values or display superscripts/subscripts in labels without changing the underlying data. Below are the two primary scenarios, each with several methods:
Copy and Paste Unicode Characters
Manually copy superscript or subscript characters from the Official Unicode Consortium code chart and paste them into the attribute table, replacing the desired characters.
Use the Python String replace() Method
Replace characters directly within the attribute table using the Calculate Field tool:
!ion!.replace("+","⁺").replace("-", "⁻")
This code replaces "+" and "-" with their superscript equivalents in the ion field, as shown in the next image.
For more complex replacements, write a Python function:
def to_subscript(!ChemicalCompound!):
subscripts = str.maketrans("0123456789", "₀₁₂₃₄₅₆₇₈₉")
return text.translate(subscripts)
to_subscript(!ChemicalCompound!)
This converts numbers in the ChemicalCompound field to subscripts, as shown in the next image.
Use the Python String replace() Method with HTML Tags
ArcGIS Pro supports HTML tags for superscripts and subscripts in labels:
replace()
method with HTML tags (<SUP>
for superscripts and <SUB>
for subscripts). For example:[ion].replace("+", "<SUP>+</SUP>").replace("-", "<SUP>-</SUP>")
This displays "+" and "-" as superscripts in labels for the ion
field, as shown in the next image.
Use a Python Function for Advanced Labelling
For more complex label transformations, write a Python function:
def to_subscript(text):
subscripts = str.maketrans("0123456789", "₀₁₂₃₄₅₆₇₈₉")
return text.translate(subscripts)
def FindLabel([ChemicalCompound]):
return to_subscript([ChemicalCompound])
This displays numbers in the ChemicalCompound field as subscripts in the label.
By following these methods, you can effectively add superscripts or subscripts to text in ArcGIS Pro, whether in attribute values or labels. Choose the approach that best suits the project requirements.
Article ID: 000034456
Get help from ArcGIS experts
Download the Esri Support App