  Spectral lines of heavy atomic elements in the ejecta of supernovae and
neutron star mergers can have important contribution to the opacity of the
ejecta matter even when the abundance of the elements is very small. Under
favorable conditions, the line expansion opacity arising from spectral lines
and the expansion of the medium can be orders of magnitude larger than the
opacity of electron scattering. In this paper we derive the formulae for
evaluating the line expansion opacity and its Rosseland mean in an expanding
medium in the framework of special relativity, which can be considered as a
generalization of the previous work in the Newtonian approximation. Then we
compare the derived relativistic formulae to the Newtonian ones to explore the
relativistic effect on the opacity, and test the new formulae with the spectral
lines of some heavy atomic elements. We also derive some approximation formulae
for the Rosseland mean of the line expansion opacity that are easy to use in
numerical works while still maintaining a high enough accuracy relative to
exact solutions. The formulae derived in this paper are expected to have
important applications in radiative problems related to relativistic
astrophysical phenomena such as neutron star mergers, supernovae, and gamma-ray
bursts where relativistic or subrelativistic expansions are involved.
