5

Can I introduce new delimiter symbols to use with \left and \right? For example I would like to do

\begin{equation}
\left\harpoonleft something \right\harpoonright
\end{equation}

I would then like the size of the symbols to be dependent on the size of something between the symbols.

How would I do such a thing?

  • I think you can redefine \left and \right but I'm not sure if it is a good idea... this and this answer might help you. – Pouya Jun 9 '14 at 13:17
  • 4
    A symbol can go after \left or \right only if scalable versions of the symbol are available as part of the font. – egreg Jun 9 '14 at 13:20
  • 2
    The mathtools \DeclarePairedDelimiter is probably easiest. One could do it from scratch using graphics \resizebox. – John Kormylo Jun 9 '14 at 14:13
  • @JohnKormylo that wont do any resizing when whats between the delimiters is large. But that's probably because of what egreg said. – Tim Kuipers Jun 9 '14 at 14:58
4

I mean that the qeustion mentions the harpoons, no arrows. Because there is no harpoon part in common math symbols and the \resizebox creates the harpoon marks deformed, I suggest another solution: to draw the harpoon parts as PDF code using \pdfliteral. The rest is simply \vrule.

\documentclass{article}

\def\leftharpoonpart  {\pdfliteral{q 0 0 m 0 -2.1 -1.2 -2.8 -1.5 -3 c 1 j .4 w S Q}}
\def\rightharpoonpart {\pdfliteral{q 0 0 m 0 -2.1  1.2 -2.8  1.5 -3 c 1 j .4 w S Q}}

\def\encloseharpoons#1{\setbox0=\hbox{$\displaystyle{#1}$}%
   \mathop{\,\vrule height\ht0 depth\dp0
   \kern-.2pt \raise\ht0\vbox to0pt{\vss\leftharpoonpart\kern.1pt}%
   \copy0
   \raise\ht0\vbox to0pt{\vss\rightharpoonpart\kern.1pt}\kern-.2pt\vrule\,}%
   \nolimits
}
\begin{document}

$$a \cdot \encloseharpoons{\int_a^b} + \encloseharpoons{1\over2}^2$$

\end{document}

Of course, no special packages are needed. The result is

harpoon

And the detail:

harpoon detail

You have to use pdflatex or lualatex. When xelatex is used you need to add the definition:

\def\pdfliteral#1{\special{pdf:literal #1}}
2

If you want to use Tikz to create your delimeters:

\documentclass{article}
\usepackage{tikz}

\newcommand{\leftdelim}[2]% #1 = height, #2 = depth
{\tikz[baseline]{\draw[color=red,arrows={-latex}](0,-#2)--(0,#1);}}

\newcommand{\rightdelim}[2]% #1 = height, #2 = depth
{\tikz[baseline]{\draw[color=red,arrows={latex-}](0,-#2)--(0,#1);}}

\newlength{\MyHeight}
\newlength{\MyDepth}
\newsavebox{\MyBox}

\newcommand{\mydelim}[1]% #1 = text to be enclosed
{\savebox{\MyBox}{$\displaystyle #1$}% get size of box
\settoheight{\MyHeight}{\usebox{\MyBox}}%
\settodepth{\MyDepth}{\usebox{\MyBox}}%
\leftdelim{\MyHeight}{\MyDepth}%
\,\usebox{\MyBox}\,%
\rightdelim{\MyHeight}{\MyDepth}}

\begin{document}
\[
\mydelim{\frac{x+a}{x+b}}
\]
\end{document}

delimiters

If you do NOT want to use tikz:

\documentclass{article}
\usepackage{graphics}

\newlength{\MyHeight}
\newlength{\MyDepth}
\newlength{\MyDiff}
\newsavebox{\MyBox}

\newcommand{\mydelim}[1]% #1 = text to be enclosed
{\savebox{\MyBox}{$\displaystyle #1$}% get size of box
\settoheight{\MyHeight}{\usebox{\MyBox}}%
\settodepth{\MyDepth}{\usebox{\MyBox}}%
\addtolength{\MyHeight}{\MyDepth}%
\settodepth{\MyDiff}{$\uparrow$}
\addtolength{\MyDiff}{-\MyDepth}
\raisebox{\MyDiff}{\resizebox{\width}{\MyHeight}{$\uparrow$}}%
\,\usebox{\MyBox}\,%
\raisebox{\MyDiff}{\resizebox{\width}{\MyHeight}{$\downarrow$}}}

\begin{document}
\[
\mydelim{\frac{x+a}{x+b}}
\]
\end{document}

resize

  • Erh, \uparrow and \downarrow already qualify as delimiters so no need for tikz or scaling in that case. – daleif Jun 10 '14 at 8:31
  • I didn't realize that harpoon referred to a specific shape. I used arrows because they were easy. – John Kormylo Jun 10 '14 at 13:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.