11

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

single quote in typeset document

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

single quotes with dejavu

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

Any clues?

10

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

enter image description here

\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{}
 is a valid Haskell identifier.}

\end{document}
  • There probably shouldn't be a space between alpha and \textquotesingle – Aaron McDaid Feb 7 '13 at 11:55
6

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}

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.