TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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):


which should render as something like “‘.


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.

share|improve this question
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
up vote 3 down vote accepted

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.