  The fragmentation properties of jets containing $b$-hadrons are studied using
charged $B$ mesons in 139 fb$^{-1}$ of $pp$ collisions at $\sqrt{s} = 13$ TeV,
recorded with the ATLAS detector at the LHC during the period from 2015 to
2018. The $B$ mesons are reconstructed using the decay of $B^{\pm}$ into
$J/\psi K^{\pm}$, with the $J/\psi$ decaying into a pair of muons. Jets are
reconstructed using the anti-$k_t$ algorithm with radius parameter $R=0.4$. The
measurement determines the longitudinal and transverse momentum profiles of the
reconstructed $B$ hadrons with respect to the axes of the jets to which they
are geometrically associated. These distributions are measured in intervals of
the jet transverse momentum, ranging from 50 GeV to above 100 GeV. The results
are corrected for detector effects and compared with several Monte Carlo
predictions using different parton shower and hadronisation models. The results
for the longitudinal and transverse profiles provide useful inputs to improve
the description of heavy-flavour fragmentation in jets.
