The paper combines the optimal gerrymandering approach in political sc
ience with the ''fair cake division'' results in mathematics and econo
mics to consider optimal partisan gerrymandering schemes on a given te
rritory. We analyze existence and properties of an optimal districting
map for a strategic party that has control over redistricting process
, given arbitrary continuous distributions of voters and party support
ers over the electoral territory. Interestingly, we find that impositi
on of certain equality-type constraints on districting might often hel
p to prevent gerrymandering and sustain fairness.