How to fix kerning of comma/colon after quotes?

Hello, I’m a relative newbie in latex and am trying to reduce the space between closing quotes and colon/comma, but by a general way in the preamble, not by manual \kern commands.

My document is actually in Portuguese, where it’s common to keep punctuation after the quotes (unlike English). Also, it is written in Markdown and translated into Latex by Pandoc; so it has a lot of \enquote followed by \autocite commands, which may be followed by colons/commas. Since I’m using biblatex’s footnote style, these cases are also problematic.

In the next sample, my current situation is in line 1, but want it to look more like lines 2 or 3.

1) \enquote{something}\autocite{key}, or \enquote{something}.
2) \enquote{something}\kern-.3em,\autocite{key} or \enquote{something}\kern-.3em.
3) \enquote{something\makebox[0pt][l]{,}}\autocite{key} or \enquote{something\makebox[0pt][l]{.}}

Resulting image

Since Pandoc substitutes all quotes in my source file with \enquote commands, maybe a patch to it could do (but I dunno if it can deal with the interposed \autocite).

I'm using pdflatex as processor.

  • Are you loading the babel package with the portuguese option and the csquotes package with the autostyle option set?
    – Mico
    Commented Apr 22, 2012 at 23:01
  • 7
    With \textquote instead of \enquote, you can use the \mktextquote hook to move trailing punctuation and fix kerning. Alan gives an example here. If you move punctuation before the closing quotation mark, you'll probably want to use \DefineBibliographyExtras{portuguese}{\DeclareQuotePunctuation{.,}} for consistency.
    – Audrey
    Commented Apr 22, 2012 at 23:50
  • @Mico, yes I'm using them. @Audrey, I think this could do, but Pandoc generates \enquote followed by \autocite (like in my sample). Is there a way to redefine \enquote to check the following token(?) for \autocite and substitute it with the proper syntax (i.e., change from \enquote{bla}\autocite[key] to \textquote[\autocite{key}]{bla})?
    – ogoid
    Commented Apr 23, 2012 at 3:27
  • @ogoid Yes, this is why I steered clear from answering. Citation commands can take any number of keys; they just process them one by one. So redefining \enquote would (at best) be pretty involved.
    – Audrey
    Commented Apr 23, 2012 at 5:22
  • In my opinion: don't aim for #3 --- it looks weird and wrong. Also, your problem seems more related to the Markdown to LaTeX workflow. Is it reasonable to assume that a lightweight markup language will be able to do everything LaTeX does out of the box? That said, if you want this kind of cramped punctuation, a little post-processing with (say) sed would be easy enough.
    – jon
    Commented Apr 26, 2012 at 13:00

1 Answer 1


In this question it is shown how xetex and luatex can adjust font kerning automatically. I didn't test xetex's method, but this luatex code works like a charm:

local function kern_fix(fontdata)
 local ch = fontdata.characters[8221]
 ch.kerns = ch.kerns or {}
 ch.kerns[44] = -200000
 ch.kerns[46] = -200000
luatexbase.add_to_callback("luaotfload.patch_font", kern_fix, "kern_fix")

But since I want to stick with pdflatex my current solution is to use a perl script. This is my current makefile:

define PATCH
#remove italics in titles
if($$_ =~ /^#/) { $$_ =~ s/\*//g; }
#switch puncts and cites, but not inside footnotes
if($$_ !~ /^\[\^/) { $$_ =~ s/\s*(\[[^[^]*@[^[^]*\])([:punct:])/\2\1/g; }
#set old style numbers
$$_ =~ s/(\d+)/\\oldstylenums{\1}/g;
#insert kern between quotes and commas/colons
$$_ =~ s/’\s*([.,])/’\\kern-.15em\1/g;
$$_ =~ s/”\s*([.,])/”\\kern-.25em\1/g;
print $$_;
export PATCH

all: neumann.pdf

view: neumann.pdf
    open neumann.pdf

    rm -f neumann.{aux,bbl,bcf,blg,fls,fdb*,log,toc,out,pdf,dvi,run*,syn*,tex}

neumann.pdf: neumann.tex neumann.bib
    latexmk -quiet -pdf neumann

neumann.tex: template.tex neumann.md
    perl -ne "$$PATCH" neumann.md | pandoc --template=template.tex --bibliography=neumann.bib --biblatex -o neumann.tex

You must log in to answer this question.

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