Building label expressions

You can use label expressions to adjust the formatting of your labels. In addition to inserting characters and scripting functions, you can use ArcGIS formatting tags in label expressions. These are special characters for changing the appearance of all or part of your labels. For example, you might use the bold formatting tag to make the first line bold in a stacked, multiline label.

A label expression is limited to a single line of code unless you check the Advanced box on the Label Expression dialog box. Checking the Advanced box allows you to enter a function containing programming logic and spanning multiple lines of code.

Steps:

  1. Click the Label Manager button Label Manager on the Labeling toolbar.
  2. Click a label class in the Label Classes list.
  3. Click the Expression button.
  4. Choose a language on the Parser menu.
  5. Type a VBScript or JScript expression. Optionally, enter ArcGIS text formatting tags in the Expression box to apply formatting to a portion of your label text.

    If your expression will span multiple lines of code check the Advanced checkbox and then enter your label expression.

  6. Click Verify to make sure there are no syntax errors.
  7. Click OK on each of the dialog boxes.

Expression examples

The following are examples of label expressions:

Learn more about Microsoft VBScript Language Reference

Learn more about Microsoft JScript Language Reference

(This information is housed on Web pages created, owned, and maintained by Microsoft Corporation. ESRI cannot guarantee the availability of these pages and is not responsible for the content found on them.)

ArcGIS text formatting tags

Labels are drawn using the symbol specified in the Label Manager or on the Labels tab of the Layer Properties dialog box. You can modify or override the appearance of this symbol for particular portions of the expression by inserting ArcGIS text formatting tags into the expression as text strings. This lets you create mixed-format labels where, for example, one field in a label is underlined.

The tags that you can use are listed in the table below. Acceptable values for Color (RGB) are red, green, blue = 0–255, and acceptable values for Color (CMYK) are cyan, magenta, yellow, black = 0–100; missing color attributes are assumed to be 0.

Font

"<FNT name='Arial' size='18'>" & [LABELFIELD] & "</FNT>"

"<FNT name='Arial' scale='200'>" & [LABELFIELD] & "</FNT>"

Color

"<CLR red='255' green='255' blue='255'>" & [LABELFIELD] & "</CLR>"

"<CLR cyan='100' magenta ='100' yellow='100' black='100'>" & [LABELFIELD] & "</CLR>"

Bold

"<BOL>" & [LABELFIELD] & "</BOL>"

Italic

"<ITA>" & [LABELFIELD] & "</ITA>"

Underline

"<UND>" & [LABELFIELD] & "</UND>"

All capitals

"<ACP>" & [LABELFIELD] & "</ACP>"

Small capitals

"<SCP>" & [LABELFIELD] & "</SCP>"

Superscript

"<SUP>" & [LABELFIELD] & "</SUP>"

Subscript

"<SUB>" & [LABELFIELD] & "</SUB>"

Character spacing (0%=regular)

"<CHR spacing='25'>" & [LABELFIELD] & "</CHR>"

Character width (100%=regular)

"<CHR width='150'>" & [LABELFIELD] & "</CHR>"

Word spacing (100%=regular)

"<WRD spacing='150'>" & [LABELFIELD] & "</WRD>"

Line leading (pts)

"<LIN leading='12'>" & [LABELFIELD] & "</LIN>"

Un-Bold

"<_BOL>" & [LABELFIELD] & "</_BOL>"

Un-Italic

"<_ITA>" & [LABELFIELD] & "</_ITA>"

Un-Underline

"<_UND>" & [LABELFIELD] & "</_UND>"

Un-Superscript

"<_SUP>" & [LABELFIELD] & "</_SUP>"

Un-Subscript

"<_SUB>" & [LABELFIELD] & "</_SUB>"

ArcGIS text formatting tags

Tag syntax

The following syntax rules apply to tags in label expressions:

Tips for building label expressions

The following tips will help you build your label expressions:

Related Topics


5/2/2011