Perhaps there was too much nesting. Try this variation with fo:
With[{order = "Lexicographic"},
StringJoin[
Riffle[Table[
poly = MonomialList[K[Sqrt[#]/Tanh[Sqrt[#]] &, i] /. c -> p,
Table[Subscript[p, k], {k, 1, 7}], order];
gcd = GCD @@ poly /. Rational[n_, d_]*c_ :> d;
ToString[
Inactive[Set][Subscript[L, i],
DisplayForm@
RowBox[{1/primeFactorForm[gcd], "(",
RowBox[Flatten[(List @@
Distribute[gcd*poly]) /. {Times[Rational[n_, d_],
e__] :> {If[n/d > 0, "+", "-"],
primeFactorForm[Abs@n]/primeFactorForm[Abs@d], e},
Times[n_Integer, e__] :> {If[n > 0, "+", "-"],
primeFactorForm[Abs@n], e}}] /. {"+", a___} :> {a}],
")"}]], TeXForm],
{i, 3, 7}],
"\\\\"]]]
Over my 25+ years of usage I have learned a fair number of tricks. Unfortunately, the precise formatting of expressions is not easy in Mathematica. As a gateway into the subject, I would suggest the documentation on RowBox. Don't forget to wrap everything into DisplayForm. An occasional peek into CellExpression may give clues on low-level box structures.