4

I am looking to accomplish the following:

enter image description here

So far I have the following code but it's just not quite right

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\left(
 \begin{matrix}
  \nu+\tfrac{1}{2}\\
  2\nu+1\\
 \end{matrix}
\right\rvert\,2iz
\end{document}

Which compiles as

enter image description here

Ingmar
  • 6,690
  • 5
  • 26
  • 47
  • Welcome to tex.sx! We usually skip greetings to focus on the question. Could you give us a minimum working example (minimum code that can be compiled)? – AlMa May 30 '23 at 16:27
  • Welcome. // Latex is complex. Please give us more than just code fragments. Something that compiles after copy is nice. – MS-SPO May 30 '23 at 16:27
  • 1
    I'm very new to this, fixed the code fragment so it compiles and added an image of the compilation. Thank you in advance. – Celepharn May 30 '23 at 16:52
  • While it's entirely ok to upvote answers immediately if you find them to be useful, site guidelines strongly recommend waiting several hours, and maybe even a day or two, before "accepting" any particular answer. That way, you don't discourage others from providing possibly even better answers. – Mico May 30 '23 at 17:12
  • 1
    You may want to look at https://tex.stackexchange.com/a/125531/4427 – egreg May 30 '23 at 19:55
  • the solution given by @egreg in the linked post is so vastly superior that I am tempted to vote to close as a duplicate. :-) – Willie Wong Jun 01 '23 at 02:20

3 Answers3

11

(updated the answer to address @yarchik's comment)

Here are two solutions. The first uses \mleft(, \middle|, and \mright), where \mleft and \mright are macros provided by the mleftright package. The second uses \Bigl(, \Bigm\vert, and \Bigr). Both solutions avoid creating an excessive amount of space to the left of the opening parenthesis -- a problem that arises when using \left( and \right).

enter image description here

\documentclass{article}
\usepackage{mleftright} % for \mleft and \mright macros
\begin{document}

[ {}_1F_1 \mleft( \begin{array}{@{}c@{}} \nu+\frac{1}{2} \ 2\nu+1 \end{array} ,\middle|, 2iz \mright) \qquad {}_1F_1 \Bigl( \begin{array}{@{}c@{}} \nu+0.5 \ 2\nu+1 \end{array} \Bigm\vert 2iz \Bigr) ]

\end{document}

Willie Wong
  • 24,733
  • 8
  • 74
  • 106
Mico
  • 506,678
  • Mico and @Willie Wong: Correct me if I'm wrong, but shouldn't \middle| be surrounded by \; instead of \, for correct spacing? – Sandy G May 30 '23 at 17:15
  • @SandyG - The screenshot the OP posted sure doesn't make it look like \; spacers were used. – Mico May 30 '23 at 17:23
  • \middle is defined in such a way that the horizontal spacing is taken care of automatically. With \vert you'd have to space it explicitly. – barbara beeton May 30 '23 at 17:59
  • 1
    @barbarabeeton did you mean the spacing for \mid and not \middle? AFAICT there is no extra spacing inserted for \middle; but \mid cannot be automatically sized. – Willie Wong May 31 '23 at 15:00
  • @SandyG I wasn't aware there is such a thing as an officially "correct" spacing. I like \, in these cases because they look nice to me. – Willie Wong May 31 '23 at 15:00
  • @WillieWong -- Yes, I guess I did. I didn't check. You are correct in all particulars. – barbara beeton May 31 '23 at 15:31
  • 2
    Shouldn't space between the function name and parentheses be smaller? I believe it is not a product. – yarchik May 31 '23 at 19:34
  • @yarchik - Good point! I'll update my answer and provide two ways to fix the spacing issue. – Mico May 31 '23 at 20:38
8

This is a perfect place to use amsmath's \genfrac command.

enter image description here

\documentclass{article}
\usepackage{amsmath}
\newcommand\hypergeom[3]{{}_1F_1\left(\genfrac{}{}{0pt}{}{#1}{#2}\,\middle\vert\,#3\right)}

\begin{document} [ \hypergeom{\nu+\frac12}{2\nu+1}{2iz} ] \end{document}

Explanation

In the definition above, we first have \left( ... \,\middle\vert\, ... \right); this generates automatically resized ( | ) that shows up. The \, is used to add some spacing, the \middle applied to \vert makes the vertical line grow in the same way as the parentheses to accommodate the arguments.

The heavy lifting is done by the \genfrac command, which amsmath uses to create things like \tfrac and \binom. Here we just want to stack two terms one over another, and so we basically ignore the first four arguments. For more bout the \genfrac command, see the amsmath documentation.

An advantage of using \genfrac is that it follows automatically scaling when you use the command in in-line math versus in display math. See the image below:

enter image description here

The top line uses the \hypergeom macro defined above; the bottom line uses a matrix based incantation. For things like the hypergeometric function, the down-sized expression (similar to how in-line fractions are smaller compared to display ones) is, in my opinion, more pleasing.

Willie Wong
  • 24,733
  • 8
  • 74
  • 106
5

There are several ways. You can place the | character inside mathrel for proper spacing. Then adjust its size with \Big or \bigg if you want it bigger. Manually sizing the delimiters ( and ) will generally give you better results than using \left( and \right).

enter image description here

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
\biggl(
 \begin{matrix}
  \nu+\tfrac{1}{2}\\
  2\nu+1\\
 \end{matrix}
\mathrel{\Big|} 2iz\biggr)
\]
\end{document}
Sandy G
  • 42,558
  • The middle vertical bar isn't as tall as the outer parentheses. Is this intentional? – Mico May 30 '23 at 17:09
  • @Mico: It was intentional, just to demonstrate that the sizes can be chosen differently if desired. – Sandy G May 30 '23 at 17:12