  Context. Magnetic helicity is an important quantity in studies of magnetized
plasmas as it provides a measure of the geometrical complexity of the magnetic
field in a given volume. A more detailed description of the spatial
distribution of magnetic helicity is given by the field line helicity that
expresses the amount of helicity associated to individual field lines, rather
than in the full analysed volume. Aims. Magnetic helicity is not a
gauge-invariant quantity in general, unless it is computed with respect to a
reference field, yielding the so called relative magnetic helicity. The field
line helicity corresponding to the relative magnetic helicity has only been
examined under specific conditions so far. This work aims to define the field
line helicity corresponding to relative magnetic helicity in the most general
way. In addition to its general form, we provide the expression for the
relative magnetic field line helicity in a few commonly used gauges, and
reproduce known results as a limit of our general formulation. Methods. By
starting from the definition of relative magnetic helicity, we derive the
corresponding field line helicity, and we note the assumptions it is based on.
Results. We check that the developed quantity reproduces relative magnetic
helicity by using three different numerical simulations. For these cases we
also show the morphology of field line helicity in the volume, and on the
photospheric plane. As an application to solar situations, we compare the
morphology of field line helicity on the photosphere with that of the
connectivity-based helicity flux density in two reconstructions of an active
region's magnetic field. We discuss how the derived relative magnetic field
line helicity has a wide range of applications, notably in solar physics and
magnetic reconnection studies.
