Get[NotebookDirectory[]<>"PolyLogToolsLite.m"];

Get[NotebookDirectory[]<>"wt5_bruteforce_i32_as_i41_and_li5.m"];

I32[x_,y_] := G[0,y, 0, 0, x, 1];
I41[x_,y_] := G[y,0, 0, 0, x, 1];
L5[x_] := -G[0, 0, 0, 0, 1/x, 1];

leading = wt5i32asi41idleading;

li5s = wt5i32asi41idli5s/.{L5c[a_,b_,c_]:>a L5i[b Times@@({x, 1-x, y, 1-y,x-y}^c)]};

(leading - li5s)/.{I32i->I32,I41i->I41,L5i->L5}//CreateTensor//sh//flatTensor//Expand

(* Now LaTeX the results *)

<<TeXUtilities`

myFold[f_,l_List]:=Fold[f,l[[1]],l[[2;;All]]]
myTeXList[l_List]:=TeXForm[TeXVerbatim[myFold[#1<>", "<>#2&,ToString[TeXForm[#]]&/@l]]]

Format[L5c[coeff_,sgn_,factors_List],TeXForm]:=TeXVerbatim["\\{"<>If[sgn === 1, "+", "-"]<>"; "<>ToString[myTeXList[factors]]<>"\\}"];

arg[L5c[a_,b_,c_]] := {a,b,c};
arg[q_?NumericQ L5c[a_,b_,c_]] := {a,b,c};

gath = GatherBy[List@@wt5i32asi41idli5s, arg[#][[1]]&];

texLi5s := If[arg[#[[1]]][[1]] ==1, "", ToString[TeXForm[arg[#[[1]]][[1]]]] <> " "] <>"\\Li_5( "<>
StringReplace[ToString[TeXForm[Total[#]]], {"\\}+\\{"->"\\}\n + \\{","\\}-\\{"->"\\}\n - \\{"}]<>" )"&;

Fold[#1 <> " + {} \\\\ \n & {} + " <> #2&, texLi5s/@gath]