Emergent Dirac fermions and broken symmetries in confined and deconfined phases of Z 2 gauge theories