5

How do I define my own delimiters from arbitrary symbols for math which have these properties:

  • They have a fixed size. Unlike the usual delimiters they do not stretch to adapt to the enclosed content.
  • They do not have to be paired. A left delimiter need not be followed by a right delimiter. A right delimiter need not be preceded by a left delimiter.
  • Each delimiter can be declared to belong to one of the three sides (left, middle, right).

Example 1: I want to use the $ character as a math delimiter. I want to declare a left, a right, and a middle $ delimiter. I want to be able to use just any one, just any two, or all three variants of $ delimiters.

Example 2: What I want already exists for some characters. There are the \lvertand \rvert delimiters. I would like to declare delimiting characters of this type for arbitrary characters. So, for my example 1 I would create the new commands \ldollar, \mdollar, and \rdollar which would produce a left, a middle, and a right $ sign delimiter, respectively.

1
  • you can just use \newcommand to define shortands for \mathopen{\$}, \mathbin{\$}, \mathclose{\$}` Feb 5, 2015 at 17:20

1 Answer 1

4

Use the commands \mathopen, \mathclose and \mathrel:

\documentclass{article}
\usepackage{amsmath}

\newcommand{\ldollar}{\mathopen{\$}}
\newcommand{\rdollar}{\mathclose{\$}}
\newcommand{\mdollar}{\mathrel{\$}}

\begin{document}
$\log\ldollar a+b\rvert-\{a\mdollar b\}$
\end{document}

enter image description here

3
  • I'd have guessed \mathbin ? Feb 5, 2015 at 17:21
  • @DavidCarlisle Why \mathbin? A “middle delimiter” is surely a relation symbol like \mid.
    – egreg
    Feb 5, 2015 at 17:23
  • I don't know what a$b means but if I had to guess, I'd guess it was semantically closer to a+b than a=b but who knows:-) Feb 5, 2015 at 17:25

You must log in to answer this question.

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