Measurements of the structure of quark and gluon jets in hadronic Z decays