First-principles optical spectra of low dimensional systems