How to align braces with middle vertical line the same size in math mode?

How can I make the middle vertical line the same size as the braces?

$A\left(c\mid \substack{a,b \\ c,d} \right)$


Thanks!

• There is not defined command \c and the \substack does not work properly in your example. – Dox Mar 18 '15 at 16:38
• Could you provide a MWE? – Dox Mar 18 '15 at 16:39
• Thanks Dox, it should be $A\left(c\mid \substack{a,b \\ c,d} \right)$ – Anand Mar 18 '15 at 16:44
• I'd use \Big| instead of \mid... although it is not the nicest solution. – Dox Mar 18 '15 at 16:50
• are you saying that the \substacked expression should be below the vertical line? this doesn't make sense to me. if you could show a drawing of what you expect, then the question would be easier to answer. (as phrased, i'd guess that the substack should hang out below the braces, and i'm not sure what that means with respect to the "A".) – barbara beeton Mar 18 '15 at 16:51

Here are some options - I prefer the use of \Big and friends:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

$A\left(c\mid \substack{a,b \\ c,d} \right)$

$A\Bigl(c\Bigm\vert \substack{a,b \\ c,d} \Bigr) \quad% Preferred A\left(c\middle\vert \substack{a,b \\ c,d} \right)$

\end{document}

• i wouldn't even have thought of using \substack in this situation; more likely to use a \genfrac approach. that's why i was so confused by the question. i do think the fences are a bit large; would have tried \bigg also, and compared to see which looks better. – barbara beeton Mar 18 '15 at 18:16

Your use of the \substack macro appears to be an attempt to re-create the smallmatrix environment. I would write

\documentclass{article}
\usepackage{amsmath}
\begin{document}
$A\bigl(\, c \: \big\vert \begin{smallmatrix}a,b \\ c,d \end{smallmatrix} \bigr)$
\end{document}


to produce

Note the use of \, and \: to adjust the spacing around c; since smallmatrix automatically inserts a bit of whitespace around it, there's no need to fine-tune the spacing of the material after the vertical bar.

• i agree fully that \substack isn't the best choice here -- it really confused me in the question. – barbara beeton Mar 18 '15 at 18:33
• no, i'm confused. the progression is \big, \Big, \bigg, \Bigg. that comment has been zapped. – barbara beeton Mar 18 '15 at 18:34

You can do that with the mathtools package. Here I define an \innerp command (I supposed you tried to make a variable sized inner product) with two arguments in one, that have to be separated by a semicolon. This last point can be realised with xparse. Usage:

• \innerp does no scaling;
• \innerp* acts as a pair of \left … \right;
• for fine-tuning of the size of delimiters, \innerp[\big] inserts a pair of \bigl … \bigr.

Note that in the rare cases when the argument of \innerp must contain a semicolon which comes before the argument separator, you have to add a pair of braces around it.

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fourier}
\usepackage{array, mathtools}
\usepackage{xparse}
\DeclarePairedDelimiterX{\innerp}[1](){\innerpargs{#1}}
\NewDocumentCommand{\innerpargs}{>{\SplitArgument{1}{;}}m}
{\innerpargsaux#1}
\NewDocumentCommand{\innerpargsaux}{mm}
{\IfNoValueTF{#2}{#1}{#1\:\delimsize\vert\:\mathopen{} #2}}

\begin{document}

\begin{tabular}{l >{$}c<{$}}
\verb+\innerp*+: & \innerp*{c;\substack{a,b \\c,d}}\\[3ex]
\verb+\innerp[\big]+: & \innerp[\big]{c;\substack{a,b \\c,d}\mkern1.5mu}
\end{tabular}

\end{document}


• What if the first arg contains a comma? Does one then always have to remember to protect it in order to hide it from the parser? (This is why I tend to stay away from parsing solutions) – daleif Mar 20 '15 at 11:15
• Yes. However, the comma is often already ‘naturally’ hidden (e.g. because the first argument is the result of a command). An we can use a semi-colon, which much more rarely used in maths formulae, as a separator. I modified my answer in function of your comment. – Bernard Mar 20 '15 at 11:36
• I'm still not convinced it is the best syntax for user input. Just because a char might be rare doesn't mean users will not use it. At the moment I don't know what a good interface would be. – daleif Mar 20 '15 at 12:31
• I'm afraid there's no perfect interface: two arguments with two pairs of braces slows down typing and is somewhat unnatural w.r.t. formulae handwriting. Two arguments in one with a separator is closer, but has the drawback you pointed. The less bad solution, in my opinion, is a rarely used separator (thus it will seldom have to be protected), and easily accessible on a keyboard. In addition, semicolon is one of the natural separators in handwriting. – Bernard Mar 20 '15 at 12:49
• For something as an inner product I find it more natural to make it a two argument macro, because it is a two argument function. And adding braces is not that slow. Some editors even just require you to type {. – daleif Mar 20 '15 at 13:19