Multi-line text in legends
Problem: You need to create a legend with long descriptions that wrap to more than one line
Last week I read the Strange Maps slideshow essay on Slate.com, and fell in love with the last map: Soil Map of the Central Far Side of the Moon. The interesting colors make it look like an abstract painting. I stared at it appreciatively for only a little while before I began to wonder what each shade represented.

This map is available from the USGS at http://astrogeology.usgs.gov/Projects/PlanetaryMapping/DIGGEOL/moon/1047/lfar.htm. Unfortunately, the .pdf file on that web page does not have accompanying explanatory text, either. I had to dig futher down to find it, spread between two separate pages: a chart that links color swatches to soil type codes, and a list that links soil type codes to full descriptions. If all of this information was displayed together on one page as a map and legend, it would be an even more captivating piece.
Producing such a legend for an ArcMap layout is kind of tricky. ArcMap does not, by default, handle color swatches along with multiple lines of text very well. What you would envision looking something like this…

…turns out looking something like this…

….with no line breaks, and no good way to create them. I arrived at the bad-looking purple legend item in the typical way you would think to make a legend. That is, I created an attribute table field for Soil Descriptions. I called that field “Desc_” and I copied the long text descriptions into it. Then, I symbolized by category on the Desc_ field. My symbolgy definition box looked like this:

You can already start to see the problem. The Label area is truncating, and that’s where ArcMap looks to get the legend text. Yes, you can double click in this area to edit the text, but you will not be able to enter line breaks.
One solution is to convert your entire legend to graphics, ungroup it, and start editing the text boxes manually. That will work, but then you will have a static legend that doesn’t update with changes to your map. Do it a couple times, and then have to remake your entire legend when you’re asked to add new items or use a different color scheme, and you won’t want to do it again.
The solution I will describe takes more time to set up initially, but will make your life easier later on. The answer is to make ArcMap take the legend text from a special Description area instead. The Description box will let you use line breaks! But, it is not available if you symbolize by category. It is only available if you use the “draw all features using the same symbol” option. Luckily, you can mimic the effect of symbolizing by category by using multiple versions of the same layer with definition queries applied.
So, to create a legend item for the lavender “It” soil that looks like the legend item for the brown “NpNt” soil, you would follow the steps below.
1. Add the soil layer to ArcMap a second time.
2. Create a definition query on the new layer so it only displays soil type “It”.
3. Symbolize all features with the lavender color.
4. Copy the soil description text into Notepad or any text editor, and enter line breaks where you want them. Ideally you’d do this for all your soil descriptions at once so you know they’re all the same width.
5. Bring up the Layer Properties, Symbology tab. Press the Description… button and copy the text from Notepad into the Description for Legend box.
Note that you cannot create line breaks in this box by pressing the enter key! But, any line breaks you have created in Notepad will be maintained by copying and pasting.
6. Go to Layout view and insert a new legend (or right click on the one that’s there) to bring up the Legend Properties. Go to the Items tab, select your newest entry, and press the Style… button.
7. Pick one of the styles that uses “Description” instead of the default “Label” for the swatch text.
Finally, it’s looking pretty good!
You can repeat the same process for as many legend items as you need. In the end, the legend will appear and behave just as if you had symbolized by category.
If you want to take a little more time, you can make it look even better. Most people envision these sorts of legends with the swatch justified with the top of the text. You can do that if you drill down a bit within the settings. Return to step #6 where you selected the legend item and pressed the Style… button. This time, press Properties… in the Legend Item Selector box that comes up. If you go the General tab you’ll see this:
Show Descriptions should be checked because of the changes you made earlier. Press the Description Symbol… button below it. Then, press Properties… again in the Symbol Selector window that comes up. Change the Vertical Alignment to Top.
That’s shaping up into one respectable legend. 2 soils down, about 25 to go. I’m half a mind to complete it just so I can stare at that map a little longer.
Tags: dynamic label, legend, line break
December 7th, 2009 at 10:14 am
This is an all-too-common problem and you’ve done a nice job of explaining how to fix this in ArcMap. Thanks!
December 7th, 2009 at 3:43 pm
Note for step 5. You can enter line breaks using Ctrl-Enter.
Keep up the great blog!
December 7th, 2009 at 5:28 pm
I believe you can create line breaks in the Description box by pressing enter while holding down shift (or maybe it’s control…).
August 31st, 2010 at 1:15 pm
Instead of doing a definition query for each legend item, you can go into
-> Layer Properties -> Categories -> Unique Values.
Right click on the label you want to add a description to and select edit description.
Then you’ll have to go to Legend Properties -> Right Click on the Legend item with the description then check the description box. and uncheck the the label box.
The one draw back is that you’ll have to enter a description for each label that you don’t have a multi-line for.
February 2nd, 2011 at 2:38 am
As a Newbie, I am permanently browsing online for articles that can be of assistance to me. Thank you