Run

SetDirectory["C:\\drorbn\\AcademicPensieve\\Projects\\Discovery-2024"];
nb2tex["MathematicaInserts",PDFWidth->4.2];

Inserts

<< KnotTheory`

Rot[pd_PD]:=Module[{n,xs,x,rots,Xp,Xm,front={1},k},
n=Length@pd;rots=Table[0,{2n}];
xs=Cases[pd,x_X:>(Piecewise[{{Xp[x[[4]],x[[1]]], PositiveQ@x}, {Xm[x[[2]],x[[1]]], True}}])];
For[k=1,k<=2n,++k,
If[FreeQ[front,-k],
front=Flatten@Replace[front,k->(xs/.{
Xp[k,l_]|Xm[l_,k]:>{l+1,k+1,-l},
Xp[l_,k]|Xm[k,l_]:>(++rots[[l]];{-l,k+1,l+1}),
_Xp|_Xm:>{}
}), {1}],
Cases[front,k|-k]/.{k,-k}:>--rots[[k]];
]
];
{xs/.{Xp[i_,j_]:>{+1,i,j}, Xm[i_,j_]:>{-1,i,j}},rots} ];
Rot[K_]:=Rot[PD[K]];

(Subscript[R, 11])[s_,i_,j_]=s(1/2-(Subscript[g, 3,i,i])+(Subscript[T, 2]^s)(Subscript[g, 1,i,i])(Subscript[g, 2,j,i])-(Subscript[g, 1,i,i])(Subscript[g, 2,j,j])-((Subscript[T, 2]^s)-1)(Subscript[g, 2,j,i])(Subscript[g, 3,i,i])+2(Subscript[g, 2,j,j])(Subscript[g, 3,i,i])-(1-(Subscript[T, 3]^s))(Subscript[g, 2,j,i])(Subscript[g, 3,j,i])-(Subscript[g, 2,i,i])(Subscript[g, 3,j,j])-(Subscript[T, 2]^s)(Subscript[g, 2,j,i])(Subscript[g, 3,j,j])+(Subscript[g, 1,i,i])(Subscript[g, 3,j,j])+(((Subscript[T, 1]^s)-1)(Subscript[g, 1,j,i])((Subscript[T, 2]^(2s))(Subscript[g, 2,j,i])-(Subscript[T, 2]^s)(Subscript[g, 2,j,j])+(Subscript[T, 2]^s)(Subscript[g, 3,j,j]))+((Subscript[T, 3]^s)-1)(Subscript[g, 3,j,i])(1-(Subscript[T, 2]^s)(Subscript[g, 1,i,i])-((Subscript[T, 1]^s)-1)((Subscript[T, 2]^s)+1) (Subscript[g, 1,j,i])+((Subscript[T, 2]^s)-2)(Subscript[g, 2,j,j])+(Subscript[g, 2,i,j])))/((Subscript[T, 2]^s)-1));

(Subscript[R, 12])[{s0_,i0_,j0_},{s1_,i1_,j1_}]=s1((Subscript[T, 1]^s0)-1)((((Subscript[T, 2]^s1)-1))^(-1))((Subscript[T, 3]^s1)-1)(Subscript[g, 1,j1,i0])(Subscript[g, 3,j0,i1])( ((Subscript[T, 2]^s0)(Subscript[g, 2,i1,i0])-(Subscript[g, 2,i1,j0]))- ((Subscript[T, 2]^s0)(Subscript[g, 2,j1,i0])-(Subscript[g, 2,j1,j0])));

(Subscript[Γ, 1])[φ_,k_]=-φ/2+φ (Subscript[g, 3,k,k]);

(Subscript[T, 3])=(Subscript[T, 1])(Subscript[T, 2]);
Θ[K_]:=Module[{Cs,φ,n,A,s,i,j,k,Δ,G,ν,α,β,gEval,c,z},
{Cs,φ}=Rot[K]; n=Length[Cs];
A=IdentityMatrix[2n+1];
Cases[Cs,{s_,i_,j_}:>(A[[{i,j},{i+1,j+1}]]+=(({{-(T^s), (T^s)-1}, {0, -1}})))];
Δ=(T^((-Total[φ]-Total[Cs[[All,1]]])/2))Det[A];
G=Inverse[A];
gEval[ℰ_]:=Factor[ℰ/.(Subscript[g, ν_,α_,β_]):>(G[[α,β]]/.T->(Subscript[T, ν]))];
z=gEval[(∑_(k=1)^n)(Subscript[R, 11])@@Cs[[k]]];
z+=gEval[(∑_(k1=1)^n)(∑_(k2=1)^n)(Subscript[R, 12])[Cs[[k1]],Cs[[k2]]]];
z+=gEval[(∑_(k=1)^(2n))(Subscript[Γ, 1])[φ[[k]],k]];
{Δ,(Δ/.T->(Subscript[T, 1]))(Δ/.T->(Subscript[T, 2]))(Δ/.T->(Subscript[T, 3]))z}//Factor ];

Θ[Knot[3,1]]//Expand

nb2tex

As in http://drorbn.net/AcademicPensieve/Projects/nb2tex/.

SetOptions[$FrontEndSession,PrintingStyleEnvironment->"Working"];
nb2tex[nb_String,opts___Rule]:=nb2tex[nb,nb,opts];

nb2tex[nb_String,tex_String, opts___Rule]:=Module[
{notebook,PDFCounter=0,type,tag,pdfname,cells,cell,c,cl,texfiles={},TeXOut,
PDFFolder=PDFFolder/. {opts}/.PDFFolder->nb
},
nb2tex$TeXFileName=tex<>".tex";
nb2tex$PDFWidth = PDFWidth /. {opts} /. PDFWidth->6.5;
TeXOut[s_String]:=(texfiles=texfiles⋃{nb2tex$TeXFileName};
WriteString[nb2tex$TeXFileName,s]);
notebook=NotebookGet[NotebookOpen@FileNameJoin[{Directory[],nb<>".nb"}]];
If[FileType[PDFFolder]===None, CreateDirectory[PDFFolder]];
DeleteFile/@FileNames["*.pdf",PDFFolder];
cells=Cases[notebook,c_Cell /; Length[c]≥2,∞];
Do[
type=cell[[2]];
tag=CellTags /. Cases[cell,_Rule] /. CellTags->"";
Which[
type=="Text"∧tag=="tex", TeXOut[
StringReplace[cell[[1]],{"’"->"'", "”"->"\""}]<>"\n\n"],
StringMatchQ[tag,"pdf:"~~___], (
pdfname=PDFFolder<>"/"<>StringDrop[tag,4]<>type<>".pdf";
Export[pdfname, Join[cell, Cell[PageWidth -> 80nb2tex$PDFWidth/0.75]]];
cl="c:\\drorbn\\bin\\cpdf.exe -scale-page \"0.75 0.75\" "<>pdfname<>" -o "<>pdfname;
Close@OpenRead["!"<>cl];
),
StringMatchQ[tag,"pdf"~~___], (
pdfname=PDFFolder<>"/"<>ToString[++PDFCounter]<>".pdf";
Export[pdfname, Join[cell, Cell[PageWidth -> 80nb2tex$PDFWidth/0.75]]];
cl="c:\\drorbn\\bin\\cpdf.exe -scale-page \"0.75 0.75\" "<>pdfname<>" -o "<>pdfname;
Close@OpenRead["!"<>cl];
TeXOut[StringReplace[
"\\noindent\\nbpdfXXXType{pdfname}\n\n",
{"XXX"->StringDrop[tag,3], "Type"->type, "pdfname"->pdfname}
]]
),
type=="Input"∧tag=="exec", ToExpression[cell[[1]]],
True, Null
],
{cell,cells}
];
Close/@texfiles;
]