Not really an expert at this S-version PWM, but one thing the pulse width modulator must do is decide when to turn on and when to turn off, or when should be high and when should be low.
Usually pulses have a fixed frequency and one controlls the width, the time the pulse spends high and low.
Each pulse, being fixed height corresponds to energy proportional to its width,, each delivering a packet of energy, proportional to the width of that pulse.
So this is linear with width,
The sides oof a triangle, or one-sided sawtooth, are linear with time.
So if we draw the sinusoid that we want and draw also a trinagle wave, or one-sided sawtoth, where the width, period of the saw tooth is the same as the maximum pulse width, the time the sawtooth is above the sinusoid tells us when it would be too high. The time below the sine tells us when is is lower than needed.
That is the time that triangle signal the crosses to above the sine signal is the time to switch the drive, pulse off.
.
I'll try to post the figure in the document posted by bertus.

Or if you prefer from
https://electronics.stackexchange.com/questions/214902/pwm-frequency-and-lc-filter
Obviously, the resultant is only sinusoidal in some average sense. As basically a series of squange pulses, there are a lot of harmonics. Smoothing can follow, or be done as part of the load.
Moving the pulses round, or subtly changing their position can change the harmonic content. Sometime harmonic content is important.