I really haven't had any problems at all with my marksdwarves, but then I use them in a very simple manner.
I first construct the entrance to my fortress in such a manner that all visitors must travel through a chokepoint. Then in the middle of that chokepoint I build an armor stand, and create a barracks from it.
I then make a custom uniform with crossbows, shields, helmets, breastplate, 2 mail shirts, gauntlets, leggings, and high boots. I make 5-6 militia captains and assign them this uniform. Each squad gets an allotment of 250 bolts, which is 25 per dwarf. Remember that you must also make quivers. Quivers are not explicitly assigned in the uniform screen but you still need them.
After that is all done I'll assign the 5-6 crossbow squads (which consist of only 1 militia captain apiece) to be active/training at the barracks.
Then I go and hunt around for peasants. Any peasant I find gets assigned to the military. Its very easy to just scroll around the fortress and see what peasants are in the dining hall. They get sent into the military. I keep doing this until my military is full.
This gets me a blob of 50-60 marksdwarves packed closely together in the only entrance to the fortress. Anything attacking must go through them. The nature of the chokepoint is also great for marksdwarves. Even if the recruit marksdwarf misses their intended target, the bolt will still hit something, and massive dakka will take care of all problems.
As an added security precaution I'll make a squad of legendary+5 miners, using mining picks and full armor, and give them a barracks just behind my marksdwarves. The miners will only attack should enemies close to melee range of the marksdwarves, so the marksdwarves will do most of the fighting with the miners automatically jumping in if the marksdwarves get swamped in melee. The massive firepower of 50-60 crossbows all firing at the same target in the same direction will drop nearly anything. Only a bronze colossus is able to get past that barrage.
And then just to be extra through, behind the miners is a series of cage traps, so anything that somehow gets past all this will get caught in a cage.
I don't bother with any archery ranges or anything along those lines. I just leave them on active/training in a single barracks, and it all works out from there.
Edit:
Added diagram:
TO FORT
X.......X
X.......X
X^^^^^^^X
X^^^^^^^X <==traps for last ditch defense
X^^^^^^^X
X.......X
X.......X
X.......X
X.......X
X.......X
X...A...X <==armor stand barracks with melee squad
X.......X
X.......X
X.......X
X.......X
X...A...X <==armor stand barracks with marksdwarves
X.......X
X.......X
X.......X
X.......X
X.......X
X.......X
X.......X
X.......X
X.......X
X.......X
X.......X
X.......X
X.......X
X.......X
OUTSIDE