  The impact of confinement on self-assembly of particles interacting with
short-range attraction and long-range repulsion (SALR) potential is studied for
thermodynamic states corresponding to local ordering of clusters or layers in
the bulk. Exact and asymptotic expressions for the local density and for the
effective potential between the confining surfaces are obtained for a
one-dimensional lattice model introduced in [J. P\k{e}kalski et al. $J. Chem.
Phys.$ ${\bf 140}$, 144903 (2013)].The simple asymptotic formulas are shown to
be in good quantitative agreement with exact results for slits containing at
least 5 layers. We observe that the incommensurability of the system size and
the average distance between the clusters or layers in the bulk leads to
structural deformations that are different for different values of the chemical
potential $\mu$. The change of the type of defects is reflected in the
dependence of density on $\mu$ that has a shape characteristic for phase
transitions. Our results may help to avoid misinterpretation of the change of
the type of defects as a phase transition in simulations of inhomogeneous
systems. Finally, we show that a system confined by soft elastic walls may
exhibit bistability such that two system sizes that differ approximately by the
average distance between the clusters or layers are almost equally probable.
This may happen when the equilibrium separation between the soft boundaries of
an empty slit corresponds to the largest stress in the confined self-assembling
system.
