[Tex/LaTex] Adding straight quote marks to \texttt

punctuation

Problem:

Inline text gets curled quote marks and I would like to format these automatically to be straight ones instead.

Minimal Working Example (MWE):

\documentclass{article}
\usepackage{xcolor}

\definecolor{light-gray}{gray}{0.95}
\newcommand{\code}[1]{\colorbox{light-gray}{\texttt{#1}}}

\begin{document}

The function \code{date('Y-m-d')} allows you to...

\end{document}

Outputs:

enter image description here

Desired output:

Instead of curled single quotes, they should be straight ones like '.

Best Answer

enter image description here

One option is to use the \textquotesingle from the textcomp package as this:

\documentclass{article}
\usepackage{xcolor}
\usepackage{textcomp}
\definecolor{light-gray}{gray}{0.95}
\newcommand{\code}[1]{\colorbox{light-gray}{\texttt{#1}}}

\begin{document}

The function \code{date(\textquotesingle Y-m-d\textquotesingle)} allows you to...

\end{document}