  Light from celestial objects interacts with the molecules of the Earth's
atmosphere, resulting in the production of telluric absorption lines in
ground-based spectral data. Correcting for these lines, which strongly affect
red and infrared wavelengths, is often needed in a wide variety of scientific
applications. Here, we present the template division telluric modeling (TDTM)
technique, a method for accurately removing telluric absorption lines in stars
that exhibit numerous intrinsic features. Based on the Earth's barycentric
motion throughout the year, our approach is suited for disentangling telluric
and stellar spectral components. By fitting a synthetic transmission model,
telluric-free spectra are derived. We demonstrate the performance of the TDTM
technique in correcting telluric contamination using a high-resolution optical
spectral time series of the feature-rich M3.0 dwarf star Wolf 294 that was
obtained with the CARMENES spectrograph. We apply the TDTM approach to the
CARMENES survey sample, which consists of 382 targets encompassing 22357
optical and 20314 near-infrared spectra, to correct for telluric absorption.
The corrected spectra are coadded to construct template spectra for each of our
targets. This library of telluric-free, high signal-to-noise ratio,
high-resolution (R>80000) templates comprises the most comprehensive collection
of spectral M-dwarf data available to date, both in terms of quantity and
quality, and is available at the project website
(http://carmenes.cab.inta-csic.es).
