How is a synapse held in place?
The textbooks represent the synapses that way for didactic reasons. But, in fact, there are several protein complexes that keep the membranes (pre and post synaptic) attached. The most famous are the puncta adherentia junctions.

In these structures, several different proteins, like nectins and cadherins, promove cellular adhesion:



(source of the image: http://cshperspectives.cshlp.org/content/1/4/a003079)

These molecules are important not only for cellular adhesion, but for synaptic plasticity as well.

Source: Adherens Junctions: from Molecular Mechanisms to Tissue Development and Disease