# Update of Gams-Tex

Edson Valle sent me an update for Gams-Tex (see my blog from 28. Januari) where he showed how to add new keywords to the Gams-Tex file (here done for the MPSGE keywords):

Just add the following lines to the gams theme file (theme_gams.tex) after the moreKeywords={
$PROD,$DEMAND, $AUXILIARY,$COMMODITIES, $SECTORS,$CONSUMERS, $MODEL,$REPORT,
It’ll become automatically case insensitive due to the options selected.

# Gams code in LaTeX documents

Edson Valle recently wrote a style for the package listings from LaTeX. It allows you to format Gams code nicely in your LaTeX documents.
Here is a small example taken from his post to the Gams mailing list:
Scalar X /1/;
Scalar Y;
Y = 2*X;
Display “This is the famous Y”, Y;
In your LaTeX document this would look like:
The only thing you have to do is write a file gams.tex with the style and include this file in your LaTeX document before \begin{document}.
Information on the package Listings can be found here: listings
The gams.tex file should look like this:
\usepackage{listings}
%author Edson Cordeiro do Valle edsoncv at gmail dot com

\lstdefinelanguage{GAMS}{
morekeywords={
ABORT , ACRONYM , ACRONYMS , ALIAS , ALL , AND , ASSIGN , BINARY , CARD , DISPLAY , EPS , EQ , EQUATION , EQUATIONS , GE , GT , INF , INTEGER , LE , LOOP , LT , MAXIMIZING , MINIMIZING , MODEL , MODELS , NA , NE , NEGATIVE , NOT , OPTION , OPTIONS , OR , ORD , PARAMETER , PARAMETERS , POSITIVE , PROD , SCALAR , SCALARS , SET , SETS , SMAX , SMIN , SOS1 , SOS2 , SUM , SYSTEM , TABLE , USING , VARIABLE , VARIABLES , XOR , YES , REPEAT , UNTIL , WHILE , IF , THEN , ELSE , SEMICONT , SEMIINT , FILE , FILES , PUT , PUTPAGE , PUTTL , PUTCLOSE , FREE , NO , SOLVE , FOR , ELSEIF , ABS , ARCTAN , CEIL , COS , ERROR , EXP , FLOOR , LOG , LOG10 , MAP , MAPVAL , MAX , MIN , MOD , NORMAL , POWER , ROUND , SIGN , SIN , SQR , SQRT , TRUNC , UNIFORM , LO , UP , FX , SCALE , PRIOR , PC , PS , PW , TM , BM , CASE , DATE , IFILE , OFILE , PAGE , RDATE , RFILE , RTIME , SFILE , TIME , TITLE , TS , TL , TE , TF , LJ , NJ , SJ , TJ , LW , NW , SW , TW , ND , NR , NZ , CC , HDCC , TLCC , LL , HDLL , TLLL , LP , WS , /,PROD: },
sensitive = false,
morecomment=[f]*,%
morecomment=[s]{$ontext}{$offtext},
morecomment=[s][\color{green}]{/}{/},
morestring=[b]”,
morestring=[b]’
}
\lstset{
basicstyle=\fontfamily{pcr}\fontseries{m}\selectfont\footnotesize,
keywordstyle=\color{blue}\bfseries,
stringstyle=\color[rgb]{0.5,0,0.5}\itshape,
showstringspaces=false,
numbers=left,
numberstyle=\color[rgb]{0,0.5,0.5}\fontfamily{pcr}\fontseries{m}\selectfont\tiny,
numberblanklines=false,
showlines=false,
belowskip=\bigskipamount{},
breaklines=true,
%stepnumber=2,
tabsize=6,
%extendedchars=true,
%float=h,
frame=tb
}

# Excel-Addin for converting Excel tables to LaTeX tables

Although I am not a great fan of the Microsoft software, I have to admit that Excel is great. Sending tables from Excel to Word is easy but I work in LaTeX and then it can be time consuming. Fortunately there is a nice add-in for Excel that allows you to copy your Excel table to LaTeX. It is called Excel2LaTeX and developed by Joachim Marder and Andrew Hawryluk and can be downloaded from http://www.ctan.org/tex-archive/support/excel2latex/. I tested it with Excel 2010 and it works fine.

When you download the file Excel2LaTeX.xla you can either open it when you need it or if you use it often save it in your Excel add-in directory.
Most of the text formatting, border lines  and even multi-column cells are retained.
Text formatting (bold, italic) is retained and multi-column cells are supported. The LaTeX code can be copied to the clipboard or saved as a LaTeX file, which then can be included in an existing LaTeX document using the \input command.

Here a small example: First the excel table:

and here the code generated by Excel2LaTeX

% Table generated by Excel2LaTeX from sheet ‘Estimation LES’
\begin{table}[htbp]
\centering
\begin{tabular}{rrrrrrr}
\toprule
{\bf } & \multicolumn{ 6}{|c}{{\bf from the Estimation}} \\
\midrule
{\bf Good} & {\bf Alpha} & {\bf Constant} & {\bf Number of hh} & {\bf R-Adjusted} & {\bf s.e. Alpha} & {\bf s.e. Constant} \\
agr   & 0.01  & 68.79 & 8262  & 0.29  & 0.00  & 3.75 \\
fd    & 0.03  & 329.83 & 8262  & 0.20  & 0.00  & 16.15 \\
mnf   & 0.14  & -365.17 & 8262  & 0.67  & 0.01  & 52.49 \\
ppp   & 0.01  & -16.51 & 8262  & 0.32  & 0.00  & 8.54 \\
ene   & 0.03  & -26.40 & 8262  & 0.46  & 0.00  & 24.08 \\
crp   & 0.02  & -45.15 & 8262  & 0.72  & 0.00  & 6.41 \\
nmm   & 0.00  & -4.34 & 8262  & 0.29  & 0.00  & 1.51 \\
\bottomrule
\end{tabular}