A #PractiCarto Archive

For the past few months, on Twitter, I’ve been posting brief practical cartography tips every Tuesday using the #PractiCarto hashtag. You can click on the tweet below to read a thread with my whole rationale, but the short version is: by keeping it short, it makes it easy for me to share, and it makes it easy for the reader to pay attention — and thus, I hope, there are more chances to share knowledge.

This blog post is simply meant to collect my own #PractiCarto tweets all in one place. A few colleagues have also made use of the hashtag, which is great and exactly what I was hoping for.

Stephen Smith has put together a little notifier that will send you an email every time someone uses the hashtag, so that you’ll never miss out on useful mapping advice.

My #PractiCarto Archive

Advertisements

Even Fancier Type Knockouts in Illustrator

As longtime readers may know, I’m a big fan of label knockouts — see my previous tutorial on the subject here. I’d much rather have stuff underneath a label gracefully vanish vs. stepping on it with a halo. However, the downside with the technique I usually use is that you actually have multiple independent copies of the label: one you can see, and one (or more) that’s being used to make the linework invisible. If you move/change one, you have to do it with all the others.

MoveLabel

Note how the waterlines vanish to make room for Ardebil. Note also how I moved the visible label for Rasht, but didn’t move the copy of the label that was being used to mask the waterlines.


I’ve lately figured out an improved technique in Illustrator that lets me make labels that knock out map features underneath them, instead of requiring a second, separate knockout object. This means you can move a label, retype it, etc., and it automatically clears its own surroundings.

This technique actually doesn’t wholly supplant the technique in my previous tutorial, as it can’t be used in every circumstance (as we’ll see). But it’s pretty great when you can get away with it.
Before we look at how to do this, there are two pieces of Illustrator that we need to understand: the Knockout Group setting and appearance attributes. You can skip ahead if you’re familiar with these already.

Knockout Groups

Perhaps you’ve seen this little checkbox on the Transparency panel and wondered what it did.

knockout-group-option

May need to click (more than once) on the icon next to the word “Transparency” to get it to appear.

When you have two objects overlapping in Illustrator, it has to figure out which parts you can see, and which are hidden. So, we don’t see the entire red square below, because the blue circle is covering part of it. Illustrator has knocked out (made invisible) part of the red square. Remember, we’re not dealing with real physical objects, so for one thing to hide another, Illustrator has to figure out how to make a decision for each pixel on the screen (or page): “do I show red, blue, or some combination?”

squarecircle

If I turn the blue circle partly transparent, Illustrator figures out that part of the red square should show through, and then does some math to determine what color the overlap should be. If I turn the blue circle completely transparent, Illustrator realizes that the red square should completely show through.

squarecircletransparent

The order of operations here is:

  1. Look at transparency settings for each object
  2. Then decide if any of the red square needs to be hidden, or have its colors mixed with the circle

Turning on Illustrator’s Knockout Group setting reverses this order of operations. First, Illustrator decides that the blue circle should hide part of the red square. And then it looks at transparency settings. So, if we made the blue circle completely transparent, Illustrator first hides part of the red square (due to the overlap), and then makes the blue circle vanish.


The end result is that the red square is being hidden by something that’s invisible.

I must credit Illustrator guru Mordy Golding for my understanding of how this stuff works. I don’t remember if it was a blog post or one of his lynda.com tutorials that I saw which taught me this, but I’ve been getting a lot of mileage out of Knockout Group for years thanks to him.

Appearances

So, Knockout Group is the first piece. The second is the Appearance Panel, of which I am a big fan (as anyone who has ever watched me work in Illustrator will attest). This thing is the heart and soul of Illustrator, and I really think it should be introduced on Day 1 of Illustrator 101. But most people I know encounter it much later on, as I did.

All your art in Illustrator has appearance attributes. Fills and strokes are the most common, but there are many other possibilities: drop shadows, transparency, blurs, etc. Anything that affects how your vector paths look is an appearance, and you’ll see it in the Appearance Panel.

appearance-panel

You know those little circles in the Layers panel, one next to each object and layer? The ones that you probably thought were used to select things? They’re actually for selecting and viewing appearance attributes.

appearancecircle

The reason there’s one for the layer is that you can apply appearance attributes to an entire layer at a time, in addition to whatever attributes its contents have. For example, I can draw a bunch of blue squares.

Mysterious Squares: Our Misunderstood Friends (I stole this joke from Marty Elmer)

Mysterious Squares: Our Misunderstood Friends
(I stole this joke from Marty Elmer)

Now, if I click on the appearance circle for the layer they’re in, I can choose to add a new stroke from the panel menu (or use the “new stroke” button on the bottom of the panel) and add a stroke to them.
addstroke

