Here's a quick diagram I threw together of another engine not mentioned, compared to the more common I4 and V6. The VR6 is the one I'm talking about (yes, because I'm a VR6 Volkswagen whore).
Generally, the "straighter" up and down the cylinder the more torque it makes, however; the engine is usually longer horizontally in that case. A V formation is generally considered a good combination of both being relatively compact and still making a good amount of torque. A large 8 cylinder engine would have to have an insanely long engine bay to house an Inline-8, but it needs a much smaller one for a V-8, make sense?
Well, Volkswagen went and squished the idea's of an I4 and a V-6 together and came up with a VR6, what you see is an engine with about 1/3rd more "thickness" than a typical I-4, which only has one row of cylinders, and it's roughly the same length horizontally as well. Compared to the V-6 shown on the bottom, you can see the space it saves.
I'm not saying what's better, but there's some more things out there for ya to look at...