17

I decided to look if the solution Caramdir gave in this question would work as well for my attempts to use a new notation for hypergeometric functions. However, trying

{}_3 F_2\left(\begin{matrix}a& &b& &c\\&d& &e&\end{matrix}\middle;z\right)

resulted in the arguments before the semicolon being too widely spaced. I could of course just give up on the "staggered array notation" and align by columns what can be aligned by columns, or just use a two row, one column matrix and then use commas as delimiters, but I kind of like to see how to do a staggered array in LaTeX, and reserve matrix for the case of the number of parameters in both rows being equal.

So, how does one do a tighter looking (but still nicely spaced) staggered array?

  • I am not sure a staggered array is a way to go here, what if you need to do something like {}_3 F_2\left(\begin{matrix}a-b+1& &b+a-1& &c+d-1\\&d-a+1& &e+d-b-1&\end{matrix}\middle;z\right), even if you make the the array tighter, there will still be a lot of space left. How about something like this: {}_3 F_2\left(\begin{matrix}a\quad b\quad c\\d\quad e\end{matrix}\middle;z\right)? – Jan Hlavacek Aug 29 '10 at 04:34
  • That doesn't compile for me because ; isn't a math delimiter. – TH. Aug 29 '10 at 05:08
  • I've seen it with both semicolons and bars delimiting the argument from the parameters. I guess any of the two would work for me. –  Aug 29 '10 at 07:29
  • 2
    To get prepended subscripts, you may also consider using the tensor package, see http://tex.stackexchange.com/questions/334/non-kludgey-left-subscripts – Willie Wong Aug 29 '10 at 15:08

5 Answers5

12
\setlength\arraycolsep{1pt}
{}_3 F_2\left(\begin{matrix}a& &b& &c\\&d&
&e&\end{matrix};z\right)

That tightens up the spacing quite a bit. I made a hypergeometric macro previously, but it doesn't support the ;z, unfortunately.

