Cubans have approved a sweeping “family law” code that will allow same-sex couples to marry and adopt as well as redefining rights for children and grandparents, officials said on Monday, though opposition in the national referendum was unusually strong on the Communist Party-governed island.