Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions devel/213_23.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# [213_23] Fix piecewise function LaTeX import with aligned environment

Issue: https://github.com/MoganLab/mogan/issues/2733

When importing LaTeX code like `\left\{\begin{aligned}...\end{aligned}\right.`, the `aligned` environment inside `\left\{...\right.` was not recognized as a matrix-like environment, causing broken layout for piecewise functions.

## Root Cause
The `aligned` environment was not handled in `finalize_pmatrix` or `parse_pmatrix`, so it was passed through as raw BEGIN/END tokens instead of being converted to a proper table structure.

## Changes
- `src/Plugins/Tex/fromtex_post.cpp`:
- Added `aligned` as a recognized environment in `finalize_pmatrix`, converting it to `tabular*` format (same as `array`)
- Added `END "aligned"` as a break condition in `parse_pmatrix`

The `\left\{` and `\right.` delimiters are already handled by the existing LEFT/RIGHT processing, so the aligned content inside will now be properly laid out as a table within the braces.
2 changes: 2 additions & 0 deletions src/Plugins/Tex/fromtex_post.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ parse_pmatrix (tree& r, tree t, int& i, string lb, string rb, string fm) {
else if (v == tree (END, "bmatrix")) break;
else if (v == tree (END, "vmatrix")) break;
else if (v == tree (END, "smallmatrix")) break;
else if (v == tree (END, "aligned")) break;
else if (v == tree (APPLY, "hline")) {
int howmany= 1;
while (i + 1 < N (t) &&
Expand Down Expand Up @@ -446,6 +447,7 @@ finalize_pmatrix (tree t) {
u[i][0] == "tabularx" || u[i][0] == "tabularx*")
parse_pmatrix (r, u, i, "", "", "tabular*");
else if (u[i][0] == "cases") parse_pmatrix (r, u, i, "", "", "choice");
else if (u[i][0] == "aligned") parse_pmatrix (r, u, i, "", "", "tabular*");
else if (u[i][0] == "stack") parse_pmatrix (r, u, i, "", "", "stack");
else if (u[i][0] == "matrix")
parse_pmatrix (r, u, i, "", "", "tabular*");
Expand Down