Forcing label items to remain on the same line

973
3
Jump to solution
07-14-2017 07:45 AM
New Contributor II

Hi all,

I'm new to working with label expressions in ArcGIS Pro and I was hoping for some help. The expression I'm working with is as follows (VBScript):

[full_name] + " (Z:" & [zone] & " R:" & [rank_id] &")"

I realize my syntax and labeling structure is messy, but it's been getting the job done. The label is displaying a client name followed by their zone and rank numbers in parenthesis. Example: ExampleName (Z:1 R:10) The problem I'm having occurs when a longer client name forces what I have in parenthesis on to two different lines when I have label stacking enabled.

Is there a way to ensure that my information inside the parenthesis always stays together on the same line?

Any help is appreciated!

Reply
0 Kudos
1 Solution

Accepted Solutions
Regular Contributor

A less elegant option (without code) would be to simply change the label engine from Maplex to Standard Label Engine by un-selecting the Use Maplex Label Engine under the more options.

This should ensure all labels are on one line.

View solution in original post

3 Replies
Regular Contributor

A less elegant option (without code) would be to simply change the label engine from Maplex to Standard Label Engine by un-selecting the Use Maplex Label Engine under the more options.

This should ensure all labels are on one line.

View solution in original post

New Contributor II

This seems to be solved my issue:

I turned off Maplex Label Engine and added \n before my parenthesis to push this portion onto to the second line. [full_name] + "\n (Z:" & [zone] & " R:" & [rank_id] &")"

There must be a way to format this in Maplex, but using a line break was creating too large of a break for my desired label appearance. For now, the less elegant option does the job.

Esri Contributor

Hi Brandon,

This problem may no longer be relevant for you, but just in case it is: the issue is that maplex has the option to specify stacking characters, and the space character is a stacking separator by default, so it splits on any space it sees fit. 

You could remove the space as a stacking separator and choose an open bracket character for example, with visibility on and split after checked off.

However, this won't help you if you still want it to stack on space characters in other parts of your expression. For that, you can use non-breaking space characters.

You can replace regular spaces in part of your expression with non-breaking space character (U+00A0). For example:

$feature.full_name + " (Z:" + $feature.zone + "\u00A0" + "R:"+ $feature.rank_id +")"‍‍

Or if you have regular spaces in your fields and don't want them to stack, you could find and replace them with nbsp in a section:

$feature.full_name+ " " + replace("(Z:" + $feature.zone + " R:"+ $feature.rank_id +")", " ", "\u00A0")

Maplex will not split on these non breaking space characters.

Or as a third option, you can hard code your new line character, and disabling stacking as a fitting strategy

$feature.full_name + TextFormatting.Newline + "(Z:" + $feature.zone + " R:"+ $feature.rank_id +")"‍‍‍‍‍‍

All the examples above are using Arcade, but will work just as well in any other parser. For VBScript make sure you use + vbnewline + instead of TextFormatting.Newline to ensure you have the correct type of line feed character.

Hope that helps!

Ciara