This question is mainly about exporting to HTML/TeX. For those of you who do not know how to write aligned equations in Mathematica please see this answer. Lets assume that you modified your stylesheet as I mentioned in my answer. In my notebook this is the cell expression I have:
Cell[BoxData[
FormBox[GridBox[{
{
RowBox[{
RowBox[{"a", "+", "b", "+", "c"}], "\[AlignmentMarker]", "=", "d"}]},
{
RowBox[{"c", "\[AlignmentMarker]", "=",
RowBox[{"d", "-", "a", "-", "b"}]}]}
}], TraditionalForm]], "DisplayMath"]
Now I want to export this expression to TeX, we can do this with:
cell = Cell[BoxData[
FormBox[GridBox[{
{
RowBox[{
RowBox[{"a", "+", "b", "+", "c"}], "\[AlignmentMarker]", "=", "d"}]},
{
RowBox[{"c", "\[AlignmentMarker]", "=",
RowBox[{"d", "-", "a", "-", "b"}]}]}
}], TraditionalForm]], "DisplayMath"];
Convert`TeX`BoxesToTeX[cell]
The output is:
\begin{array}{c}
a+b+c=d \\
c=d-a-b
\end{array}
The function Convert`TeX`BoxesToTeX
is undocumented but the documentation does show how to use it under examples. It seems that the function doesn't do anything with the \[AligmentMarker]
, but I'm sure we could make good use of them.
What we want to do is find any appearances of the \[AligmentMarker]
and substitute them with "&". And if we did find some \[AligmentMaker]
s then we use StringReplace to change "array" for "aligned". This is the output that I would like to end up with:
\begin{aligned}
a+b+c&=d \\
c&=d-a-b
\end{aligned}
Does anyone know how to create a wrapper function that does this? The main problem I'm having is replacing things in cell
.