Joël Bleuse on Mon, 11 Mar 2024 13:50:32 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: which LaTeX package for Pari/GP scripts ?


Thank you very much: it works perfectly.

    Joël


Le 11/03/2024 à 13:24, Loïc Grenié a écrit :
Le lun. 11 mars 2024 à 11:28, Joël Bleuse <joel.bleuse@cea.fr> a écrit :

Hello,

I'm currently writing an article where most results were computed with a Pari/GP script. I would like to include it in the methods section, and tried the 'listings' package to do so. Unfortunately, this package does not properly handle Pari comments (\\ seems to be a nightmare for LaTeX).

I even tired to define Pari as a new language, with :

\lstdefinelanguage{parigp}
{    morekeywords={for,if,sum,binomial,my,eval,print,return,vector,write},%
    sensitive=true,%
    morecomment=[l]{//},%
    morecomment=[s]{/*}{*/},%
    literate={//}{\textbackslash\textbackslash}{2},
}

but to no avail...

 
     This might do the trick:

{
    \catcode`\#=0
    \catcode`\\=11
    #lstdefinelanguage{parigp}
    {    morekeywords={for,if,sum,binomial,my,eval,print,return,vector,write},%
        sensitive=true,%
        morecomment=[l]{\\},%
        morecomment=[s]{/*}{*/},%
    }
}

   but I advise against italic for comments (the italic backslashes are really ugly).

        Hope this helps,

             Loïc