# Redefine quotation mark usage

I would like to be able to manually redefine quotation mark usage, preferably without having to load an external package.

Judging by the answer to How does TeX's mechanism for sorting out quotation marks work?, it seems that TeX and LaTeX use fonts that feature built-in ligatures to handle quotation mark conversion, while XeTeX and XeLaTeX refer to a map file that has the same function. The quotation marks are effectively ligatures, and not directly defined by the typesetting system.

However, I would like to be able to directly define the expected quotation mark result.

For example, I would like to define commands similar to the following (which do not work):

\def{\char"201C\char"202F\char"2018\relax}


which should render as something like “‘.

\def'''{\char"2019\char"202F\char"201D\relax}


which should render as something like ’”.

I would prefer a solution that could use any character or set of characters as the replacement, because I may have to customize the usage further in the future.

-
You can't do it in this way. Ligatures are substituted well down the digestion process, when macros are not a factor any more. Are you using XeLaTeX? –  egreg Nov 5 '12 at 10:22

It might be overkill, but I've found that one can achieve this through the use of LaTeX3's regular expression system.

The first thing to do is to disable the default TeX ligatures in a manner similar to the following:

\setmainfont[Ligatures={Common}, BoldFont={Calluna Semibold}]{Calluna}


Then define a command to perform a find and replace process on the text in a manner similar to the following:

\tl_new:N \l_demo
\cs_new:Npn \demo #1 {
\tl_set:Nn \l_demo {#1}
\regex_replace_all:nnN {\\\} {“‘} \l_demo
\regex_replace_all:nnN {\'\'\'} {’”} \l_demo
\tl_use:N \l_demo
}


The command can be called in the following manner:

\demo{These are fancy quotation marks.'''}


I am not sure if it is possible to have the \demo command automatically encompass the document` environment, but if it is possible, that would effectively automate the process.

And of course, one might want to reimplement (some of) the default TeX ligatures using this method, seeing as they have already been disabled.

-