Open vsht opened 4 years ago
As far as I remember I considered boxes produced by MakeBoxes
to be the only valid ones, and MakeBoxes
gives boxes with strings. But e.g. MakeExpression
is more lenient and accepts boxes with "raw" symbols or numbers, so maybe current behavior of CellToTeX
is to strict.
Until this is changed in package, a workaround is to add relevant pattern to $basicBoxes
:
PrependTo[$ContextPath, "CellsToTeX`Configuration`"];
AppendTo[$basicBoxes, _Integer]
As to StyleBox
, handling it in full generality is difficult on the TeX side. By default StyleBox
es are simply ignored. For simple case, as above, you could add additional rule to handle it, e.g. with \textbf
, on the TeX side:
PrependTo[$linearBoxesToTeX, StyleBox[b_, Bold, ___] :> "\\textbf{" <> makeString@b <> "}"]
After above two changes CellToTeX
on original cell should give:
\begin{mmaCell}{Output}
\mmaFrac{1}{(\mmaSup{\textbf{k}}{2}-i \(\eta\))}
\end{mmaCell}
Thanks, this workaround works nicely!
Just as a reminder for my future self. This
PrependTo[$linearBoxesToTeX,
StyleBox[b_, ___, FontWeight -> Bold, ___] :>
"\\textbf{" <> makeString@b <> "}"]
is also needed to get some bold symbols converted properly.
The following code cannot be processed by
CellToTeX
yet if I change
2
in theSuperscriptBox
to"2"
it works fineproducing
The bold styling of
k
is lost, but this is a lesser issue.The input is a produced by some custom typesetting rules used in
FeynCalc
so this is probably a not very common issue. Still, I'm wondering if there are any fundamental reasons why every non-box inside a box must be a string forCellToTeX
to work properly?