And now my squares all have a stroke. If I select each one, Illustrator will say it doesn’t have a stroke — because the actual objects do not. The layer does, and it’s applying that stroke on top of whatever’s going on with the stuff inside the layer.

This distinction of applying appearance attributes to objects vs. layers is super useful once you get the hang of it. I’ll leave you to explore a bit (since I don’t want to drift too far from our initial purpose here), but here’s an example:

shadowed

On the left, a drop shadow was applied to each object. On the right, a drop shadow was applied to the whole layer, instead.

Knocking Out Labels

Ok, so let’s put these two pieces together: appearance attributes and knockout groups.

Let’s make a layer for some labels, and type some labels inside of it.
labels
Now, let’s select our layer’s appearance (that little circle by the layer name) and go to the Appearance Panel and add a stroke to our layer and make it any color you want; I’ll go with black.

strokelabel

That worked, but now a stroke is covering up most of each of our labels. So, go back to the Appearance Panel (don’t forget to re-select the layer appearance if you deselected it — I forget to do this all the time, even after doing this for years) and take the stroke and click and drag it until it’s below the word “Contents.” “Contents” means the stuff inside the layer. We’re telling Illustrator to draw this stroke, but draw it below the contents of the layer (all of our labels). The Appearance Panel has a layer order to it, and you can rearrange what stuff draws on top of what. So now everything looks good.

strokelabel2

Now, let’s make another layer underneath our labels layer, and draw some lines or something in it. This is the stuff we want our labels to knock out. And finally, let’s put both of these layers into a master layer, so that we have one top layer and two sublayers (one for labels, one for the map stuff).

stuff

Select the appearance circle for the master layer, go to the Transparency Panel, and find that “Knockout Group” checkbox. Click it until it turns into a check mark. It’ll turn into a dash first, likely, but skip past that. I don’t adequately understand what the dash setting does, but I am led to believe it has uses which are very, very rare. So we can ignore it.

kg-on

Now we’ve turned on Knockout Group, so that activates that reverse order of operations. The labels are on top of the other stuff, so Illustrator figures out which parts of that stuff are hidden by the labels, and then afterwards it will calculate any transparency. Since nothing is transparent at present, this has no effect. So let’s change that.

Select the appearance for the labels sublayer and go to the Appearance Panel. We want to turn up the transparency on that black stroke. So we need to select carefully. We don’t want to change the transparency for everything (including the labels). So in the Appearance Panel, click on the entry for the stroke to highlight it. And then go to the Transparency Panel and set the Opacity of that black stroke to 0%. It vanishes (as we would expect when something is totally transparent).

knockout1

Not only did the stroke vanish, but so did the artwork underneath it. If you want to get much mileage out of this technique (and figure out your own variants and other uses for these tools), you’ve got to understand what’s going on. So let’s go through it again (since it can be tough to wrap your head around).

All of our labels have strokes around them because we edited the appearance for the label sublayer and added a stroke. Then we made that stroke invisible (0% opacity). But, since the top layer had Knockout Group checked, Illustrator looked first at the labels, figuring out that they were on top of and hiding the artwork underneath, then erased those portions of the artwork. Then, and only then, did it calculate transparency and realize that the stroke couldn’t be seen, and so made it vanish. It’s still there, acting as an invisible buffer that knocks out stuff underneath.

And it’s all live. The stroke is applied to the label layer, so it affects whatever is in that layer. If we add labels, or move them around, the knockout still works. We can also go in and change how big the knockout is. I can go back to the stroke that I added, for example, and make it thicker. I also usually choose the rounded corner join, as well.

knockout2

Wrap-Up

So, that’s a little trick for labels that knock out the stuff underneath. It can’t be used in every situation. I have maps, for example, where I want some labels to knock out some map layers and not others, and some labels to not knock out anything at all, etc. That would be pretty tough to arrange using the above technique, and so I generally use my opacity mask technique instead. But for simpler situations, this is a really handy trick to pull out.

One additional quick example of this technique. My transit-style river maps have double lines for all the water courses.

double-line

To do this, I went to the Appearance Panel and applied a thick blue stroke to my paths, then a thinner black stroke on top, then made the thinner black stroke invisible, then turned on Knockout Group (in this case, on the transparency for the object, not the layer, since all of this is happening within one object). The thin stroke hides the middle of the thick stroke, and then vanishes.

I hope all this helps. The Knockout Group setting has a ton of applications, especially in conjunction with cleverly-set appearance attributes, so if you take a while to mess around and get an understanding of how it works, it’ll pay off in the long run.