fvextra icon indicating copy to clipboard operation
fvextra copied to clipboard

Use curly quotes in `verbatim` environment

Open cykerway opened this issue 4 years ago • 3 comments

I was surprised to find loading package minted would change quote display in a verbatim (not Verbatim) environment.

My current understanding is that loading minted would also load fvextra and upquote in turn. It is the upquote package that modifies environment verbatim.

I don't think the fvextra package was made to hack verbatim. I would appreciate if you provide a package option curlyquotes such that if set then package upquote is not loaded at all, and so my verbatim environments are left untouched.

I have 2 temporary solutions to the problem at hand:

I can either use \begin{verbatim}[curlyquotes] for each verbatim environment, or call \fvset{curlyquotes=true} right after loading minted or fvextra. You see, neither is documented and I don't even know if they truly work.

To be precise, \fvset is documented but for Verbatim not verbatim.

cykerway avatar Jul 28 '20 18:07 cykerway

The overall issue is that upquote is the standard way to get non-curly quotation marks, and it overrides absolutely all verbatim environments, including verbatim and Verbatim plus any custom verbatim environments that depend on the standard \@noligs approach. It's basically an all-or-nothing approach. To avoid this, fvextra needs to completely reimplement upquote internally, so that only Verbatim is affected. I can look into doing that at some point in the future.

Probably the easiest way to work around this is to just patch verbatim by adding this in the preamble before upquote is loaded:

\makeatletter
\let\orig@noligs\@noligs
\usepackage{etoolbox}
\AtBeginEnvironment{verbatim}{\let\@noligs\orig@noligs}
\makeatother

This saves the condition of things before upquote, and then restores it, but only for verbatim.

gpoore avatar Jul 28 '20 19:07 gpoore

That looks promising.

Btw I think the standard way to get non-curly quotation marks is to not define that mapping at all. I'm using XeTeX and I prefer using Mapping=... rather than Ligatures=TeX in font options because I can customize the mapping file to keep only those ligatures I want. upquote looks like a hack that undoes a do. Maybe there is a reason for doing so on other TeX engines I'm not familiar with.

cykerway avatar Jul 28 '20 22:07 cykerway

There may be better ways to handle quotation marks under XeTeX and LuaTeX. I think upquote has been around for a while. Some of this may be required for pdfTeX.

gpoore avatar Jul 28 '20 22:07 gpoore