# Différences

Ci-dessous, les différences entre deux révisions de la page.

 2_programmation:syntaxe:catcodes:liste_des_catcodes [2017/06/20 17:12]jgrimm 2_programmation:syntaxe:catcodes:liste_des_catcodes [2017/06/21 11:18] (Version actuelle)jejust [Catcode 12] Correction orthographe. Les deux révisions précédentes Révision précédente 2017/06/21 11:18 jejust [Catcode 12] Correction orthographe.2017/06/21 11:15 jgrimm 2017/06/20 17:12 jgrimm 2017/06/20 15:43 jgrimm 2017/06/18 16:13 jgrimm créée Prochaine révision Révision précédente 2017/06/21 11:18 jejust [Catcode 12] Correction orthographe.2017/06/21 11:15 jgrimm 2017/06/20 17:12 jgrimm 2017/06/20 15:43 jgrimm 2017/06/18 16:13 jgrimm créée Ligne 1: Ligne 1: - ====== Quels sont les différents catcodes ? ====== + ====== Quels sont les différents catcodes? ====== Ligne 35: Ligne 35: Note the following points. Both ''​\typeout''​ and ''​\show''​ print the value on the tty as well as the transcript file. The token list of ''​\typeout''​ is fully expanded, and for this reason, we put in a token list the quantity ''#​1wantd:​ ->#​2''​. and inhibit expansion via ''​\the''​. Note the following points. Both ''​\typeout''​ and ''​\show''​ print the value on the tty as well as the transcript file. The token list of ''​\typeout''​ is fully expanded, and for this reason, we put in a token list the quantity ''#​1wantd:​ ->#​2''​. and inhibit expansion via ''​\the''​. - + ----- - ===== The symbols, by catcode ===== + Unless stated otherwise, a category code (in short a //​catcode//​) is an integer between **0** and **15**. It is a property of input characters, used by the scanner to convert the input stream into a sequence of tokens. The character with ASCII code 37 is the character ''​%'',​ and is normally of category 14, thus behaves like a start-of-comment. You can insert such a character in the XML output via the sequence ''​\char37''​ (However ''​\char60''​ produces <​latex>​$<​$,​ see the ''​\char''​ command). In most of the cases, a character of catcode c is read as a command with command code c. Unless stated otherwise, a category code (in short a //​catcode//​) is an integer between **0** and **15**. It is a property of input characters, used by the scanner to convert the input stream into a sequence of tokens. The character with ASCII code 37 is the character ''​%'',​ and is normally of category 14, thus behaves like a start-of-comment. You can insert such a character in the XML output via the sequence ''​\char37''​ (However ''​\char60''​ produces <​latex>​$<​$,​ see the ''​\char''​ command). In most of the cases, a character of catcode c is read as a command with command code c. Ligne 42: Ligne 41: Tralics uses the same parsing rules as TeX, with the exception of characters of category 16 (see below), and the fact that the character range is not limited to 8bit characters but to 16 bits. A construction like ''​^^^^^1d7e0''​ provides a character without category code, see the documentation on characters. Tralics uses the same parsing rules as TeX, with the exception of characters of category 16 (see below), and the fact that the character range is not limited to 8bit characters but to 16 bits. A construction like ''​^^^^^1d7e0''​ provides a character without category code, see the documentation on characters. - ==== Catcode 0 ==== + ===== Catcode 0 ===== The only character with catcode 0 is the backslash. This character is used to construct command names. The number 0 is not a command code. The command name is created as follows: if the next character is not of category 11, the name consists of the single character, and Tralics goes into state **S** if the character is a space, state **M** otherwise; if the character is of category 11, the name consists of all characters category 11 starting with the current one, and Tralics goes into state **S**. The first unused character will be read again later, and a category code assigned to it. Normally, spaces after command names are ignored because the current state **S** and the category code of the space character is 10. But the command can change the category code of the character that follows. The only character with catcode 0 is the backslash. This character is used to construct command names. The number 0 is not a command code. The command name is created as follows: if the next character is not of category 11, the name consists of the single character, and Tralics goes into state **S** if the character is a space, state **M** otherwise; if the character is of category 11, the name consists of all characters category 11 starting with the current one, and Tralics goes into state **S**. The first unused character will be read again later, and a category code assigned to it. Normally, spaces after command names are ignored because the current state **S** and the category code of the space character is 10. But the command can change the category code of the character that follows. Ligne 72: Ligne 71: ​ - ==== Catcode 1 ==== + ===== Catcode 1 ===== Initially, the only character of catcode 1 is the open brace. See below. Initially, the only character of catcode 1 is the open brace. See below. - ==== Catcode 2 ==== + ===== Catcode 2 ===== Initially, the only character of catcode 2 is the closing brace. Initially, the only character of catcode 2 is the closing brace. Ligne 91: Ligne 90: Note the following trick: ''​\uppercase \relax\bgroup}''​. After ''​\uppercase''​ and commands like that, you can have an arbitrary sequence of spaces and ''​\relax''​ commands. The argument is delimited on the left by an implicit left brace, on the right by an explicit right brace. Note the following trick: ''​\uppercase \relax\bgroup}''​. After ''​\uppercase''​ and commands like that, you can have an arbitrary sequence of spaces and ''​\relax''​ commands. The argument is delimited on the left by an implicit left brace, on the right by an explicit right brace. - ==== Catcode 3 ==== + ===== Catcode 3 ===== Initially, the only character with catcode 3 is the dollar sign. It is used to enter and exit math and display math mode. A construct like ''​{\catcode x=3 \catcodey=3 xy \sinxy}''​ is the same as ''​$\sin$''​. Initially, the only character with catcode 3 is the dollar sign. It is used to enter and exit math and display math mode. A construct like ''​{\catcode x=3 \catcodey=3 xy \sinxy}''​ is the same as ''​$\sin$''​. - ==== Catcode 4 ==== + ===== Catcode 4 ===== The only character with catcode 4 is the alignment tab character ''&''​. (see description of arrays). The only character with catcode 4 is the alignment tab character ''&''​. (see description of arrays). - ==== Catcode 5 ==== + ===== Catcode 5 ===== The only character with catcode 5 is the end-of-line character (carriage return, ASCII code 13). When <​latex>​\TeX​ sees such a character, it throws away the remaining of the line. If TeX is in state **N**, the result is a ''​\par''​ token; if TeX is in state **M**, the result is a newline token of catcode 10, and otherwise, the character is ignored. For Tralics, the newline token has value 10 (line-feed),​ and not 32 (space) as in TeX. As a result, in most cases, newline characters remain in the XML result, whenever they are equivalent to space (the purpose is to make the output more readable). Note that Tralics is in state **N** whenever it reads the first character of a line. The number 5 is not a command code. The only character with catcode 5 is the end-of-line character (carriage return, ASCII code 13). When <​latex>​\TeX​ sees such a character, it throws away the remaining of the line. If TeX is in state **N**, the result is a ''​\par''​ token; if TeX is in state **M**, the result is a newline token of catcode 10, and otherwise, the character is ignored. For Tralics, the newline token has value 10 (line-feed),​ and not 32 (space) as in TeX. As a result, in most cases, newline characters remain in the XML result, whenever they are equivalent to space (the purpose is to make the output more readable). Note that Tralics is in state **N** whenever it reads the first character of a line. The number 5 is not a command code. Ligne 105: Ligne 104: Whenever Tralics sees a new line, it inserts the character defined by the ''​\endlinechar''​ command. This character is by default the end of line character, see ''​\endlinechar''​. Whenever Tralics sees a new line, it inserts the character defined by the ''​\endlinechar''​ command. This character is by default the end of line character, see ''​\endlinechar''​. - ==== Catcode 6 ==== + ===== Catcode 6 ===== The only character with catcode 6 is the sharp sign ''#''​. This character is used as parameter delimiter or parameter reference in macro definitions. It is also used in TeX table preambles (but not in LaTeX not Tralics). In the definition of ''​\xbar''​ below, the quantity ''#​1''​ refers to the first argument of ''​\Ma'',​ ''##​1''​ refers to the first argument of ''​\Mb''​ and ''####​1''​ could be used to refer to the first argument of ''​\xbar''​. As you can see, the sharp character can be replaced by any character of catcode 6. In order to put in a command a character of category code 6, it suffices to precede it by any character of catcode 6. The body of the ''​\xfoo''​ command is ''#​A#​A'',​ but the printer shows it as ''##​AA##​AA''​. Example The only character with catcode 6 is the sharp sign ''#''​. This character is used as parameter delimiter or parameter reference in macro definitions. It is also used in TeX table preambles (but not in LaTeX not Tralics). In the definition of ''​\xbar''​ below, the quantity ''#​1''​ refers to the first argument of ''​\Ma'',​ ''##​1''​ refers to the first argument of ''​\Mb''​ and ''####​1''​ could be used to refer to the first argument of ''​\xbar''​. As you can see, the sharp character can be replaced by any character of catcode 6. In order to put in a command a character of category code 6, it suffices to precede it by any character of catcode 6. The body of the ''​\xfoo''​ command is ''#​A#​A'',​ but the printer shows it as ''##​AA##​AA''​. Example Ligne 126: Ligne 125: ​ - ==== Catcode 7 ==== + ===== Catcode 7 ===== The only character with catcode 7 is the hat. This character is used in math mode for superscripts. It is also used in the double hat construct: if a character of catcode 7 appears twice in a row, like in ''​^^13''​ and ''​^^ab'',​ and is followed by two digits in base 16, it is as if the character with this code had been given (here, code 19, and 171); note that only lowercase letters are allowed here. In the case where a character of catcode 7 appears twice in a row, and is followed by a 7bit character of code c (like ''​^^Z''​ or ''​^^A''​ or ''​^^{''​),​ it is as if TeX had seen a character of code c-64 or c+64 (the one which is between 0 and 128). In the example, the numbers are 26, 1 and 59. The catcode of this character is examined again, for instance ''​^^5e''​ is the hat character, of catcode 7. The only character with catcode 7 is the hat. This character is used in math mode for superscripts. It is also used in the double hat construct: if a character of catcode 7 appears twice in a row, like in ''​^^13''​ and ''​^^ab'',​ and is followed by two digits in base 16, it is as if the character with this code had been given (here, code 19, and 171); note that only lowercase letters are allowed here. In the case where a character of catcode 7 appears twice in a row, and is followed by a 7bit character of code c (like ''​^^Z''​ or ''​^^A''​ or ''​^^{''​),​ it is as if TeX had seen a character of code c-64 or c+64 (the one which is between 0 and 128). In the example, the numbers are 26, 1 and 59. The catcode of this character is examined again, for instance ''​^^5e''​ is the hat character, of catcode 7. Ligne 166: Ligne 165: ​ - Preview: ^^^^ example - ==== Catcode 8 ==== + ===== Catcode 8 ===== The only character with catcode 8 is the underscore character. It is used for subscripts in math mode. See the ''​\sp''​ command for an example of use. The only character with catcode 8 is the underscore character. It is used for subscripts in math mode. See the ''​\sp''​ command for an example of use. Ligne 195: Ligne 193: ​ - ==== Catcode 9 ==== + ===== Catcode 9 ===== Characters of code 9 are ignored. Initially, no character has this category code. Characters of code 9 are ignored. Initially, no character has this category code. - ==== Catcode 10 ==== + ===== Catcode 10 ===== A character of catcode 10 acts like a space. If TeX sees a character of catcode 10, the action depends on the current state. If the state is **N** or **S**, the character is ignored. Otherwise, TeX is in state **M** and changes to state **S**, and the result is a space token (character 32, category 10). Space, tabulation are of catcode 10. A character of catcode 10 acts like a space. If TeX sees a character of catcode 10, the action depends on the current state. If the state is **N** or **S**, the character is ignored. Otherwise, TeX is in state **M** and changes to state **S**, and the result is a space token (character 32, category 10). Space, tabulation are of catcode 10. Ligne 205: Ligne 203: Spaces are in general ignored at start of line, because TeX is in state **M**. In verbatim mode, the catcode of the space is changed, and thus spaces remain. Spaces are in general ignored at start of line, because TeX is in state **M**. In verbatim mode, the catcode of the space is changed, and thus spaces remain. - ==== Catcode 11 ==== + ===== Catcode 11 ===== Characters of catcode letter can be used to make multiletter control sequences (without using ''​\csname''​). Only ASCII letter (between ''​a''​ and ''​z'',​ or between ''​A''​ and ''​Z''​) are by default of catcode 11. Characters of catcode letter can be used to make multiletter control sequences (without using ''​\csname''​). Only ASCII letter (between ''​a''​ and ''​z'',​ or between ''​A''​ and ''​Z''​) are by default of catcode 11. - ==== Catcode 12 ==== + ===== Catcode 12 ===== - Characters of catcode 12 cannot be used to make multiletter control sequences. All characters not liste elsewhere are of catcode 12 (especially,​ all 8-bit characters). + Characters of catcode 12 cannot be used to make multiletter control sequences. + All characters not listed ​elsewhere are of catcode 12 (especially,​ all 8-bit characters). - ==== Catcode 13 ==== + ===== Catcode 13 ===== Characters of category 13 are active. They can be used only if a definition is associated. In Tralics only the tilde character is of 13, but the three characters ''​_#&''​ have a definition (the translation is the character). Note that, in PlainTeX, the tilde character expands to ''​\penalty \@M \ ''​ (there is a space at the end of the command) and in LaTeX to ''​\nobreakspace{}'',​ which is the same with a ''​\leavevmode''​ in front, in Tralics, the expansion is simply ''​\nobreakspace''​. Characters of category 13 are active. They can be used only if a definition is associated. In Tralics only the tilde character is of 13, but the three characters ''​_#&''​ have a definition (the translation is the character). Note that, in PlainTeX, the tilde character expands to ''​\penalty \@M \ ''​ (there is a space at the end of the command) and in LaTeX to ''​\nobreakspace{}'',​ which is the same with a ''​\leavevmode''​ in front, in Tralics, the expansion is simply ''​\nobreakspace''​. - ==== Catcode 14 ==== + ===== Catcode 14 ===== Characters of catcode 14 act like an start-of-comment character. The only character with catcode 14 is the percent character. Characters of catcode 14 act like an start-of-comment character. The only character with catcode 14 is the percent character. - ==== Catcode 15 ==== + ===== Catcode 15 ===== Characters of catcode 15 are invalid. There is no invalid character in Tralics. Characters of catcode 15 are invalid. There is no invalid character in Tralics. - ==== Catcode 16 ==== + ===== Catcode 16 ===== There is no character of catcode 16 in TeX . In Tralics, this code is reserved for verbatim-like characters, defined by ''​\DefineShortVerb''​. These characters act is if they were preceded by ''​\verb''​. Note that the star character is not exceptional. You can use ''​\fvset'',​ if you want to change the translation of a space. There is no character of catcode 16 in TeX . In Tralics, this code is reserved for verbatim-like characters, defined by ''​\DefineShortVerb''​. These characters act is if they were preceded by ''​\verb''​. Note that the star character is not exceptional. You can use ''​\fvset'',​ if you want to change the translation of a space. Ligne 279: Ligne 278: ​ - Preview: example of ShortVerb ----- -----
2_programmation/syntaxe/catcodes/liste_des_catcodes.1497971556.txt.gz · Dernière modification: 2017/06/20 17:12 par jgrimm