  The effect of imposing a constraint on a fluctuating scalar order parameter
field in a system of finite volume is studied within statistical field theory.
The canonical ensemble, corresponding to a fixed total integrated order
parameter, is obtained as a special case of the theory. A perturbative
expansion is developed which allows one to systematically determine the
constraint-induced finite-volume corrections to the free energy and to
correlation functions. In particular, we focus on the Landau-Ginzburg model in
a film geometry (i.e., a rectangular parallelepiped with a small aspect ratio)
with periodic, Dirichlet, or Neumann boundary conditions in the transverse
direction and periodic boundary conditions in the remaining, lateral
directions. Within the expansion in terms of $\epsilon=4-d$, where $d$ is the
spatial dimension of the bulk, the finite-size contribution to the free energy
and the associated critical Casimir force are calculated to leading order in
$\epsilon$ and are compared to the corresponding expressions for an
unconstrained (grand canonical) system. The constraint restricts the
fluctuations within the system and it accordingly modifies the residual
finite-size free energy. The resulting Casimir force is shown to depend on
whether it is defined by assuming a fixed transverse area or a fixed total
volume. In the former case, the constraint is typically found to significantly
enhance the attractive character of the force as compared to the grand
canonical case. In contrast to the grand canonical Casimir force, which, for
supercritical temperatures, vanishes in the limit of thick films, the canonical
Casimir force defined for fixed transverse area attains for thick films a
negative value for all boundary conditions studied here. Typically, the
dependence of the Casimir force both on the temperature- and on the field-like
scaling variables is different in the two ensembles.
