  The CARMENES survey is searching for Earth-like planets orbiting M dwarfs
using the radial velocity method. Studying the stellar activity of the target
stars is important to avoid false planet detections and to improve our
understanding of the atmospheres of late-type stars. In this work we present
measurements of activity indicators at visible and near-infrared wavelengths
for 331 M dwarfs observed with CARMENES. Our aim is to identify the activity
indicators that are most sensitive and easiest to measure, and the correlations
among these indicators. We also wish to characterise their variability. Using a
spectral subtraction technique, we measured pseudo-equivalent widths of the He
I D3, H$\alpha$, He I $\lambda$10833 {\AA}, and Pa$\beta$ lines, the Na I D
doublet, and the Ca II infrared triplet, which have a chromospheric component
in active M dwarfs. In addition, we measured an index of the strength of two
TiO and two VO bands, which are formed in the photosphere. We also searched for
periodicities in these activity indicators for all sample stars using
generalised Lomb-Scargle periodograms. We find that the most slowly rotating
stars of each spectral subtype have the strongest H$\alpha$ absorption.
H$\alpha$ is correlated most strongly with He I D3, whereas Na I D and the Ca
II infrared triplet are also correlated with H$\alpha$. He I $\lambda$10833
{\AA} and Pa$\beta$ show no clear correlations with the other indicators. The
TiO bands show an activity effect that does not appear in the VO bands. We find
that the relative variations of H$\alpha$ and He I D3 are smaller for stars
with higher activity levels, while this anti-correlation is weaker for Na I D
and the Ca II infrared triplet, and is absent for He I $\lambda$10833 {\AA} and
Pa$\beta$. Periodic variation with the rotation period most commonly appears in
the TiO bands, H$\alpha$, and in the Ca II infrared triplet.
