Electric and magnetic superlattices in trilayer graphene