The overflowing problem is well known to us. Unfortunately so far we do not have a general solution for this. model2tex is written in Python and implements a stack machine that works on the instructions generated by the GAMS compiler. If you put a
$debug dmpins at the end of a model you can look at the generated instructions in the .lst file. E.g. for the
cost equation of the transport model from the GAMS Model Library we get the following instructions:
Code: Select all
20 0 UnitBeg 1 56
21 14 DefBeg 0 144 cost
22 55 EndLhs 0 0
23 2 Push 0 143 z
24 29 SumBeg 0 0
25 7 CntrBeg 0 135 i
26 7 CntrBeg 0 136 j
27 12 Index 0 1
28 12 Index 0 2
29 2 Push 0 141 c
30 12 Index 0 1
31 12 Index 0 2
32 2 Push 0 142 x
33 4 MultOp 0 0
34 30 SumOp 0 0
35 8 CntrEnd 0 0
36 8 CntrEnd 0 0
37 42 EquOp 0 0
38 15 DefOp 0 144 cost
39 16 DefEnd 0 144 cost
40 1 UnitEnd 0 0
While the instructions are relatively straight forward for simple models, they can become quite complicated for larger and more sophisticated ones.
The way model2tex generates the LaTeX output is just one way of doing so. There are several other formulations which might be better or worse depending on the context and the actual equation. Right now the best way to influence the output of model2tex is to use the JSON file, especially the
nameMap that allows to replace GAMS symbols by user defined identifiers and the
landscape flag that might reduce the extend of the overflowing equations. Please see the documentation on this:
https://www.gams.com/latest/docs/T_MODEL2TEX.html#JSON
If you really want to modify the structure of the output it might be best to change the generated LaTeX file afterwards, either manually or by using a script.
Hope that helps,
Clemens