@@ -69,6 +69,7 @@ enum eKeywordId {
6969 KEYWORD_declaremathoperator ,
7070 KEYWORD_newenvironment ,
7171 KEYWORD_renewenvironment ,
72+ KEYWORD_newtheorem ,
7273 KEYWORD_newcounter ,
7374};
7475typedef int keywordId ; /* to allow KEYWORD_NONE */
@@ -125,6 +126,7 @@ typedef enum {
125126 TEXTAG_COMMAND ,
126127 TEXTAG_OPERATOR ,
127128 TEXTAG_ENVIRONMENT ,
129+ TEXTAG_THEOREM ,
128130 TEXTAG_COUNTER ,
129131 TEXTAG_COUNT
130132} texKind ;
@@ -159,6 +161,7 @@ static kindDefinition TexKinds [] = {
159161 { true, 'C' , "command" , "command created with \\newcommand" },
160162 { true, 'o' , "operator" , "math operator created with \\DeclareMathOperator" },
161163 { true, 'e' , "environment" , "environment created with \\newenvironment" },
164+ { true, 't' , "theorem" , "theorem created with \\newtheorem" },
162165 { true, 'N' , "counter" , "counter created with \\newcounter" },
163166};
164167
@@ -185,6 +188,7 @@ static const keywordTable TexKeywordTable [] = {
185188 { "DeclareMathOperator" , KEYWORD_declaremathoperator },
186189 { "newenvironment" , KEYWORD_newenvironment },
187190 { "renewenvironment" , KEYWORD_renewenvironment },
191+ { "newtheorem" , KEYWORD_newtheorem },
188192 { "newcounter" , KEYWORD_newcounter },
189193};
190194
@@ -940,6 +944,50 @@ static bool parseNewEnvironment (tokenInfo *const token, bool *tokenUnprocessed)
940944 return eof ;
941945}
942946
947+ static bool parseNewTheorem (tokenInfo * const token , bool * tokenUnprocessed )
948+ {
949+ bool eof = false;
950+ /* \newtheorem{name}{title}
951+ \newtheorem{name}{title}[numbered_within]
952+ \newtheorem{name}[numbered_like]{title} */
953+ struct TexParseStrategy strategy [] = {
954+ {
955+ .type = '{' ,
956+ .flags = 0 ,
957+ .kindIndex = TEXTAG_THEOREM ,
958+ .roleIndex = ROLE_DEFINITION_INDEX ,
959+ .name = NULL ,
960+ .unique = false,
961+ },
962+ {
963+ .type = '[' ,
964+ .flags = TEX_NAME_FLAG_OPTIONAL ,
965+ .kindIndex = KIND_GHOST_INDEX ,
966+ .name = NULL ,
967+ },
968+ {
969+ .type = '{' ,
970+ .flags = 0 ,
971+ .kindIndex = KIND_GHOST_INDEX ,
972+ .name = NULL ,
973+ },
974+ {
975+ .type = '[' ,
976+ .flags = TEX_NAME_FLAG_OPTIONAL ,
977+ .kindIndex = KIND_GHOST_INDEX ,
978+ .name = NULL ,
979+ },
980+ {
981+ .type = 0
982+ }
983+ };
984+
985+ if (parseWithStrategy (token , strategy , tokenUnprocessed ))
986+ eof = true;
987+
988+ return eof ;
989+ }
990+
943991static bool parseNewcounter (tokenInfo * const token , bool * tokenUnprocessed )
944992{
945993 bool eof = false;
@@ -1048,6 +1096,9 @@ static void parseTexFile (tokenInfo *const token)
10481096 case KEYWORD_renewenvironment :
10491097 eof = parseNewEnvironment (token , & tokenUnprocessed );
10501098 break ;
1099+ case KEYWORD_newtheorem :
1100+ eof = parseNewTheorem (token , & tokenUnprocessed );
1101+ break ;
10511102 case KEYWORD_newcounter :
10521103 eof = parseNewcounter (token , & tokenUnprocessed );
10531104 break ;
0 commit comments