Tunisian troops killed a gunman and captured three others on Sunday after they attacked soldiers guarding ballot papers for the country's presidential vote, the defence ministry said.