Beji Caid Sebsi, the Tunisian president, declared a nationwide state of emergency and a curfew in the capital after a bomb attack on a presidential guard bus killed at least 12 people on Tuesday.