[Tex/LaTex] item formatting in description list

descriptionlists

How can I get this to work:

\begin{description}
    \item[\texttt{foo :: a \rightarrow b}] bla
\end{description}

without having to write:

\begin{description}
    \item\ttfamily[foo~::~a~$\rightarrow$~b]\normalfont~bla
\end{description}

?

  • \ttfamily: for typewriter formating
  • ~: to get the spacing right(??)
  • $: to activate math mode
  • \normalfont: to get back to normal
  • last ~: insert simple space(??)

or how would you list some function definitions and append a description for the functions?

Best Answer

How about

\begin{description}
    \item[\texttt{foo :: a $\rightarrow$ b}] bla
\end{description}

That is: add a closing brace and $s around \rightarrow.

Or maybe you want

\begin{description}
    \item[\texttt{[foo ::~a $\rightarrow$ b]}] bla
\end{description}