7

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 '.

9

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}

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.