The distributions of transverse momentum and longitudinal momentum fraction of charged particles in jets are measured in Pb+Pb and pp collisions with the ATLAS detector at the LHC. The distributions are measured as a function of jet transverse momentum and rapidity. The analysis utilises an integrated luminosity of 0.14 nb-1 of Pb+Pb data and 4.0 pb-1 of pp data collected in 2011 and 2013, respectively, at the same centre-of-mass energy of 2.76 TeV per colliding nucleon pair. The distributions measured in pp collisions are used as a reference for those measured in Pb+Pb collisions in order to evaluate the impact on the internal structure of jets from the jet energy loss of fast partons propagating through the hot, dense medium created in heavy-ion collisions. Modest but significant centrality-dependent modifications of fragmentation functions in Pb+Pb collisions with respect to those in pp collisions are seen. No significant dependence of modifications on jet pT and rapidity selections is observed except for the fragments with the highest transverse momenta for which some reduction of yields is observed for more forward jets.