# Typesetting single quotes

How can the single quote character be typeset as the ascii character ' in a LaTeX document?

For instance, consider the document:

\documentclass{standalone}

\usepackage[T1]{fontenc}

\begin{document}

\texttt{Note that alpha''' is a valid Haskell identifier.}

\end{document}


The output produced by pdflatex is

Notice how the first two quotes are typeset differently than the third one. The third one is bigger further away from the second.

With other fonts this become more evident. Adding to the preamble:

\usepackage{dejavu}


gives the result

I want all of them typeset the same way, as the ascii single quote character '.

Any clues?

-

You can break the ligature just by inserting {} but you may prefer the straight quote from textcomp rather than three right quotes:

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage{textcomp}
\begin{document}

\texttt{Note that alpha''' is a valid Haskell identifier.}

\texttt{Note that alpha'{'}' is a valid Haskell identifier.}

\texttt{Note that alpha\textquotesingle\textquotesingle\textquotesingle{}

\end{document}

-
There probably shouldn't be a space between alpha and \textquotesingle – Aaron McDaid Feb 7 '13 at 11:55
@AaronMcDaid thanks. I updated the answer. – David Carlisle Feb 7 '13 at 12:11

Use \lstinline from the listings package. An option can make it substitute ' with \textquotesingle from the textcomp package:

\documentclass{article}
\usepackage{listings}
\usepackage{textcomp}
\lstset{upquote=true}

\begin{document}
\texttt{Note that \lstinline@alpha'''@ is a valid Haskell identifier.}
\end{document}

-