I use the \Verb
command from the fancyvrb pacakge for in-text verbatim fragments. To get straight single quotes, I also loaded the upquote package. Unfortunately, this does not work when I use a custom command of the form
\newcommand\textcode[1]{\Verb[<options>]|#1|}
I tried adapting @egreg's solution to How can I change a glyph in a Verbatim environment?, but this was not successful. How can I create a \textcode
macro that produces straight single quotes (without having to type \textquotesingle
every time)?
\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{upquote}
\usepackage{fancyvrb}
\newcommand\textcode[1]{\Verb|#1|}
\newcommand\makequotestraight{%
\begingroup\lccode`~=`'
\lowercase{\endgroup\let~}\textquotesingle
\catcode`'=\active
}
\newcommand\textcodeii[1]{\Verb[codes={\makequotestraight},]|#1|}
\begin{document}
\Verb|'a = b'|
\textcode{'a = b'}
\textcodeii{'a = b'}
\textcode{\textquotesingle a = b\textquotesingle}
\end{document}