# Redefining special characters as macros

I'd like to redefine some special characters as macros. Essentially, I want to tell lualatex to execute some user-defined commands whenever encountering some special characters, such as á, ḿ, etc.

I've found this solution. http://www.tex.ac.uk/FAQ-activechars.html

\catcode\z=\active
\def z{Yawn, I'm tired}%


Unfortunately I think it doesn't work for special characters. When I put á at where z is in the above code, I got the following error:

!Improper alphabetic constant.


Any suggestion? Please also help to add relevant tags.

## 1 Answer

Your á is not a single glyph but an a with a combining accent U+0301. With the proper glyph U+00E1 is works fine:

\documentclass{article}

\begin{document}
\catcode\á =\active
\def á {Yawn, I'm tired}%
á
\end{document}

• Thank you @Ulrike Fischer. How did you find out that the á in my original post is an a with a combing accent? – Roshnii Sep 6 '15 at 16:05
• I knew it ;-). Only this could explain your error. But I could also confirm it by converting it in babelpad. – Ulrike Fischer Sep 6 '15 at 16:19