I would like to obtain a straight quote, ', when I type ' in my LaTeX input, and a straight double quote, ", when I type " in my LaTeX input. This, everywhere, in every case: normal text, section title, inside a \texttt or a \verb command, … I want to have “nice” quotes only when I input such with my keyboard (which I’ll do myself, thank you).

This questions lists several similar question, but I have not found this specific question: most questions are in the case of XeLaTeX or are about getting straight quotes only in some special case.

I have tried to adapt an answer to the above question to my case. Here is a MWE.



A "“'straight'” quoting".

\texttt{A "'straight' quoting".}

I have several questions.

  • Is this code “dangerous”, in the sense that it would be doing something (e.g., declaring new active characters) that will strongly increase the probability of incompatiblity (or strange behavior) with some package that I might want to use one day or another? (I’d rather give up my dreams of taking care of my quotes myself than risking all sorts of problems and long debugging sessions in the future.)
  • How can I suitably simplify the above code? In particular, I’d like to replace the \algoupquote command by its definition, but if I do that, I get insulted by LaTeX (if I dare report it, it says “Argument of \UTFviii@three@octets has an extra }”).
  • Is there a risk of sensibly enlarging the compilation time, for big documents?
  • Can I / should I rather declare ' and " active and use something like \DeclareUnicodeCharacter{0027}{\textquotesingle}? What would be the advantage and drawback?

(I know that XeLaTeX and other LaTeX variants have been designed for treating nicely Unicode input, but I prefer to keep maximal compatibility and use the standard LaTeX that most people use.)

  • TeXnicCenter converts " into `` and '' automatically (context dependent), which is a real pain when I need a ". Dec 22, 2019 at 23:47
  • It's an editor preference in TeXworks, Format | Smart Quotes | None; TeX ligatures, TeX commands, Unicode characters; Apply to selection.
    – Cicada
    Dec 23, 2019 at 0:59
  • \textquotesingle and \textquotedbl work without any packages; they must be in the kernel. Possibly related: tex.stackexchange.com/questions/7735/…
    – Cicada
    Dec 23, 2019 at 2:12
  • 1
    Or with T1 encoding: \documentclass{article} \usepackage[T1]{fontenc} \usepackage{textcomp} \catcode39=\active \let'\textquotesingle \begin{document} A "'straight' quoting". \texttt{A "'straight' quoting".} \end{document} (not sure about side effects).
    – Marijn
    Dec 25, 2019 at 19:17
  • 1
    @Marijn thanks! Do you have a similar trick for the backquote, `? I’d like it to display as-is as well. (Something like \catcode`\`=\active \let`\textasciigrave, I suppose, but this produces an error message, unsurprinsingly.) Dec 27, 2019 at 14:01

1 Answer 1


A solution is to make the single quote and backtick active and define them to be the required commands. Within the definition different output can be set for math mode and text mode. This solution is partly based on Replace backtick ` with power/caret ^ in math mode. I would like to repeat the warning given there that this may break any code that expects either character to have the usual category code.

T1 font encoding is used in the MWE because " is available in that encoding and therefore no additional catcode changes or definitions are needed.




A "'straight' quoting".

\texttt{A "'straight' quoting".}

$a 'b' c` x$

The character ` is the grave accent.


enter image description here

  • 1
    I’d be most interested by a concrete example of something breaking because of this code, in order to know what kind of problems to expect (or perhaps, give up using this code altogether if it creates too much problems). Dec 28, 2019 at 9:23
  • The linked-to answer claims to redefine the catcode only for math-mode (though I don’t understand how the code provided there achieves that). If I understand correctly, the code provided here redefines the catcode for both text and math mode. Is it possible to similarly redefine the catcode only for text mode, and leave it alone for math mode (therefore possibly reducing the adverse effects)? Dec 28, 2019 at 9:28
  • I have to abandon this at least for the Grave Accent symbol: in that context, \catcode`\'=\active is incompatible with \usepackage{graphicx} or empheq. (However, the linked-to answer does not suffer this incompatibility.) Dec 28, 2019 at 12:32
  • In the previous comment I meant that \catcode`\`=\active is incompatible with \usepackage{graphicx}. But moving the two lines \catcode`\`=\active \let`\gravesingle after the \begin{document} works when loading the graphicx, empheq, and various other packages. Not sure about their use, however. Dec 28, 2019 at 13:20
  • Also, this fails to produce straight quotes in \verb|A "'straight' quoting".|. Any idea? Dec 28, 2019 at 13:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .