World chess number one Magnus Carlsen has quit a major tournament after being told he couldn't wear jeans.