  Complex (iso-)nitrile molecules, such as CH3CN and HC3N, are relatively
easily detected in our Galaxy and in other galaxies. We constrain their
chemistry through observations of two positions in the Horsehead edge: the
photo-dissociation region (PDR) and the dense, cold, and UV-shielded core just
behind it. We systematically searched for lines of CH3CN, HC3N, C3N, and some
of their isomers in our sensitive unbiased line survey at 3, 2, and 1mm. We
derived column densities and abundances through Bayesian analysis using a large
velocity gradient radiative transfer model. We report the first clear detection
of CH3NC at millimeter wavelength. We detected 17 lines of CH3CN at the PDR and
6 at the dense core position, and we resolved its hyperfine structure for 3
lines. We detected 4 lines of HC3N, and C3N is clearly detected at the PDR
position. We computed new electron collisional rate coefficients for CH3CN, and
we found that including electron excitation reduces the derived column density
by 40% at the PDR position. While CH3CN is 30 times more abundant in the PDR
than in the dense core, HC3N has similar abundance at both positions. The
isomeric ratio CH3NC/CH3CN is 0.15+-0.02. In the case of CH3CN, pure gas phase
chemistry cannot reproduce the amount of CH3CN observed in the UV-illuminated
gas. We propose that CH3CN gas phase abundance is enhanced when ice mantles of
grains are destroyed through photo-desorption or thermal-evaporation in PDRs,
and through sputtering in shocks. (abridged)

Astrophysics of Galaxies