Karim Belabas on Tue, 05 Feb 2019 19:21:04 +0100


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

Re: texi_sign()


* Oliver Bandel [2019-02-05 18:28]:
> Quoting  Karim Belabas <Karim.Belabas@math.u-bordeaux.fr> (snt: 2019-02-05 15:26 +0100 CET) (rcv: 2019-02-05 15:26 +0100 CET):
>> * Oliver Bandel [2019-02-04 21:38]:
>>> In
>>>   src/language/es.c
>>> there is the function texi_sign(), which creates
>>> TeX-output.
>>> 
>>> I used gp for some calculations and writetex()
>>> for putting the results into a *.tex file.
>>> 
>>> The output is ok for plain-TeX
>>>, but for LaTeX it should look different.
>>> 
>>> There is \pmatrix{} for TeX, but in LaTeX it would be
>>> \begin{array} and \end{array},
>>> or with amsmath-package it would be
>>> \begin{pmatrix} and \end{pmatrix}.
>> 
>> Hello Oliver,
>> 
>> This problem came up before and I decided NOT to add (or overload) another
>> obscure option. TeX or LaTeX are exceedingly (re)configurable via style
>> files which makes the annoyance of updating our TeX markup each time a
>> popular package author breaks compatibility unnecessary. For instance
>> 
>>   % using plain TeX: t_FRAC are typeset using \frac
>>   \def\frac#1#2{{#1\over#2}}
>> 
>>   % using LaTeX + amsmath: the package authors broke \pmatrix on purpose
>>   % replace by equivalent amsmath construct
>>   \def\pmatrix#1{\begin{pmatrix}#1\end{pmatrix}}
>[...]

>> * Karim Belabas [2019-02-05 15:26]:
>> [...]
>> >   % using LaTeX + amsmath: the package authors broke \pmatrix on purpose
>> >   % replace by equivalent amsmath construct
>> >   \def\pmatrix#1{\begin{pmatrix}#1\end{pmatrix}}
>> [...]
>>
>> This one doesn't work. Here is a less naive override:
>>
>>   \makeatletter
>>   \def\pmatrix#1{\left(\env@matrix#1\endmatrix\right)}
> 
> 
> Hello Karim,
> 
> don't see a solution to my problem here.
> 
> What do I have to do, to include gp-output into my LaTeX-document with/without
> amsmath-package? And does this solution also allow me to stretch the matrix
> with \arraystretch?


1) Without amsmath: GP produces correct tex output. If you don't like the 
way plain tex typesets \pmatrix, you can override it as usual in TeX style
files or headers, no need to change GP.

2) With amsmath: compilation breaks, because \pmatrix is now forbidden. So
again you redefine it, e.g. add in a pari.sty file [ my preference ] 

   \def\pmatrix#1{\left(\env@matrix#1\endmatrix\right)}
   % then you must add \usepackage{pari} in your files.

or, in the header of your LaTeX document

   \makeatletter
   \def\pmatrix#1{\left(\env@matrix#1\endmatrix\right)}

Et voila: \pmatrix now follows the \arraystretch value, because it is
internally replaced by the equivalent of \begin{pmatrix} ... \end{pmatrix}.

My point is that, as long as you have an actual TeX markup to start with
(even the outdated one produced by GP), such typesetting changes can be done
transparently from the TeX side alone. More flexible than complicating a
(rigid) C interface.

Cheers,

    K.B.
--
Karim Belabas, IMB (UMR 5251)  Tel: (+33) (0)5 40 00 26 17
Universite de Bordeaux         Fax: (+33) (0)5 40 00 21 23
351, cours de la Liberation    http://www.math.u-bordeaux.fr/~kbelabas/
F-33405 Talence (France)       http://pari.math.u-bordeaux.fr/  [PARI/GP]
`