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 '17 at 19:02

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

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.