  Complex absorbing potentials (CAPs) are artificial potentials added to
electronic Hamiltonians to make the wave function of metastable electronic
states square-integrable. This makes electronic-structure theory of resonances
comparable to that of bound states, thus reducing the complexity of the
problem. However, the most often used box and Voronoi CAPs depend on several
parameters that have a substantial impact on the numerical results. Among these
parameters are the CAP strength and a set of spatial parameters that define the
onset of the CAP. It has been a common practice to minimize the perturbation of
the resonance states due to the CAP by optimizing the strength parameter while
fixing the onset parameters although the performance of this approach strongly
depends on the chosen onset. Here we introduce a more general approach that
allows one to optimize not only the CAP strength but also the spatial
parameters. We show that fixing the CAP strength and optimizing the spatial
parameters is a reliable way for minimizing CAP perturbations. We illustrate
the performance of this new approach by computing resonance energies and widths
of the temporary anions of dinitrogen, ethylene, and formic acid. This is done
at the Hartree-Fock and equation-of-motion coupled-cluster singles and doubles
levels of theory, using full and projected box and Voronoi CAPs.
