2

How is it possible to use combined Unicode characters (such as x̃, x̅, X̅, f̅, f᷉, f̂) in a definition of \DeclareUnicodeCharacter?

So something like \newunicodechar{x̃}{\tilde{x}} (using the package newunicodechar) or \DeclareUnicodeCharacter{00780303}{\tilde x} would be nice.

3
  • basically you can not. Supporting combining characters in pdftex is really hard. Apr 13, 2023 at 11:43
  • Thank you for this clear answer. It is a pity pdftex cannot handle this ‘simple’ character input :-( Apr 13, 2023 at 18:41
  • tex typesets characters as they appear, and once typeset they are not accessible from within tex. so it typesets an x, then sees a combining accent but can do nothing with it. Apr 13, 2023 at 18:44

1 Answer 1

2

It is hard, bordering impossible, to support unicode combining characters with pdftex.

This is not much of a problem in practice as (if using luatex is not an option) you can usually pre-process to handle the combinations.

For example if instead of using pdflatex directly you use myscript which is

sed -e 's/\(.\)\xcc\x83/\\tilde{\1}/g' \
    -e 's/\(.\)\xcc\x85/\\bar{\1}/g' \
    -e 's/\(.\)\xe1\xb7\x89/\\acute{\\grave{\\acute{\1}}}/g' \
    -e 's/\(.\)\xcc\x82/\\hat{\1}/g' \
    $1 > $1-

pdflatex $1-

then with file.tex

\documentclass{article}

\begin{document}

$x̃, x̅, X̅, f̅, f᷉, f̂$

\end{document}

the command myscript file.tex produces

enter image description here

The script is written using bash syntax but a .bat file for windows could be used with a suitable windows sed (or perl or python)

1
  • U+1dc9 COMBINING ACUTE-GRAVE-ACUTE should be horizontally stacked like '`' but that's just details, it is a never used character anyway in math, did you intend U+0304 COMBINING TILDE ~ ??? Apr 13, 2023 at 13:53

You must log in to answer this question.

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