Documente Academic
Documente Profesional
Documente Cultură
GAMS Documentation 24.7 > Tools > Other Tools
MODEL2TEX - A Tool to generate a documentation from GAMS source code in LaTeX format
Author
Table of Contents
Clemens Westphal
Introduction
Special thanks to Ingmar Schlecht for supporting us and sharing his gamsToLatex implementation. Usage
Options
Introduction Using a JSON style file
Example
MODEL2TEX is a tool to generate a documentation from GAMS source code in LaTeX format. This LaTeX output can then be further
processed in order to generate pretty output files like PDF. The tool can be found in the root directory of GAMS. The tool allows to
document one specific model symbol inside of a GAMS program. The resulting documentation contains two parts. The first part shows a list of symbols that are used by the
model. The second part shows the actual algebra of the used equations and information about the types of used variables. An optional third part can contain additional notes.
Usage
MODEL2TEX is a command line tool. The general command line usage is as follows:
model2tex baseName [‐h] [‐m MODEL] [‐f] [‐o OUTPUT]
Since it operates on output files generated by GAMS, the first step is to generate the required files using the docfile option. In order to to that, execute the following command
line:
gams myModel.gms docfile=myModel
The second step is to call MODEL2TEX: On Windows the tool is shipped as an executable file. On Linux, the original Python source code is distributed. Therefore the usage differs
and requires a Python 2 installation on Linux.
Windows:
model2tex myModel [‐m MODEL] [‐f] [‐o OUTPUT]
Linux:
python model2tex.py myModel [‐m MODEL] [‐f] [‐o OUTPUT]
The output file myModel.tex can be further processed for example by calling pdflatex in order to generate a PDF file.
pdflatex myModel.tex
Options
The following parameters can be used when calling MODEL2TEX:
Parameter Description
‐m model Since MODEL2TEX generates documentation for one model symbol, the model name needs to be specified explicitly, if the GAMS file contains more than one
model symbol
‐f MODEL2TEX does not allow the occurrence of suffixes in equations. This option can be used in order to force the creation of the tex file by skipping the checks
for suffixes.
‐o output Use this name for the generated TeX file instead of the base name.
https://www.gams.com/help/index.jsp?topic=%2Fgams.doc%2Ftools%2Fmodel2tex%2Findex.html 1/3
2/10/2016 MODEL2TEX A Tool to generate a documentation from GAMS source code in LaTeX format
threshold for reduceFrac.
latexDescription false Explanatory text for symbols is expected to be arbitrary text. In order to display the text correctly in LaTeX, some automatic adjustments
are applied. If all explanatory text already contains valid LaTeX strings, this option can be enabled.
nameMap the This map allows to specify alternative names for symbols.
original
names
extraSymbols empty list On default, only the required symbols in a GAMS model symbol are contained in the generated LaTeX file. This list can be used in order to
specify further symbols that should be included as well.
notes empty list Allows to specify additional notes for the documentation. Each list element will result in a new line.
Example
This example creates a PDF file for the pump model from the GAMS Model Library.
The following pictures show snippets from the resulting PDF file:
5. Customizing the JSON style file In order to change the appearance of the PDF file, the generated JSON file pump.json can be modified. Changing the options in
pump.json according to the picture and executing the commands from step 3 and 4 again will result in a customized PDF output.
https://www.gams.com/help/index.jsp?topic=%2Fgams.doc%2Ftools%2Fmodel2tex%2Findex.html 2/3
2/10/2016 MODEL2TEX A Tool to generate a documentation from GAMS source code in LaTeX format
https://www.gams.com/help/index.jsp?topic=%2Fgams.doc%2Ftools%2Fmodel2tex%2Findex.html 3/3