# Custom font specifiers in AUCTeX

I would like to add a new font specifier, so that I can for example use C-c C-f C-a to insert \textcolour{blue}{*} Is this possible?

## 1 Answer

Customize the variable LaTeX-font-list with M-x customize-variable RET LaTeX-font-list RET.

Note that C-a is already preset. You can either change that entry or pick another key for your command. Then add \textcolour{blue}{ as Prefix and } as Suffix, and hit Apply and Save.

In order to make a choice for a key, these are the ones preset by AUCTeX (next release tracking changes in LaTeX kernel 2020-02-02):

(defcustom LaTeX-font-list
'((?\C-a ""              ""  "\\mathcal{"    "}")
(?\C-b "\\textbf{"     "}" "\\mathbf{"     "}")
(?\C-c "\\textsc{"     "}")
(?\C-e "\\emph{"       "}")
(?\C-f "\\textsf{"     "}" "\\mathsf{"     "}")
(?\C-i "\\textit{"     "}" "\\mathit{"     "}")
(?\C-l "\\textulc{"    "}")
(?\C-m "\\textmd{"     "}")
(?\C-n "\\textnormal{" "}" "\\mathnormal{" "}")
(?\C-r "\\textrm{"     "}" "\\mathrm{"     "}")
(?\C-s "\\textsl{"     "}" "\\mathbb{"     "}")
(?\C-t "\\texttt{"     "}" "\\mathtt{"     "}")
(?\C-u "\\textup{"     "}")
(?\C-w "\\textsw{"     "}")
(?\C-d "" "" t))
...


In order to set the chosen character in the customize buffer, you have to follow this guideline:

### 2.3.3.3 Control-Character Syntax

Control characters can be represented using yet another read syntax. This consists of a question mark followed by a backslash, caret, and the corresponding non-control character, in either upper or lower case. For example, both ?\^I and ?\^i are valid read syntax for the character C-i, the character whose value is 9.

Instead of the ^, you can use C-; thus, ?\C-i is equivalent to ?\^I and to ?\^i:
?\^I ⇒ 9 ?\C-I ⇒ 9

And don't be worry about the numbers you see in your init file. Again from the reference manual:

### 2.3.3 Character Type

A character in Emacs Lisp is nothing more than an integer. In other words, characters are represented by their character codes. For example, the character A is represented as the integer 65.

• Thanks! This worked but there's a couple of things I still don't understand. First, after M-x customize-variable RET LaTeX-font-list RET I get the Easy Customization tool, from which I can edit the variable entries. How do I enter values for keys in this tool? The built-in ones appear as e.g. ^A (in blue), but if I just write e.g. ^J in my new entry it doesn't accept it. Second, after saving in Easy Customization, it creates an entry in my .emacs file, which instead of having e.g. ?\C-a as your answer, just shows numbers for the key (e.g. 1 for C-a) What do these map to? – SuperNano Jan 12 '20 at 23:11
• @SuperNano - See updated answer. – Arash Esbati Jan 16 '20 at 22:14