\newcommand*\pFq[2]{{}_{#1}F_{#2}\genfrac[]{0pt}{}}

Then you use \pFq{3}{2}{a,b,c}{d,e}. (Or replace the commas with any other sort of spacing you want.) I was fairly happy with that.

Edit: Actually, how about something like this?

\newcommand*\pFqskip{8mu}
\catcode`,\active
\newcommand*\pFq{\begingroup
        \catcode`\,\active
        \def ,{\mskip\pFqskip\relax}%
        \dopFq
}
\catcode`\,12
\def\dopFq#1#2#3#4#5{%
        {}_{#1}F_{#2}\biggl[\genfrac..{0pt}{}{#3}{#4};#5\biggr]%
        \endgroup
}

Change \pFqskip to whatever spacing you want between the elements. You use it like

\pFq{3}{2}{a,b,c}{d,e}{z}
TH.
  • 62,639
  • wow, I guess I'll swing with your macro instead. Thanks a lot! I guess with a little tinkering I could get it to render the Meijer G function and other multivariate hypergeometrics as well! –  Aug 29 '10 at 07:27
  • Hmm, wait... I see you use \Bigl and \Bigr here; I'm still confused when to use these instead of \left and \right. Mind explaining why? –  Aug 29 '10 at 10:03
  • 1
    It was a mistake. It should be \biggl and \biggr. I'll edit my answer. But the reason was that I wanted it to behave the same way \binom does. I find that most of the time \left and \right produce brackets that are too large. Most of the time, \bigX, \BigX, \biggX, \BiggX suffice. – TH. Aug 29 '10 at 10:18
  • 1
    A more efficient definition of \pFq appears here – egreg Mar 07 '12 at 08:41
10

Update, with more features

The optional argument to \pFq is a set of key-value settings, but the settings can also be specified globally with \hypergeometricsetup.

One can set the symbol (default F), the fences (default brackets), the separator between parameters (default nothing), the skip between parameters (in mu units, default 8) and the divider (default a semicolon, but it can be bar).

\documentclass{article}
\usepackage{amsmath}

\ExplSyntaxOn

\NewDocumentCommand{\pFq}{O{}mmmmm} { % #2 = left subscript, #3 = right subscript % #4 = top, #5 = bottom, #6 = right \group_begin: \keys_set:nn { hypergeometric } { #1 } \hypergeometric_print:nnnnn { #2 } { #3 } { #4 } { #5 } { #6 } \group_end: } \NewDocumentCommand{\hypergeometricsetup}{m} { \keys_set:nn { hypergeometric } { #1 } }

\tl_new:N \l_hypergeometric_divider_tl \tl_new:N \l_hypergeometric_left_tl \tl_new:N \l_hypergeometric_right_tl

\keys_define:nn { hypergeometric } { symbol .tl_set:N = \l_hypergeometric_symbol_tl, symbol .initial:n = F, separator .tl_set:N = \l_hypergeometric_separator_tl, separator .initial:n = {}, skip .tl_set:N = \l_hypergeometric_skip_tl, skip .initial:n = 8, divider .choice:, divider/semicolon .code:n = \tl_set:Nn \l_hypergeometric_divider_tl { ;; }, divider/bar .code:n = \tl_set:Nn \l_hypergeometric_divider_tl { ;\middle|; }, divider .initial:n = semicolon, fences .choice:, fences/brack .code:n = \tl_set:Nn \l_hypergeometric_left_tl {[} \tl_set:Nn \l_hypergeometric_right_tl {]}, fences/parens .code:n = \tl_set:Nn \l_hypergeometric_left_tl {(} \tl_set:Nn \l_hypergeometric_right_tl {)}, fences .initial:n = brack, }

\cs_new_protected:Nn \hypergeometric_print:nnnnn { % the main symbol {} \sb {#1} \l_hypergeometric_symbol_tl \sb { #2 } % the parameters \left\l_hypergeometric_left_tl \genfrac .. % no delimiters {0pt} % no line {} % default style { __hypergeometric_process:n { #3 } } % numerator { __hypergeometric_process:n { #4 } } % denominator \l_hypergeometric_divider_tl #5 \right\l_hypergeometric_right_tl }

\cs_new_protected:Nn __hypergeometric_process:n { \clist_use:nn { #1 } { {\l_hypergeometric_separator_tl} \mspace { \l_hypergeometric_skip_tl mu } } }

\ExplSyntaxOff

\begin{document}

[ \pFq{3}{2}{a,b,c}{d,e}{z} \qquad \pFq[skip=4]{3}{2}{a,b,c}{d,e}{z} \qquad \textstyle\pFq{3}{2}{a,b,c}{d,e}{z} ]

\hypergeometricsetup{ fences=parens, separator={,}, divider=bar, }

[ \pFq{3}{2}{a,b,c}{d,e}{z} \qquad \pFq[skip=4]{3}{2}{a,b,c}{d,e}{z} \qquad \textstyle\pFq{3}{2}{a,b,c}{d,e}{z} ]

[ \pFq{1}{1}{\nu+\frac{1}{2}}{2\nu+1}{2iz} ]

\end{document}

enter image description here

Original answer

A modification of TH's answer that allows \pFq to be in the argument of other commands.

\documentclass{article}
\usepackage{amsmath}
\newmuskip\pFqmuskip

\newcommand*\pFq[6][8]{% \begingroup % only local assignments \pFqmuskip=#1mu\relax % make the comma math active \mathcode\,=\string"8000 % and define it to be \pFqcomma \begingroup\lccode~=`, \lowercase{\endgroup\let~}\pFqcomma % typeset the formula {}{#2}F{#3}{\left[\genfrac..{0pt}{}{#4}{#5};#6\right]}% \endgroup } \newcommand{\pFqcomma}{\mskip\pFqmuskip}

\begin{document} [ \pFq{3}{2}{a,b,c}{d,e}{z} \qquad \pFq[4]{3}{2}{a,b,c}{d,e}{z} \qquad \textstyle\pFq{3}{2}{a,b,c}{d,e}{z} ] \end{document}

The trick is using math activation, rather than activation tout court. There's also an optional argument for changing the default spacing between the coefficients.

enter image description here

A modification for keeping the comma:

\documentclass{article}
\usepackage{amsmath}
\newmuskip\pFqmuskip

\newcommand*\pFq[6][8]{% \begingroup % only local assignments \pFqmuskip=#1mu\relax \mathchardef\normalcomma=\mathcode, % make the comma math active \mathcode,=\string"8000 % and define it to be \pFqcomma \begingroup\lccode\~=, \lowercase{\endgroup\let~}\pFqcomma % typeset the formula {}{#2}F{#3}{\left[\genfrac..{0pt}{}{#4}{#5};#6\right]}% \endgroup } \newcommand{\pFqcomma}{{\normalcomma}\mskip\pFqmuskip}

\begin{document} [ \pFq{3}{2}{a,b,c}{d,e}{z} \qquad \pFq[4]{3}{2}{a,b,c}{d,e}{z} \qquad \textstyle\pFq{3}{2}{a,b,c}{d,e}{z} ] \end{document}

enter image description here

egreg
  • 1,121,712
  • Can you tell us how to use comma separator for: a, b, c ? – struct Mar 14 '18 at 14:04
  • @JanFilip Added the code. – egreg Mar 14 '18 at 14:17
  • Using update I got these errors:

    ! Bad mathchar (32768). \pFq ... \mathchardef \normalcomma =\mathcode , \mathcode,=\string "800... l.368 \pFq{2}{1}{a,b}{c}{z} = \sum_{n = 1}^{\infty}\frac{(a)_n (b)_n z^n}{(c... A mathchar number must be between 0 and 32767. I changed this one to zero.

    – struct Mar 14 '18 at 14:22
  • @JanFilip Sorry, I can't reproduce. It surely depends on some other code in your document. Please ask a new question with a minimal example of code reproducing the issue. – egreg Mar 14 '18 at 14:29
3

Mathematica gave me the folowing when I asked it to give the TeXForm of a generalized hypergeometric function

_2F_2\left(\frac{1}{2},\frac{1}{2};\frac{3}{2},\frac{3}{2};-c^2\right)

and it seems to work. Simple and general !

1

Although it doesn't use "matrix" notation you can adapt from one of the COOL package solutions. Check out page 30 of the COOL package manual. http://www.ctan.org/tex-archive/macros/latex/contrib/cool.

coolhyper

alfC
  • 14,350
-2

If you ask Mathematica;

Hypergeometric2F1[2 a, b, c, d]
TeXForm[%]

then you get

 \, _2F_1(2 a,b;c;d)

and this works in Latex

dexteritas
  • 9,161