# Disable smart (contextual) quotes for entire document?

Is it possible to disable smart (contextual) quotes for an entire document? If yes, how?

In particular, can the single quote ', double quote ", and backtick  be left as-is by some option or method to directly disable such substitutions?

\documentclass{article}
% minimal document which illustrates the issue.
\begin{document}

Can "double quotes", 'single quotes' and backticks
substitutions to any curly, smart, quote, contextual
be switched off for the whole document?

\end{document}


The package upquote appears limited to the \ver­ba­tim type sections. The package csquotes has com­mands and en­vi­ron­ments for user-de­fin­able ‘smart quotes’ … yet, some switch to just completely disable smart quotes has been elusive.

The question "Is there upquote like package for main text and not just verbatim text?" is looking for a package plus macros and rather than an off switch.

The systemic impact of add packages vs. toggle a switch(option?) have intrinsic differences.

On one hand, "adding a package" is a downstream approach. Downstream files have added cluster and complexity in the authors' files. Such as, add this package x for macro y, then add that package z, then override a, then define b so that b can then itself be overridden. Each added package, definition and override also likely adds some computational complexity to the dynamic runtime execution as well.

On the other hand, "toggle a switch" is a upstream approach. I'm guessing these quote substitutions originate in the various TeX/LaTeX engines. Hypothetically or ideally, a smart quote option switch could be compiled and linked for execution efficiently at the source … with some pseudo logic like:

// over simplified pseudo code
if smartQuotesOption == true {
// make quote substitutions happen
}
else {
// just skip the substitutions.
// so, maybe nothing or little to do.
}


then conceptually users would use a command line option:

pdflatex --no-smart-quotes document.tex


or use some direct switch like the following in the LaTeX/TeX files:

\smartquotesdisable
\smartquotesenable % default for backward compatibility


Such smart substitution enable/disable toggles do exist in document creation environments like various markdown tools, pandoc and mainstream word processors.

So, "Can smart quote substitutions just be toggled off?" …

If yes, great.

If no, then where would one submit a feature request for a smart substitution toggle? Or, find out if such a feature is already on the roadmap? :-)

• Maybe this question? tex.stackexchange.com/questions/7735/… – David Purton Feb 19 '19 at 9:26
• Paul Stanley mentioned it in his now deleted answer, so let me re-iterate in the comments, that technically speaking LaTeX does not really apply 'smart quotes' as they are normally understood (i.e. you press the same button on your keyboard to get correct “curly” quotation marks). It's just that " means ” for TeX and that it has a ligature set up for  as “ – moewe Feb 19 '19 at 13:29
• I'm kind of curious as to why you would want to turn this off... – Seamus Feb 19 '19 at 15:46

I have some reservations about changing the catcode of the asciigrave and the quotedbl as these characters are often used to change catcodes of other characters. But maybe it's OK.

Updated to work with pdflatex, xelatex, and lualatex.

\documentclass{article}

\usepackage{ifxetex}
\usepackage{ifluatex}
\newif\ifxetexorluatex
\ifxetex
\xetexorluatextrue
\else
\ifluatex
\xetexorluatextrue
\else
\xetexorluatexfalse
\fi
\fi

\ifxetexorluatex
\usepackage{fontspec}
\begingroup
\catcode 34=13
\catcode 39=13
\catcode 96=13
\gdef"{\textquotedbl}
\gdef'{\textquotesingle}
\gdef{\textasciigrave}
\endgroup
\else
\usepackage[TS1,T1]{fontenc}
\begingroup
\catcode 39=13
\catcode 96=13
\gdef'{{\fontencoding{TS1}\selectfont\textquotesingle}}
\gdef{{\fontencoding{TS1}\selectfont\textasciigrave}}
\endgroup
\fi

\def\smartquotedisable{%
\ifxetexorluatex
\catcode 34=13
\fi
\catcode 39=13
\catcode 96=13
}
\def\smartquoteenable{%
\ifxetexorluatex
\catcode 34=12
\fi
\catcode 39=12
\catcode 96=12
}

\begin{document}

Hello'

"Hello"

Hello''

\smartquotedisable

Hello'

"Hello"

Hello''

\smartquoteenable

Hello'

"Hello"

Hello''

\end{document}