  Jet fragmentation transverse momentum ($j_{\rm T}$) distributions are
measured in proton-proton (pp) and proton-lead (p-Pb) collisions at
$\sqrt{s_{\rm NN}}$ = 5.02 TeV with the ALICE experiment at the LHC. Jets are
reconstructed with the ALICE tracking detectors and electromagnetic calorimeter
using the anti-$k_{\rm T}$ algorithm with resolution parameter $R=0.4$ in the
pseudorapidity range $|\eta|<0.25$. The $j_{\rm T}$ values are calculated for
charged particles inside a fixed cone with a radius $R = 0.4$ around the
reconstructed jet axis. The measured $j_{\rm T}$ distributions are compared
with a variety of parton-shower models. Herwig and PYTHIA 8 based models
describe the data well for the higher $j_{\rm T}$ region, while they
underestimate the lower $j_{\rm T}$ region. The $j_{\rm T}$ distributions are
further characterised by fitting them with a function composed of an inverse
gamma function for higher $j_{\rm T}$ values (called the "wide component"),
related to the perturbative component of the fragmentation process, and with a
Gaussian for lower $j_{\rm T}$ values (called the "narrow component"),
predominantly connected to the hadronisation process. The width of the Gaussian
has only a weak dependence on jet transverse momentum, while that of the
inverse gamma function increases with increasing jet transverse momentum. For
the narrow component, the measured trends are successfully described by all
models except for Herwig. For the wide component, Herwig and PYTHIA 8 based
models slightly underestimate the data for the higher jet transverse momentum
region. These measurements set constraints on models of jet fragmentation and
hadronisation.
