I'd actually go for 4 cav, 16 inf and 10 artillery in a 30k stack. There's just no need for 6 cavalry units.
It works like this.
X is infanty
C is cavalry
A is artillery.
E is the enemy.
The infantry can only fight the unit that is directly in front of them. So they will line up against each other, like so:
xxxxxxxx
eeeeeee
Artillery ccan attack the unit directly in front of the unit in front of them; they fire 'over' a friendly unit. As such, they will prefer to sit in the second line wherever possible:
aaaaaaaaaa
xxxxxxxxxxx
eeeeeeeeee
Cavalry can attack diagonally forwards - so they attack either the unit directly in front of them, or the unit directly in front of the unit to their left or right. So you always want 2 cavalry to sit on the flanks, like so:
_aaaaaaaaaaa_
cxxxxxxxxxxxxxc
_eeeeeeeeeee_
So, let's take a small example so we can see what's happening here.
__aa_
cxxxc
_eee_
the first e is being attacked by the infantry unit directly in front of it, and by the cavalry unit to it's front and left. The second e is being attacked by the infantry unit directly in front of it, and the artillery unit hidden behind that. And the third E is being attacked by the infantry unit in front of it, the artillery unit behind that, and the cavalry unit to it's front and right.