14

I'm trying to typeset a paper in Haskell, and I want to typeset these operators:

enter image description here

I'm talking about <*>, <$> and <$.

  1. I've seen these before in articles about Haskell. Is there a package for them? Possibly an lhs2tex style file?

  2. I'm trying to recreate them by hand. This is what I've tried:

    • $<\mathclap{\$}>$ (Too much space)

    • $<\!\!\mathclap{\$}\!\!>$ (Very hacky, vertical spacing wrong)

Do I have to use TikZ for that, or is there a better way to achieve this?

  • Will they be used in sub-/superscripts as well, or just in inline \textstyle? – Werner Mar 7 '16 at 21:36
  • @Werner, just inline. – Turion Mar 7 '16 at 21:37
8

I think your second "very hacky" approach is not too bad at all. Instead of using \! for a negative space of fixed width, I used \hspace with a negative size argument. Also, I had to use \scalebox to shrink the dollar sign, which was taller than the angle braces. Here's the code:

\documentclass[border=10pt]{standalone}

\usepackage{mathtools}

\begin{document}

$<\hspace{-3.6pt}\mathclap{*}\hspace{-3.6pt}>$
$<\hspace{-3.6pt}\mathclap{\scalebox{.71}{\$}}\hspace{-3.6pt}>$
$<\hspace{-3.6pt}\mathclap{\scalebox{.71}{\$}}$

\end{document}

And here's the result:

enter image description here

Note the dollar sign isn't quite exactly the same font as you have. Also, to use <$ in text, you may want to add a horizontal space (for example with \) after it to make everything look nice.

  • I went for this version together with a \raisebox. I like that it doesn't need any further packages than mathtools. – Turion Mar 10 '16 at 12:36
  • This code uses points rather than mus. Won't that means trouble when symbols are rescaled? – Blaisorblade Jul 22 '17 at 0:29
13

It's encouraged to define macros for these types of things:

enter image description here

\documentclass{article}
\usepackage[export]{adjustbox}

\newcommand{\dstar}{\mathbin{{\ooalign{${<}\mkern-3.5mu{>}$\cr\hidewidth\adjustbox{raise=-.4ex,scale=.75}{*}\hidewidth}}}}
\newcommand{\ddollar}{\mathbin{{\ooalign{${<}\mkern-2mu{>}$\cr\hidewidth\adjustbox{scale=.7}{\$}\hidewidth}}}}
\newcommand{\ddollarl}{\mathbin{{<}\mkern-4mu\adjustbox{scale=.7}{\$}}}
\newcommand{\ddollarr}{\mathbin{\adjustbox{scale=.7}{\$}\mkern-4mu{>}}}

\begin{document}

$f \dstar x$

$f \ddollar x$

$f \ddollarl x$

$f \ddollarr x$

\end{document}

Note that the above macros will be sufficient for inline \displaystyle and \teststyle use, but not for sub-/superscripts (\scriptstyle and smaller).

8

Choose better names. Depending on the fonts used some adjustment might be necessary.

\documentclass{article}
\usepackage{amsmath}

\newcommand{\rstar}{
  \mathbin{
    <
    \mathrel{
      \mspace{-1.7mu}
      \vcenter{
        \hbox to 0pt{\hss$\scriptstyle*$\hss}
      }
      \mspace{-1.7mu}
    }
    >
  }
}
\newcommand{\rdollar}{
  \mathbin{
    <
    \mathrel{
      \mspace{-1mu}
      \vcenter{
        \hbox to 0pt{\hss$\scriptstyle\$$\hss}
        \kern0.005ex
      }
      \mspace{-1mu}
    }
    >
  }
}
\newcommand{\ldollar}{
  \mathbin{
    <
    \mathrel{
      \mspace{-1mu}
      \vcenter{
        \sbox0{$\scriptstyle\$$}
        \hbox to .5\wd0{\hss\box0}
        \kern0.005ex
      }
    }
  }
}
\newcommand{\gdollar}{
  \mathbin{
    \mathrel{
      \vcenter{
        \sbox0{$\scriptstyle\$$}
        \hbox to .5\wd0{\box0\hss}
        \kern0.005ex
      }
      \mspace{-1mu}%
    }
    >
  }
}

\begin{document}

$f\rstar x$

$f\rdollar x$

$f\ldollar x$

$f\gdollar x$

\end{document}

Look, ma! No percent!

enter image description here

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.