Yes and no. A thin line is prone to getting holes punched in it so the enemy can essentially split your unit into two. Similarly, you have less to fall back on if your engaged thinly spread unit is attack from flank or rear.
Generally you want to aim for 2-4 ranks for missile units, 3-5 for melee infantry, 4-6 for spears, 3 for cavalry. This is for small unit sizes.
If you are defending a city, sometimes its better to block an entire street (i.e you already lost the gate) with 2-3 regiments side to side, so they are only 4 men wide and the rest deep.
Bookmarks