6

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?

lockstep
  • 250,273

3 Answers3

12

In this case I would \usepackage{enumitem}

And then write:

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

This way you don't need to define the font for each of your items.

Geoff
  • 3,801
3

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}
Caramdir
  • 89,023
  • 26
  • 255
  • 291
2

i notice you're missing a closing brace before the closing bracket, other than that the two seem to produce identical output for me, save the enclosing brackets in your second example.

aeroNotAuto
  • 2,390