I am wondering what the advantages and disadvantages are of placing the vertical tail nearer to, or farther from, the main wing. For instance, when the vertical tail is just behind the wing, do the wing's effects on the airflow around the aircraft decrease the effectiveness of the vertical tail?
The reference point is not the leading edge but the center of gravity (CG), which is a little further back.
The ability of a fin to generate a yawing moment is proportional to both its area $A$ and its distance $l$ behind the CG. It is therefore also proportional to their product. This has units of $L^3$ so it is known as the tail volume $V$:
$V = A.l$
So the nearer the fin is to the CG, the larger it needs to be. On the other hand, the smaller a fin is, the farther back you have to build it out.
In practice everything in front of the fin, usually the fuselage and/or wing, can affect the airflow over it and reduce its effectiveness. This is especially significant at high angles of attack, such as when taking off or landing, and extra height is often added for this reason.
However a very tall fin also exerts a strong rolling moment, which can cause awkward stability problems such as Dutch roll.
At supersonic speeds, the pressure above the rear of the wing and fuselage falls, reducing the effectiveness of the fin. However the pressure under them increases, so underside strakes become very effective for their size.
Placing a very large fin above and close to the main wing is about the worst thing you can possibly do.
The optimal distance back depends on many design factors but is usually around a half- to three-quarter span, though it can be further for supersonic aircraft.
The answer depends on many factors. The most important one: What is the vertical tail needed for? This will be a combination of several functions, and the most pressing need will determine its size and location:
- Counteract asymmetric thrust in multi-engined airplanes. With all engines running, the B-52 is still flyable with almost all of its vertical gone.
- Provide yaw damping. For GA aircraft, the yaw oscillation has to die down to a tenth of its original magnitude after no more than seven cycles. Since damping grows with the square of the tail's distance to the center of gravity while control power only grows linearly, you should shift the tail further back if you need more damping.
- Get the airplane out of a spin. Here it is important to have some part of the vertical exposed to the airflow even at very high angle of attack. This means that the vertical tail should be placed a bit ahead of the horizontal tail, or a T-tail is used.
- Counteract adverse yaw: Here the wing's aspect ratio dictates how far the vertical should be shifted back. More slender wings require more distance between center of gravity and the vertical tail.
As you can see, the location relative to the wing's leading edge is not important. Measure the distance to the center of gravity and let it grow with wing span. Start with 40% of span (for gliders maybe 30% of span), size it for control power and increase the distance if damping is insufficient. Add some margin for wing-mounted engines.