0

I have a command for setbuilder notation,

\newcommand{\set}[2]{\left\{ #1 \ \big| \ #2 \right\}}

Pretty simple stuff. I have issues, however, when I want larger characters in the set, for example summations, fractions, and whatnot as the vertical bar doesn't scale. Is there a way its height can be tied to the outside brackets?

1
  • See the mathtools package and its documentation for \DeclareMathDelimiter. Note that it is never recommended to auto scale by default as it more often than not ends up in the wrong scale. The manual has an example that defines a one arg \Set macro.
    – daleif
    Aug 25, 2023 at 12:07

2 Answers 2

2

You might do like this:

\documentclass{article}
\usepackage{amsmath}

\newcommand{\set}[2]{\left\{ {#1}\vphantom{\big|} \;\middle|\; #2 \right\}}

\begin{document}

\begin{gather*}
\set{x\in A}{x^{-1}=x^2} \\
\set{x\in A}{\frac{1}{x}=x^2}
\end{gather*}

\end{document}

enter image description here

The \vphantom{\big|} is meant to use at least \big size.

However, you should take into account that \left and \right will in most cases choose too big a size. The documentation of mathtools shows alternative approaches.

2

The TeX primitive \middle is here just for these cases. It was introduced in eTeX extension of TeX (sometime in the nineties). Its argument is an extensible parenthesis/fence like arguments of \left and \right primitives. It can be used only somewhere inside the group given by \left...\right and it gets the same size.

Your macro can be defined as

 \def\set#1#2{\left\{ #1 \vbox to.85em{} \;\middle|\; #2  \right\}}

the \vbox to.85em{} is a strut which is equal to \big size.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .