3

Consider this TeX file

\documentclass{l3doc}
\usepackage{csquotes}
\MakeOuterQuote{"}
\begin{document}
\enquote{hello} "hello"
\end{document}

Output

I want to use " as the quote characters. csquotes documentation states that \MakeOuterQuote can be used to do that, but for some reason it results in verbatim code instead.

What is going on and how can I fix it?

3
  • Why not just use \enquote as in your example? It’s cleaner, less prone to errors, and with zero compatibility issues or package conflicts.
    – Gaussler
    Commented Jul 15, 2022 at 8:15
  • Because sometimes you get external texts, or something written by a collaborator, etc. and you don't want to go through your text replacing every instance of "…" with \enquote{…}. Yes, a regex could do it, but I find actual quotation marks easier to read, too.
    – Ingmar
    Commented Jul 15, 2022 at 8:40
  • Then how about using \MakeAutoQuote{“}{”} instead? It’s still readable, and a redex expression can also replace " by and in the appropriate places. Alternatively, you can copy the external text into a word precessor (e.g. MS Word), and that word processor will then automatically do the replacement for you. LyX can do the same, too, I believe. Then you can copy it back into your LaTeX code.
    – Gaussler
    Commented Jul 15, 2022 at 9:11

2 Answers 2

6

Remove " as a shorthand for verbatim:

\documentclass{l3doc}
\usepackage{csquotes}
\AtBeginDocument{\DeleteShortVerb\"}
\MakeOuterQuote{"}
\begin{document}
\enquote{hello} "hello"
\end{document}

enter image description here

But as a german I would never use " for quotes, that clashes with the shorthands setup by babel for german.

3
  • Luckily turning off those pesky (if well-meaning) babel shorthands is easy: \usepackage[shorthands=off,ngerman]{babel}. I never understood the appeal in the first place.
    – Ingmar
    Commented Jul 15, 2022 at 8:38
  • @Ingmar I know that, but surprisingly I like to use the shorthands for hyphens and break commands like "" and "=. Commented Jul 15, 2022 at 8:39
  • Yes, I get that. The comment was not for your benefit, obviously :-) It's safe to assume that you know what you're doing.
    – Ingmar
    Commented Jul 15, 2022 at 8:43
2

Inside l3doc.cls there are those 2 lines hard coded

\AtBeginDocument
  {
    \MakeShortVerb \"
    \MakeShortVerb \|
  }

As such, the 2 characters " and | will be made into short-verb characters. (remark: documentation of \MakeShortVerb can be found in texdoc doc. The fancyvrb package that l3doc uses has a similar command, \DefineShortVerb)

Any attempt to redefine " in the preamble will be overridden, and csquotes does not support defining them in the document itself.

I can find a way to override the behavior, but it's rather ugly:

\RemoveFromHook{begindocument}[l3doc]
\MakeOuterQuote{"}

Side note, \RemoveFromHook is available in a sufficiently new LaTeX version. In older versions you might need to manipulate \@begindocumenthook manually...?

At least in the current version it won't have any unexpected consequence, as can be shown by executing

\ShowHook{begindocument}

which shows that the 2 commands above are the only ones that gets removed by the \RemoveFromHook.

(which means that in some future versions l3doc might do something-else in \AtBeginDocument and the code above would break. Use with care.)

(although you might want to manually \MakeShortVerb \| afterwards.)

You must log in to answer this question.

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