# Defining TeX macros¶


$$\def\RR{{\bf R}} \def\bold#1{{\bf #1}}$$


would define \RR to produce a bold-faced “R”, and \bold{...} to put its argument into bold face. Both definitions would be available throughout the rest of the page.

You can include macro definitions in the macros section of the tex blocks of your configuration, but they must be represented as javascript objects. For example, the two macros above can be pre-defined in the configuration by

window.MathJax = {
tex: {
macros: {
RR: "{\\bf R}",
bold: ["{\\bf #1}", 1]
}
}
};


Here you give the macro as a name: value pair, where the name is the name of the control sequence (without the backslash) that you are defining, and value is either the replacement string for the macro (when there are no arguments) or an array consisting of the replacement string followed by the number of arguments for the macro and, optionally, default values for optional arguments.

Note that the replacement string is given as a javascript string literal, and the backslash has special meaning in javascript strings. So to get an actual backslash in the string you must double it, as in the examples above.