What can I do if drain alignment doesn't allow enough space for p-trap?
When you purchase a P-trap from the hardware store, you'll end up with these pieces (or something similar).

You'll also want to pick up a 1-1/2 in. PVC 90° slip-joint elbow while you're there.

You'll then want to connect the pieces something like this...

You'll then have to twist the pieces around, until you can get them to fit together. You'll end up with something similar to this.

Though I'm not sure this is code compliant anymore.
In the 2003 version of International Residential Code (IRC), there was this section.

International Residential Code 2003
Chapter 31 Vents
Section P3105 Fixture Vents
P3105.3 Vertical leg for waste fixture drains. A vertical leg (see Figure P3105.3) is permitted within a fixture drain of a waste fixture in accordance with the following criteria:

Minimum trap diameter shall be in accordance with Table P3201.7.
The diameter of Section A shall be equal to the diameter of the trap.
The length of Section A shall not be less than 8 inches (203 mm) and in accordance with Table P3105.1.
The diameter of Section B shall be one pipe size larger than the diameter of Section A.
The length of Section B shall not be more than 36 inches (914 mm).
The diameter of Section C shall be one pipe size larger than the diameter of Section B.
The total length of Section A and Section C shall not exceed the distance allowed in Table P3105.1.
Bends shall be the diameter of the largest connected section.



However, in the 2006 version, this section is gone.