  This work investigates the alignment of galactic spins with the cosmic web
across cosmic time using the cosmological hydrodynamical simulation
Horizon-AGN. The cosmic web structure is extracted via the persistent skeleton
as implemented in the DISPERSE algorithm. It is found that the spin of low-mass
galaxies is more likely to be aligned with the filaments of the cosmic web and
to lie within the plane of the walls while more massive galaxies tend to have a
spin perpendicular to the axis of the filaments and to the walls. The mass
transition is detected with a significance of 9 sigmas. This galactic alignment
is consistent with the alignment of the spin of dark haloes found in pure dark
matter simulations and with predictions from (anisotropic) tidal torque theory.
However, unlike haloes, the alignment of low-mass galaxies is weak and
disappears at low redshifts while the orthogonal spin orientation of massive
galaxies is strong and increases with time, probably as a result of mergers. At
fixed mass, alignments are correlated with galaxy morphology: the high-redshift
alignment is dominated by spiral galaxies while elliptical centrals are mainly
responsible for the perpendicular signal. These predictions for spin alignments
with respect to cosmic filaments and unprecendently walls are successfully
compared with existing observations. The alignment of the shape of galaxies
with the different components of the cosmic web is also investigated. A
coherent and stronger signal is found in terms of shape at high mass. The two
regimes probed in this work induce competing galactic alignment signals for
weak lensing, with opposite redshift and luminosity evolution. Understanding
the details of these intrinsic alignments will be key to exploit future major
cosmic shear surveys like Euclid or LSST.
