I have a document with many '
characters inside of texttt
. Is there a way to make them all appear straight when in texttt
?
I know that I can search/replace all '
with \textquotesingle
:
Perhaps there is some preamble declaration to tell texttt
to render all '
as \textquotesingle
?
Best Answer
Here is an approach using active characters, but still allowing
\texttt
usage inside arguments of other macros. (because it uses\scantokens
).The advantage compared to my other answer is that it makes do with the document typewriter font, it does not modify it. The disadvantage is that
\scantokens
may reserve some surprises. Concretely the main issue coming to my mind is that one should not use it in a context where the space character has been made active, and the main case will be thealltt
environment (of courseverbatim
is no issue, as\texttt
macro does not get executed). But that's already a bit specialized context, so generally speaking it will be fine.Notice that my approach loads package
upquote
so verbatim environment will be with straight single quotes too.