Oliver Bandel on Tue, 05 Feb 2019 19:58:49 +0100


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

Re: texi_sign()


Quoting  Karim Belabas <Karim.Belabas@math.u-bordeaux.fr> (snt: 2019-02-05 19:20 +0100 CET) (rcv: 2019-02-05 19:21 +0100 CET):
> * 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)}

Ah, ok.

So there are the following solutions for gp-out-of-the-box output:
  - plain-TeX without amsmath
  - LaTeX with amsmath and the above mentioned code-snippet.

But not LaTeX without amsmath.

Good to know.

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

Yes, that works, thank you for the clarification.

> 
> 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.
[...]

I can see this, yes.

IMO it would make sense to add your explanation to the documentation,
and maybe even add the TeX- and LaTeX-Snippets to the sources / distribution,
and/or put it onto CTAN.

Regards,
  Oliver Bandel

P.S.: Minimalistic pari.sty attached. (maybe parigp.sty would be a better name?)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Including this package allows to use PARI/GP-output %
% written by the writetex() function of gp directly   %
% inside LaTeX.                                       %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ProvidesPackage{pari}[2019/02/05]

\RequirePackage{amsmath}

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