# How do I create the following macro

How do I create this where {a}{b}{c} are variables for a possible math formula?

-
Welcome to TeX.sx! –  lockstep Dec 6 '12 at 11:48

I suggest using the amsmath command \genfrac which will resize as follows:

\documentclass{article}

\usepackage{amsmath}

\newcommand{\test}[3]{\left( \genfrac{}{}{0pt}{}{#1}{#2}\,\middle\vert\, #3\right)}

\begin{document}

\begin{equation*}
\test a b c
\end{equation*}
$$\test a b c$$

\end{document}


\genfrac takes six arguments, the first two are delimiters around the "fraction", then next is the thickness of the horizontal dividing line, set to 0pt here to make it invisible, and the last two are the numerator and denominator of the fraction.

If you want to have good control over the enclosing brackets (...) then an alternative definition can be given using the mathtools package:

\documentclass{article}

\usepackage{mathtools}

\DeclarePairedDelimiterX{\test}[3]{(}{)}{\genfrac{}{}{0pt}{}{#1}{#2}\,\delimsize\vert\, #3}

\begin{document}

\begin{equation*}
\scriptscriptstyle \test* a b c
\end{equation*}
$$\test a b c$$

\begin{equation*}
\end{equation*}

\end{document}


This time you have use \test* for the version with automatic sizing of brackets, \test just gives you ordinary brackets, but you also get the possiblities \test[\big], \test[\Big] etc. where the brackets sizes are explicitly specified.

-
Be very careful about \left and \right when used in the text. Try $\text b g c$, then the fences disturb the line spacing (add a line of text above and below). It is anoying to use, but \mathchoice might be a better choice. –  daleif Dec 6 '12 at 15:05
@daleif You are perfectly correct about use inline in text. I'll add an alternative mathtools macro to my answer. –  Andrew Swann Dec 6 '12 at 15:16

\documentclass{article}
$\test{a}{b}{c}$

@min it removes column sep –  cmhughes Dec 7 '12 at 0:57