Necromancers run away for a few seconds when they see one of your creatures, making it difficult to catch them with military patrols or guard animals.
However, they do home in on corpses (anything that they can animate). Place a corpse somewhere where the necro can get to it without seeing anyone, but where the necro has to cross a cage trap BEFORE he has line-of-sight to the corpse (so put the corpse behind a corner or an unlocked door). I've caged 2 necromancers this way so far at my current fort.
This is why I want kobold necromancers. Trapavoid.
On the other hand, animated kobold corpses can pick locked doors.
...
Step 1. Keep any and all corpses locked up where one cannot see them and cannot path to them. I think the necro magic works similar to when you fire a crossbow; in that the necromancer has to have line of sight and a clear shot. Meaning he'll sneak into position and necro your refuse stockpile from a safe distance. Just like gobbos might sometimes snipe into your fortress.
...
Step 3. I'm not sure if a necromancer can use his magic from inside of a cage but just in case you do. Don't keep your prisoner storage next to your corpse storage or you might be in for a nasty surprise when using cagetraps.
...
1. Only line of sight is required. Necromancers can cast through glass windows.
3. Necromancers can't cast from inside cages.