  Models for astrophysical plasmas often have magnetic field lines that leave
the boundary rather than closing within the computational domain. Thus, the
relative magnetic helicity is frequently used in place of the usual magnetic
helicity, so as to restore gauge invariance. We show how to decompose the
relative helicity into a relative field-line helicity that is an
ideal-magnetohydrodynamic invariant for each individual magnetic field line,
and vanishes along any field line where the original field matches the
reference field. Physically, this relative field-line helicity is a magnetic
flux, whose specific definition depends on the gauge of the reference vector
potential on the boundary. We propose a particular `minimal' gauge that depends
only on the reference field and minimises this boundary contribution, so as to
reveal topological information about the original magnetic field. We illustrate
the effect of different gauge choices using the Low-Lou and Titov-Demoulin
models of solar active regions. Our numerical code to compute appropriate
vector potentials and relative field-line helicity in Cartesian domains is open
source and freely available.
