Change the catcode and then define a (Unicode) character

\documentclass{article}

\def\activatedefine#1{\begingroup\lccode`~=`#1\relax
                      \lowercase{\endgroup\def~}}%

\activatedefine¯#1#2{\overline{#1#2}}

\begin{document}

$¯ab+¯bc=¯ac$
\end{document}

\documentclass{article}

\def\activatedefine#1{\begingroup\lccode`~=`#1\relax
                      \lowercase{\endgroup\catcode`#1\active\def~}}%

\activatedefine|#1#2{\overline{#1#2}}

\begin{document}
$|ab+|bc=|ac$
\end{document}

enter image description here

I did not pay much attention to the actual macro, which is in math mode so math active would be possibly better.

Besides I don't want to have to handle UTF-8, so I used | rather for the example.


AH! but OP is using XeTeX. So we can do this

\documentclass{article}

\def\activatedefine#1{\begingroup\lccode`~=`#1\relax
                      \lowercase{\endgroup\catcode`#1\active\def~}}%

\activatedefine¯#1#2{\overline{#1#2}}

\begin{document}
\the\catcode`¯ % ONLY XETEX, NOT PDFTEX!

$¯ab+¯bc=¯ac$
\end{document}
% Local variables:
% TeX-engine: xetex
% End:

enter image description here

Problem with pdflatex is that ¯ is multibyte, and the erased code at top of my answer was redefinig the first byte, breaking LaTeX UTF-8.


The simplest way is to use \newunicodechar; it just defines parameterless macros, but we can exploit the fact TeX is a macro expansion language to begin with.

Note that these examples can be used with all TeX engines (except Knuth TeX).

\documentclass{article}

\usepackage{newunicodechar}

\newunicodechar{‾}{\overline}

\newcommand{\twooverline}[2]{\overline{#1#2}}
\newunicodechar{﹌}{\twooverline}

\begin{document}

$‾a$ $﹌ab$

\end{document}

enter image description here

Another example:

\documentclass{article}

\usepackage{newunicodechar}

\makeatletter
\newunicodechar{‾}{\symbol@overline}
\def\symbol@overline#1‾{\overline{#1}} % must go second

\begin{document}

$‾abc‾$

\end{document}

enter image description here