How can I write ' instead of within the \texttt-environment?

I have stumbled upon several discussions, but not a single discussion has solved my problem. I do not want to write code! I just want to have a straight apostrophe when writing in the \texttt-environment. Plain and simple.

Some solutions I have come accross were successfull in writing a straight apostrophe, but only in Computer Modern Roman or Latin Modern Roman – not in Computer Modern Mono or Latin Modern Mono. But that is what I need.

I have also tried this, but it did not work.

  • Why did that not work? Have you tried the exact example shown there? Please provide the code of what you've tried.
    – Skillmon
    Nov 26, 2017 at 19:02

1 Answer 1


A simpler solution for \texttt:


  \tl_set:Nn \l_nemgathos_upquotes_tl { #1 }
  \tl_replace_all:Nnn \l_nemgathos_upquotes_tl { '' } { \textquotedbl }
  \tl_replace_all:Nnn \l_nemgathos_upquotes_tl { `` } { \textquotedbl }
  \tl_replace_all:Nnn \l_nemgathos_upquotes_tl { ' } { \textquotesingle }
  \tl_replace_all:Nnn \l_nemgathos_upquotes_tl { ` } { \textquotesingle }
  { \ttfamily \tl_use:N \l_nemgathos_upquotes_tl }
\tl_new:N \l_nemgathos_upquotes_tl


``Normal `quotes' here''

\texttt{``Straight `quotes' here''}


enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .