  Precise interstellar dust extinction laws are important to infer the
intrinsic properties of reddened objects and correctly interpret observations.
In this work, we attempt to measure the optical--infrared extinction laws of
the Large and Small Magellanic Clouds (LMC and SMC) by using red supergiant
(RSG) stars and classical Cepheids as extinction tracers. The spectroscopic RSG
samples are constructed based on the APOGEE spectral parameters, Gaia
astrometric data, and multi-band photometry. We establish the effective
temperature--intrinsic color relations for RSG stars and determine the color
excess ratio (CER) E(lambda-GRP)/E(GBP-GRP) for LMC and SMC. We use classical
Cepheids to derive base relative extinction A_GRP/E(GBP-GRP). The results are
1.589+-0.014 and 1.412+-0.041 for LMC and SMC. By combining CERs with A_GRP
/E(GBP-GRP), the optical--infrared extinction coefficients A_lambda/A_GRP are
determined for 16 bands. We adjust the parameters of Rv-dependent extinction
laws and obtain the average extinction law of LMC and SMC as Rv=3.40+-0.07 and
Rv=2.53+-0.10, which are consistent with Gordon et al. (2003). In the optical
bands, the adjusted Rv extinction curves agree with the observations with
deviations less than 3%.
