Calculations for electrons and light in layered media