1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Utilities for Latex conversion.
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
33 * Variables accessible from clients
37 TexChunk
* DocumentTitle
= NULL
;
38 TexChunk
* DocumentAuthor
= NULL
;
39 TexChunk
* DocumentDate
= NULL
;
41 // Header/footers/pagestyle
42 TexChunk
* LeftHeaderEven
= NULL
;
43 TexChunk
* LeftFooterEven
= NULL
;
44 TexChunk
* CentreHeaderEven
= NULL
;
45 TexChunk
* CentreFooterEven
= NULL
;
46 TexChunk
* RightHeaderEven
= NULL
;
47 TexChunk
* RightFooterEven
= NULL
;
48 TexChunk
* LeftHeaderOdd
= NULL
;
49 TexChunk
* LeftFooterOdd
= NULL
;
50 TexChunk
* CentreHeaderOdd
= NULL
;
51 TexChunk
* CentreFooterOdd
= NULL
;
52 TexChunk
* RightHeaderOdd
= NULL
;
53 TexChunk
* RightFooterOdd
= NULL
;
54 char * PageStyle
= copystring("plain");
56 int DocumentStyle
= LATEX_REPORT
;
57 int MinorDocumentStyle
= 0;
58 wxPathList TexPathList
;
59 char * BibliographyStyleString
= copystring("plain");
60 char * DocumentStyleString
= copystring("report");
61 char * MinorDocumentStyleString
= NULL
;
76 * USER-ADJUSTABLE SETTINGS
81 int chapterFont
= 12; // LARGEFont3;
82 int sectionFont
= 12; // LargeFont2;
83 int subsectionFont
= 12; // largeFont1;
84 int titleFont
= LARGEFont3
;
85 int authorFont
= LargeFont2
;
86 int mirrorMargins
= TRUE
;
87 bool winHelp
= FALSE
; // Output in Windows Help format if TRUE, linear otherwise
88 bool isInteractive
= FALSE
;
89 bool runTwice
= FALSE
;
90 int convertMode
= TEX_RTF
;
91 bool headerRule
= FALSE
;
92 bool footerRule
= FALSE
;
93 bool compatibilityMode
= FALSE
; // If TRUE, maximum Latex compatibility
94 // (Quality of RTF generation deteriorate)
95 bool generateHPJ
; // Generate WinHelp Help Project file
96 char *winHelpTitle
= NULL
; // Windows Help title
97 int defaultTableColumnWidth
= 2000;
99 int labelIndentTab
= 18; // From left indent to item label (points)
100 int itemIndentTab
= 40; // From left indent to item (points)
102 bool useUpButton
= TRUE
;
103 int htmlBrowseButtons
= HTML_BUTTONS_TEXT
;
105 bool truncateFilenames
= FALSE
; // Truncate for DOS
106 int winHelpVersion
= 3; // WinHelp Version (3 for Windows 3.1, 4 for Win95)
107 bool winHelpContents
= FALSE
; // Generate .cnt file for WinHelp 4
108 bool htmlIndex
= FALSE
; // Generate .htx file for HTML
109 bool htmlFrameContents
= FALSE
; // Use frames for HTML contents page
110 bool useHeadingStyles
= TRUE
; // Insert \s1, s2 etc.
111 bool useWord
= TRUE
; // Insert proper Word table of contents, etc etc
112 int contentsDepth
= 4; // Depth of Word table of contents
113 bool indexSubsections
= TRUE
; // Index subsections in linear RTF
114 // Linear RTF method of including bitmaps. Can be "includepicture", "hex"
115 char *bitmapMethod
= copystring("includepicture");
116 bool upperCaseNames
= FALSE
;
117 // HTML background and text colours
118 char *backgroundImageString
= NULL
;
119 char *backgroundColourString
= copystring("255;255;255");
120 char *textColourString
= NULL
;
121 char *linkColourString
= NULL
;
122 char *followedLinkColourString
= NULL
;
123 bool combineSubSections
= FALSE
;
126 * International support
129 // Names to help with internationalisation
130 char *ContentsNameString
= copystring("Contents");
131 char *AbstractNameString
= copystring("Abstract");
132 char *GlossaryNameString
= copystring("Glossary");
133 char *ReferencesNameString
= copystring("References");
134 char *FiguresNameString
= copystring("List of Figures");
135 char *TablesNameString
= copystring("List of Tables");
136 char *FigureNameString
= copystring("Figure");
137 char *TableNameString
= copystring("Table");
138 char *IndexNameString
= copystring("Index");
139 char *ChapterNameString
= copystring("chapter");
140 char *SectionNameString
= copystring("section");
141 char *SubsectionNameString
= copystring("subsection");
142 char *SubsubsectionNameString
= copystring("subsubsection");
143 char *UpNameString
= copystring("Up");
152 int subsectionNo
= 0;
153 int subsubsectionNo
= 0;
162 FILE *CurrentOutput1
= NULL
;
163 FILE *CurrentOutput2
= NULL
;
167 int CurrentInputIndex
= 0;
169 char *TexFileRoot
= NULL
;
170 char *TexBibName
= NULL
; // Bibliography output file name
171 char *TexTmpBibName
= NULL
; // Temporary bibliography output file name
172 bool isSync
= FALSE
; // If TRUE, should not yield to other processes.
173 bool stopRunning
= FALSE
; // If TRUE, should abort.
175 static int currentColumn
= 0;
176 char *currentArgData
= NULL
;
177 bool haveArgData
= FALSE
; // If TRUE, we're simulating the data.
178 TexChunk
*currentArgument
= NULL
;
179 TexChunk
*nextChunk
= NULL
;
180 bool isArgOptional
= FALSE
;
183 TexChunk
*TopLevel
= NULL
;
184 // wxList MacroDefs(wxKEY_STRING);
185 wxHashTable
MacroDefs(wxKEY_STRING
);
186 wxStringList IgnorableInputFiles
; // Ignorable \input files, e.g. psbox.tex
187 char *BigBuffer
= NULL
; // For reading in large chunks of text
188 TexMacroDef
*SoloBlockDef
= NULL
;
189 TexMacroDef
*VerbatimMacroDef
= NULL
;
191 #define IncrementLineNumber() LineNumbers[CurrentInputIndex] ++
193 void TexOutput(char *s
, bool ordinaryText
)
197 // Update current column, but only if we're guaranteed to
198 // be ordinary text (not mark-up stuff)
201 for (i
= 0; i
< len
; i
++)
203 if (s
[i
] == 13 || s
[i
] == 10)
210 fprintf(CurrentOutput1
, "%s", s
);
212 fprintf(CurrentOutput2
, "%s", s
);
216 * Try to find a Latex macro, in one of the following forms:
217 * (1) \begin{} ... \end{}
218 * (2) \macroname{arg1}...{argn}
222 void ForbidWarning(TexMacroDef
*def
)
225 switch (def
->forbidden
)
229 sprintf(buf
, "Warning: it is recommended that command %s is not used.", def
->name
);
233 case FORBID_ABSOLUTELY
:
235 sprintf(buf
, "Error: command %s cannot be used and will lead to errors.", def
->name
);
244 TexMacroDef
*MatchMacro(char *buffer
, int *pos
, char **env
, bool *parseToBrace
)
246 *parseToBrace
= TRUE
;
248 TexMacroDef
*def
= NULL
;
251 // First, try to find begin{thing}
252 if (strncmp(buffer
+i
, "begin{", 6) == 0)
257 while ((isalpha(buffer
[j
]) || buffer
[j
] == '*') && ((j
- i
) < 39))
259 macroBuf
[j
-i
] = buffer
[j
];
263 def
= (TexMacroDef
*)MacroDefs
.Get(macroBuf
);
267 *pos
= j
+ 1; // BUGBUG Should this be + 1???
275 // Failed, so try to find macro from definition list
278 // First try getting a one-character macro, but ONLY
279 // if these TWO characters are not both alphabetical (could
280 // be a longer macro)
281 if (!(isalpha(buffer
[i
]) && isalpha(buffer
[i
+1])))
283 macroBuf
[0] = buffer
[i
];
286 def
= (TexMacroDef
*)MacroDefs
.Get(macroBuf
);
292 while ((isalpha(buffer
[j
]) || buffer
[j
] == '*') && ((j
- i
) < 39))
294 macroBuf
[j
-i
] = buffer
[j
];
298 def
= (TexMacroDef
*)MacroDefs
.Get(macroBuf
);
305 // We want to check whether this is a space-consuming macro
307 // No brace, e.g. \input thing.tex instead of \input{thing};
308 // or a numeric argument, such as \parindent0pt
309 if ((def
->no_args
> 0) && ((buffer
[i
] == 32) || (buffer
[i
] == '=') || (isdigit(buffer
[i
]))))
311 if ((buffer
[i
] == 32) || (buffer
[i
] == '='))
314 *parseToBrace
= FALSE
;
323 void EatWhiteSpace(char *buffer
, int *pos
)
325 int len
= strlen(buffer
);
327 bool keepGoing
= TRUE
;
328 bool moreLines
= TRUE
;
329 while ((j
< len
) && keepGoing
&&
330 (buffer
[j
] == 10 || buffer
[j
] == 13 || buffer
[j
] == ' ' || buffer
[j
] == 9))
337 moreLines
= read_a_line(buffer
);
338 len
= strlen(buffer
);
348 bool FindEndEnvironment(char *buffer
, int *pos
, char *env
)
352 // Try to find end{thing}
353 if ((strncmp(buffer
+i
, "end{", 4) == 0) &&
354 (strncmp(buffer
+i
+4, env
, strlen(env
)) == 0))
356 *pos
= i
+ 5 + strlen(env
);
362 bool readingVerbatim
= FALSE
;
363 bool readInVerbatim
= FALSE
; // Within a verbatim, but not nec. verbatiminput
365 bool read_a_line(char *buf
)
367 if (CurrentInputIndex
< 0)
376 while (ch
!= EOF
&& ch
!= 10)
378 if (((i
== 14) && (strncmp(buf
, "\\end{verbatim}", 14) == 0)) ||
379 ((i
== 16) && (strncmp(buf
, "\\end{toocomplex}", 16) == 0)))
380 readInVerbatim
= FALSE
;
382 ch
= getc(Inputs
[CurrentInputIndex
]);
385 // Check for 2 consecutive newlines and replace with \par
386 if (ch
== 10 && !readInVerbatim
)
388 int ch1
= getc(Inputs
[CurrentInputIndex
]);
389 if ((ch1
== 10) || (ch1
== 13))
391 // Eliminate newline (10) following DOS linefeed
392 if (ch1
== 13) ch1
= getc(Inputs
[CurrentInputIndex
]);
394 IncrementLineNumber();
395 // strcat(buf, "\\par\n");
397 strcat(buf
, "\\par");
402 ungetc(ch1
, Inputs
[CurrentInputIndex
]);
410 // Convert embedded characters to RTF equivalents
424 case 0xf6:buf
[i
++]='o';break; // ö
425 case 0xe4:buf
[i
++]='a';break; // ä
426 case 0xfc:buf
[i
++]='u';break; // ü
427 case 0xd6:buf
[i
++]='O';break; // Ö
428 case 0xc4:buf
[i
++]='A';break; // Ä
429 case 0xdc:buf
[i
++]='U';break; // Ü
450 fclose(Inputs
[CurrentInputIndex
]);
451 Inputs
[CurrentInputIndex
] = NULL
;
452 if (CurrentInputIndex
> 0) ch
= ' '; // No real end of file
453 CurrentInputIndex
--;
456 readingVerbatim
= FALSE
;
457 readInVerbatim
= FALSE
;
458 strcat(buf
, "\\end{verbatim}\n");
463 IncrementLineNumber();
467 // Strip out comment environment
468 if (strncmp(buf
, "\\begin{comment}", 15) == 0)
470 while (strncmp(buf
, "\\end{comment}", 13) != 0)
472 return read_a_line(buf
);
474 // Read a verbatim input file as if it were a verbatim environment
475 else if (strncmp(buf
, "\\verbatiminput", 14) == 0)
478 char *fileName
= buf
+ wordLen
+ 1;
483 // thing}\par -- eliminate the \par!
484 if (strncmp((buf
+ strlen(buf
)-5), "\\par", 4) == 0)
490 if (buf
[j
-1] == '}') buf
[j
-1] = 0; // Ignore final brace
492 wxString actualFile
= TexPathList
.FindValidPath(fileName
);
493 if (actualFile
== "")
496 strcpy(errBuf
, "Could not find file: ");
497 strncat(errBuf
, fileName
, 100);
502 CurrentInputIndex
++;
503 Inputs
[CurrentInputIndex
] = fopen(actualFile
, "r");
504 LineNumbers
[CurrentInputIndex
] = 1;
505 if (FileNames
[CurrentInputIndex
])
506 delete[] FileNames
[CurrentInputIndex
];
507 FileNames
[CurrentInputIndex
] = copystring(actualFile
);
509 if (!Inputs
[CurrentInputIndex
])
511 CurrentInputIndex
--;
512 OnError("Could not open verbatiminput file.");
516 readingVerbatim
= TRUE
;
517 readInVerbatim
= TRUE
;
518 strcpy(buf
, "\\begin{verbatim}\n");
524 else if (strncmp(buf
, "\\input", 6) == 0 || strncmp(buf
, "\\helpinput", 10) == 0 ||
525 strncmp(buf
, "\\include", 8) == 0)
528 if (strncmp(buf
, "\\input", 6) == 0)
531 if (strncmp(buf
, "\\include", 8) == 0)
536 char *fileName
= buf
+ wordLen
+ 1;
541 // \input{thing}\par -- eliminate the \par!
542 // if (strncmp((buf + strlen(buf)-5), "\\par", 4) == 0)
543 if (strncmp((buf
+ strlen(buf
)-4), "\\par", 4) == 0) // Bug fix 8/2/95 Ulrich Leodolter
550 if (buf
[j
-1] == '}') buf
[j
-1] = 0; // Ignore final brace
552 // Ignore some types of input files (e.g. macro definition files)
553 char *fileOnly
= FileNameFromPath(fileName
);
554 if (IgnorableInputFiles
.Member(fileOnly
))
555 return read_a_line(buf
);
557 wxString actualFile
= TexPathList
.FindValidPath(fileName
);
558 if (actualFile
== "")
561 sprintf(buf2
, "%s.tex", fileName
);
562 actualFile
= TexPathList
.FindValidPath(buf2
);
564 if (actualFile
== "")
567 strcpy(errBuf
, "Could not find file: ");
568 strncat(errBuf
, fileName
, 100);
573 // Ensure that if this file includes another,
574 // then we look in the same directory as this one.
575 TexPathList
.EnsureFileAccessible(actualFile
);
577 CurrentInputIndex
++;
578 Inputs
[CurrentInputIndex
] = fopen(actualFile
, "r");
579 LineNumbers
[CurrentInputIndex
] = 1;
580 if (FileNames
[CurrentInputIndex
])
581 delete[] FileNames
[CurrentInputIndex
];
582 FileNames
[CurrentInputIndex
] = copystring(actualFile
);
584 if (!Inputs
[CurrentInputIndex
])
587 sprintf(errBuf
, "Could not open include file %s", (const char*) actualFile
);
588 CurrentInputIndex
--;
592 bool succ
= read_a_line(buf
);
595 if (strncmp(buf
, "\\begin{verbatim}", 16) == 0 ||
596 strncmp(buf
, "\\begin{toocomplex}", 18) == 0)
597 readInVerbatim
= TRUE
;
598 else if (strncmp(buf
, "\\end{verbatim}", 14) == 0 ||
599 strncmp(buf
, "\\end{toocomplex}", 16) == 0)
600 readInVerbatim
= FALSE
;
610 bool ParseNewCommand(char *buffer
, int *pos
)
612 if ((strncmp((buffer
+(*pos
)), "newcommand", 10) == 0) ||
613 (strncmp((buffer
+(*pos
)), "renewcommand", 12) == 0))
615 if (strncmp((buffer
+(*pos
)), "newcommand", 10) == 0)
620 char commandName
[100];
621 char commandValue
[1000];
624 while (buffer
[*pos
] != '}' && (buffer
[*pos
] != 0))
626 commandName
[i
] = buffer
[*pos
];
633 if (buffer
[*pos
] == '[')
636 noArgs
= (int)(buffer
[*pos
]) - 48;
637 *pos
+= 2; // read past argument and '['
643 char ch
= buffer
[*pos
];
654 if (!read_a_line(buffer
))
659 commandValue
[i
] = ch
;
665 CustomMacro
*macro
= new CustomMacro(commandName
, noArgs
, NULL
);
666 if (strlen(commandValue
) > 0)
667 macro
->macroBody
= copystring(commandValue
);
668 if (!CustomMacroList
.Find(commandName
))
670 CustomMacroList
.Append(commandName
, macro
);
671 AddMacroDef(ltCUSTOM_MACRO
, commandName
, noArgs
);
678 void MacroError(char *buffer
)
685 while (((ch
= buffer
[i
-1]) != '\n') && (ch
!= 0))
694 sprintf(errBuf
, "Could not find macro: %s at line %d, file %s",
695 macroBuf
, (int)(LineNumbers
[CurrentInputIndex
]-1), FileNames
[CurrentInputIndex
]);
701 * 'environment' specifies the name of the macro IFF if we're looking for the end
702 * of an environment, e.g. \end{itemize}. Otherwise it's NULL.
703 * 'parseToBrace' is TRUE if the argument should extend to the next right brace,
704 * e.g. in {\bf an argument} as opposed to \vskip 30pt
707 int ParseArg(TexChunk
*thisArg
, wxList
& children
, char *buffer
, int pos
, char *environment
, bool parseToBrace
, TexChunk
*customMacroArgs
)
710 if (stopRunning
) return pos
;
719 // Consume leading brace or square bracket, but ONLY if not following
720 // a space, because this could be e.g. {\large {\bf thing}} where {\bf thing}
721 // is the argument of \large AS WELL as being a block in its
725 if ((pos > 0) && (buffer[pos-1] != ' ') && buffer[pos] == '{')
729 if ((pos > 0) && (buffer[pos-1] != ' ') && (buffer[pos] == '[' || buffer[pos] == '('))
734 else if ((pos > 1) && (buffer[pos-1] != ' ') && (buffer[pos+1] == '[' || buffer[pos+1] == '('))
742 // If not parsing to brace, just read the next word
743 // (e.g. \vskip 20pt)
746 int ch
= buffer
[pos
];
747 while (!eof
&& ch
!= 13 && ch
!= 32 && ch
!= 10 &&
748 ch
!= 0 && ch
!= '{')
750 BigBuffer
[buf_ptr
] = ch
;
757 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_STRING
);
758 BigBuffer
[buf_ptr
] = 0;
760 chunk
->value
= copystring(BigBuffer
);
761 children
.Append((wxObject
*)chunk
);
768 len
= strlen(buffer
);
771 if (customMacroArgs
) return 0;
773 eof
= read_a_line(buffer
);
775 len
= strlen(buffer
);
776 // Check for verbatim (or toocomplex, which comes to the same thing)
777 if (strncmp(buffer
, "\\begin{verbatim}", 16) == 0 ||
778 strncmp(buffer
, "\\begin{toocomplex}", 18) == 0)
782 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_STRING
);
783 BigBuffer
[buf_ptr
] = 0;
785 chunk
->value
= copystring(BigBuffer
);
786 children
.Append((wxObject
*)chunk
);
791 eof
= read_a_line(buffer
);
792 while (!eof
&& (strncmp(buffer
, "\\end{verbatim}", 14) != 0) &&
793 (strncmp(buffer
, "\\end{toocomplex}", 16) != 0)
796 strcat(BigBuffer
, buffer
);
797 buf_ptr
+= strlen(buffer
);
798 eof
= read_a_line(buffer
);
800 eof
= read_a_line(buffer
);
803 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_MACRO
, VerbatimMacroDef
);
805 chunk
->macroId
= ltVERBATIM
;
806 TexChunk
*arg
= new TexChunk(CHUNK_TYPE_ARG
, VerbatimMacroDef
);
808 arg
->macroId
= ltVERBATIM
;
809 TexChunk
*str
= new TexChunk(CHUNK_TYPE_STRING
);
810 str
->value
= copystring(BigBuffer
);
812 children
.Append((wxObject
*)chunk
);
813 chunk
->children
.Append((wxObject
*)arg
);
814 arg
->children
.Append((wxObject
*)str
);
816 // Also want to include the following newline (is always a newline
817 // after a verbatim): EXCEPT in HTML
818 if (convertMode
!= TEX_HTML
)
820 TexMacroDef
*parDef
= (TexMacroDef
*)MacroDefs
.Get("\\");
821 TexChunk
*parChunk
= new TexChunk(CHUNK_TYPE_MACRO
, parDef
);
822 parChunk
->no_args
= 0;
823 parChunk
->macroId
= ltBACKSLASHCHAR
;
824 children
.Append((wxObject
*)parChunk
);
829 char ch
= buffer
[pos
];
830 // End of optional argument -- pretend it's right brace for simplicity
831 if (thisArg
->optional
&& (ch
== ']'))
837 case '}': // End of argument
841 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_STRING
);
842 BigBuffer
[buf_ptr
] = 0;
844 chunk
->value
= copystring(BigBuffer
);
845 children
.Append((wxObject
*)chunk
);
847 if (ch
== '}') pos
++;
853 if (buf_ptr
> 0) // Finish off the string we've read so far
855 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_STRING
);
856 BigBuffer
[buf_ptr
] = 0;
858 chunk
->value
= copystring(BigBuffer
);
859 children
.Append((wxObject
*)chunk
);
864 // Try matching \end{environment}
865 if (environment
&& FindEndEnvironment(buffer
, &pos
, environment
))
867 // Eliminate newline after an \end{} if possible
868 if (buffer
[pos
] == 13)
871 if (buffer
[pos
] == 10)
877 if (ParseNewCommand(buffer
, &pos
))
880 if (strncmp(buffer
+pos
, "special", 7) == 0)
893 int ch
= buffer
[pos
];
915 else if (ch
== '\\' && buffer
[pos
+1] == '}')
921 else if (ch
== '\\' && buffer
[pos
+1] == '{')
936 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_MACRO
);
938 chunk
->macroId
= ltSPECIAL
;
939 TexMacroDef
*specialDef
= (TexMacroDef
*)MacroDefs
.Get("special");
940 chunk
->def
= specialDef
;
941 TexChunk
*arg
= new TexChunk(CHUNK_TYPE_ARG
, specialDef
);
942 chunk
->children
.Append((wxObject
*)arg
);
944 arg
->macroId
= chunk
->macroId
;
946 // The value in the first argument.
947 TexChunk
*argValue
= new TexChunk(CHUNK_TYPE_STRING
);
948 arg
->children
.Append((wxObject
*)argValue
);
950 argValue
->value
= copystring(wxBuffer
);
952 children
.Append((wxObject
*)chunk
);
954 else if (strncmp(buffer
+pos
, "verb", 4) == 0)
957 if (buffer
[pos
] == '*')
960 // Find the delimiter character
961 int ch
= buffer
[pos
];
963 // Now at start of verbatim text
965 while ((buffer
[pos
] != ch
) && buffer
[pos
] != 0)
967 char *val
= new char[pos
- j
+ 1];
969 for (i
= j
; i
< pos
; i
++)
971 val
[i
-j
] = buffer
[i
];
977 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_MACRO
);
979 chunk
->macroId
= ltVERB
;
980 TexMacroDef
*verbDef
= (TexMacroDef
*)MacroDefs
.Get("verb");
981 chunk
->def
= verbDef
;
982 TexChunk
*arg
= new TexChunk(CHUNK_TYPE_ARG
, verbDef
);
983 chunk
->children
.Append((wxObject
*)arg
);
985 arg
->macroId
= chunk
->macroId
;
987 // The value in the first argument.
988 TexChunk
*argValue
= new TexChunk(CHUNK_TYPE_STRING
);
989 arg
->children
.Append((wxObject
*)argValue
);
991 argValue
->value
= val
;
993 children
.Append((wxObject
*)chunk
);
998 bool tmpParseToBrace
= TRUE
;
999 TexMacroDef
*def
= MatchMacro(buffer
, &pos
, &env
, &tmpParseToBrace
);
1002 CustomMacro
*customMacro
= FindCustomMacro(def
->name
);
1004 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_MACRO
, def
);
1005 chunk
->no_args
= def
->no_args
;
1006 // chunk->name = copystring(def->name);
1007 chunk
->macroId
= def
->macroId
;
1010 children
.Append((wxObject
*)chunk
);
1012 // Eliminate newline after a \begin{} or a \\ if possible
1013 if (env
|| strcmp(def
->name
, "\\") == 0)
1014 if (buffer
[pos
] == 13)
1017 if (buffer
[pos
] == 10)
1021 pos
= ParseMacroBody(def
->name
, chunk
, chunk
->no_args
,
1022 buffer
, pos
, env
, tmpParseToBrace
, customMacroArgs
);
1024 // If custom macro, parse the body substituting the above found args.
1027 if (customMacro
->macroBody
)
1030 // strcpy(macroBuf, "{");
1031 strcpy(macroBuf
, customMacro
->macroBody
);
1032 strcat(macroBuf
, "}");
1033 ParseArg(thisArg
, children
, macroBuf
, 0, NULL
, TRUE
, chunk
);
1036 // delete chunk; // Might delete children
1041 MacroError(buffer
+pos
);
1046 // Parse constructs like {\bf thing} as if they were
1051 if (buffer
[pos
] == '\\')
1055 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_STRING
);
1056 BigBuffer
[buf_ptr
] = 0;
1058 chunk
->value
= copystring(BigBuffer
);
1059 children
.Append((wxObject
*)chunk
);
1064 bool tmpParseToBrace
;
1065 TexMacroDef
*def
= MatchMacro(buffer
, &pos
, &env
, &tmpParseToBrace
);
1068 CustomMacro
*customMacro
= FindCustomMacro(def
->name
);
1070 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_MACRO
, def
);
1071 chunk
->no_args
= def
->no_args
;
1072 // chunk->name = copystring(def->name);
1073 chunk
->macroId
= def
->macroId
;
1075 children
.Append((wxObject
*)chunk
);
1077 pos
= ParseMacroBody(def
->name
, chunk
, chunk
->no_args
,
1078 buffer
, pos
, NULL
, TRUE
, customMacroArgs
);
1080 // If custom macro, parse the body substituting the above found args.
1083 if (customMacro
->macroBody
)
1086 // strcpy(macroBuf, "{");
1087 strcpy(macroBuf
, customMacro
->macroBody
);
1088 strcat(macroBuf
, "}");
1089 ParseArg(thisArg
, children
, macroBuf
, 0, NULL
, TRUE
, chunk
);
1092 // delete chunk; // Might delete children
1097 MacroError(buffer
+pos
);
1103 * If all else fails, we assume that we have
1104 * a pair of braces on their own, so return a `dummy' macro
1105 * definition with just one argument to parse.
1109 SoloBlockDef
= new TexMacroDef(ltSOLO_BLOCK
, "solo block", 1, FALSE
);
1114 TexChunk
*chunk1
= new TexChunk(CHUNK_TYPE_STRING
);
1115 BigBuffer
[buf_ptr
] = 0;
1117 chunk1
->value
= copystring(BigBuffer
);
1118 children
.Append((wxObject
*)chunk1
);
1120 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_MACRO
, SoloBlockDef
);
1121 chunk
->no_args
= SoloBlockDef
->no_args
;
1122 // chunk->name = copystring(SoloBlockDef->name);
1123 chunk
->macroId
= SoloBlockDef
->macroId
;
1124 children
.Append((wxObject
*)chunk
);
1126 TexChunk
*arg
= new TexChunk(CHUNK_TYPE_ARG
, SoloBlockDef
);
1128 chunk
->children
.Append((wxObject
*)arg
);
1129 // arg->name = copystring(SoloBlockDef->name);
1131 arg
->macroId
= chunk
->macroId
;
1133 pos
= ParseArg(arg
, arg
->children
, buffer
, pos
, NULL
, TRUE
, customMacroArgs
);
1141 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_STRING
);
1142 BigBuffer
[buf_ptr
] = 0;
1144 chunk
->value
= copystring(BigBuffer
);
1145 children
.Append((wxObject
*)chunk
);
1150 if (buffer
[pos
] == '$')
1152 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_MACRO
);
1154 // chunk->name = copystring("$$");
1155 chunk
->macroId
= ltSPECIALDOUBLEDOLLAR
;
1156 children
.Append((wxObject
*)chunk
);
1161 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_MACRO
);
1163 // chunk->name = copystring("_$");
1164 chunk
->macroId
= ltSPECIALDOLLAR
;
1165 children
.Append((wxObject
*)chunk
);
1173 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_STRING
);
1174 BigBuffer
[buf_ptr
] = 0;
1176 chunk
->value
= copystring(BigBuffer
);
1177 children
.Append((wxObject
*)chunk
);
1181 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_MACRO
);
1183 // chunk->name = copystring("_~");
1184 chunk
->macroId
= ltSPECIALTILDE
;
1185 children
.Append((wxObject
*)chunk
);
1188 case '#': // Either treat as a special TeX character or as a macro arg
1192 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_STRING
);
1193 BigBuffer
[buf_ptr
] = 0;
1195 chunk
->value
= copystring(BigBuffer
);
1196 children
.Append((wxObject
*)chunk
);
1200 if (!customMacroArgs
)
1202 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_MACRO
);
1204 // chunk->name = copystring("_#");
1205 chunk
->macroId
= ltSPECIALHASH
;
1206 children
.Append((wxObject
*)chunk
);
1210 if (isdigit(buffer
[pos
]))
1212 int n
= buffer
[pos
] - 48;
1214 wxNode
*node
= customMacroArgs
->children
.Nth(n
-1);
1217 TexChunk
*argChunk
= (TexChunk
*)node
->Data();
1218 children
.Append((wxObject
*)new TexChunk(*argChunk
));
1226 // Remove white space before and after the ampersand,
1227 // since this is probably a table column separator with
1228 // some convenient -- but useless -- white space in the text.
1229 while ((buf_ptr
> 0) && ((BigBuffer
[buf_ptr
-1] == ' ') || (BigBuffer
[buf_ptr
-1] == 9)))
1234 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_STRING
);
1235 BigBuffer
[buf_ptr
] = 0;
1237 chunk
->value
= copystring(BigBuffer
);
1238 children
.Append((wxObject
*)chunk
);
1243 while (buffer
[pos
] == ' ' || buffer
[pos
] == 9)
1246 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_MACRO
);
1248 // chunk->name = copystring("_&");
1249 chunk
->macroId
= ltSPECIALAMPERSAND
;
1250 children
.Append((wxObject
*)chunk
);
1253 // Eliminate end-of-line comment
1257 while (ch
!= 10 && ch
!= 13 && ch
!= 0)
1262 if (buffer
[pos
] == 10 || buffer
[pos
] == 13)
1265 if (buffer
[pos
] == 10) pos
++; // Eliminate newline following DOS line feed
1272 BigBuffer
[buf_ptr
] = ' ';
1273 BigBuffer
[buf_ptr
+1] = 0;
1280 BigBuffer
[buf_ptr
] = ch
;
1281 BigBuffer
[buf_ptr
+1] = 0;
1292 * Consume as many arguments as the macro definition specifies
1296 int ParseMacroBody(char *macro_name
, TexChunk
*parent
,
1297 int no_args
, char *buffer
, int pos
,
1298 char *environment
, bool parseToBrace
,
1299 TexChunk
*customMacroArgs
)
1302 if (stopRunning
) return pos
;
1304 // Check for a first optional argument
1305 if (buffer
[pos
] == ' ' && buffer
[pos
+1] == '[')
1307 // Fool following code into thinking that this is definitely
1308 // an optional first argument. (If a space before a non-first argument,
1309 // [ is interpreted as a [, not an optional argument.)
1315 if (buffer
[pos
] == '[')
1321 for (i
= 0; i
< no_args
; i
++)
1324 TexChunk
*arg
= new TexChunk(CHUNK_TYPE_ARG
, parent
->def
);
1326 parent
->children
.Append((wxObject
*)arg
);
1327 // arg->name = copystring(macro_name);
1328 arg
->argn
= maxArgs
;
1329 arg
->macroId
= parent
->macroId
;
1331 // To parse the first arg of a 2 arg \begin{thing}{arg} ... \end{thing}
1332 // have to fool parser into thinking this is a regular kind of block.
1334 if ((no_args
== 2) && (i
== 0))
1337 actualEnv
= environment
;
1339 bool isOptional
= FALSE
;
1341 // Remove the first { of the argument so it doesn't get recognized as { ... }
1342 // EatWhiteSpace(buffer, &pos);
1345 // The reason for these tests is to not consume braces that don't
1346 // belong to this macro.
1347 // E.g. {\bf {\small thing}}
1348 if ((pos
> 0) && (buffer
[pos
-1] != ' ') && buffer
[pos
] == '{')
1351 if ((pos
> 0) && (buffer
[pos
-1] != ' ') && (buffer
[pos
] == '['))
1356 else if ((pos
> 1) && (buffer
[pos
-1] != ' ') && (buffer
[pos
+1] == '['))
1362 arg
->optional
= isOptional
;
1364 pos
= ParseArg(arg
, arg
->children
, buffer
, pos
, actualEnv
, parseToBrace
, customMacroArgs
);
1366 // If we've encountered an OPTIONAL argument, go another time around
1367 // the loop, because we've got more than we thought.
1368 // Hopefully optional args don't occur at the end of a macro use
1369 // or we might miss it.
1370 // Don't increment no of times round loop if the first optional arg
1371 // -- we already did it before the loop.
1372 if (arg
->optional
&& (i
> 0))
1375 parent
->no_args
= maxArgs
;
1377 // Tell each argument how many args there are (useful when processing an arg)
1378 wxNode
*node
= parent
->children
.First();
1381 TexChunk
*chunk
= (TexChunk
*)node
->Data();
1382 chunk
->no_args
= maxArgs
;
1383 node
= node
->Next();
1388 bool TexLoadFile(char *filename
)
1390 stopRunning
= FALSE
;
1391 strcpy(TexFileRoot
, filename
);
1392 StripExtension(TexFileRoot
);
1393 sprintf(TexBibName
, "%s.bb", TexFileRoot
);
1394 sprintf(TexTmpBibName
, "%s.bb1", TexFileRoot
);
1396 TexPathList
.EnsureFileAccessible(filename
);
1399 static char *line_buffer
= new char[600];
1401 static char *line_buffer
= new char[11000];
1404 Inputs
[0] = fopen(filename
, "r");
1406 FileNames
[0] = copystring(filename
);
1409 read_a_line(line_buffer
);
1410 ParseMacroBody("toplevel", TopLevel
, 1, line_buffer
, 0, NULL
, TRUE
);
1411 if (Inputs
[0]) fclose(Inputs
[0]);
1417 TexMacroDef::TexMacroDef(int the_id
, char *the_name
, int n
, bool ig
, bool forbidLevel
)
1419 name
= copystring(the_name
);
1423 forbidden
= forbidLevel
;
1426 TexMacroDef::~TexMacroDef(void)
1428 if (name
) delete[] name
;
1431 TexChunk::TexChunk(int the_type
, TexMacroDef
*the_def
)
1443 TexChunk::TexChunk(TexChunk
& toCopy
)
1446 no_args
= toCopy
.no_args
;
1448 macroId
= toCopy
.macroId
;
1451 // name = copystring(toCopy.name);
1457 value
= copystring(toCopy
.value
);
1461 optional
= toCopy
.optional
;
1462 wxNode
*node
= toCopy
.children
.First();
1465 TexChunk
*child
= (TexChunk
*)node
->Data();
1466 children
.Append((wxObject
*)new TexChunk(*child
));
1467 node
= node
->Next();
1471 TexChunk::~TexChunk(void)
1473 // if (name) delete[] name;
1474 if (value
) delete[] value
;
1475 wxNode
*node
= children
.First();
1478 TexChunk
*child
= (TexChunk
*)node
->Data();
1480 wxNode
*next
= node
->Next();
1486 bool IsArgOptional(void) // Is this argument an optional argument?
1488 return isArgOptional
;
1491 int GetNoArgs(void) // Number of args for this macro
1496 /* Gets the text of a chunk on request (must be for small arguments
1501 void GetArgData1(TexChunk
*chunk
)
1503 switch (chunk
->type
)
1505 case CHUNK_TYPE_MACRO
:
1507 TexMacroDef
*def
= chunk
->def
;
1508 if (def
&& def
->ignore
)
1511 if (def
&& (strcmp(def
->name
, "solo block") != 0))
1513 strcat(currentArgData
, "\\");
1514 strcat(currentArgData
, def
->name
);
1517 wxNode
*node
= chunk
->children
.First();
1520 TexChunk
*child_chunk
= (TexChunk
*)node
->Data();
1521 strcat(currentArgData
, "{");
1522 GetArgData1(child_chunk
);
1523 strcat(currentArgData
, "}");
1524 node
= node
->Next();
1528 case CHUNK_TYPE_ARG
:
1530 wxNode
*node
= chunk
->children
.First();
1533 TexChunk
*child_chunk
= (TexChunk
*)node
->Data();
1534 GetArgData1(child_chunk
);
1535 node
= node
->Next();
1539 case CHUNK_TYPE_STRING
:
1542 strcat(currentArgData
, chunk
->value
);
1548 char *GetArgData(TexChunk
*chunk
)
1550 currentArgData
[0] = 0;
1551 GetArgData1(currentArgument
);
1552 haveArgData
= FALSE
;
1553 return currentArgData
;
1556 char *GetArgData(void)
1560 currentArgData
[0] = 0;
1561 GetArgData1(currentArgument
);
1563 return currentArgData
;
1566 TexChunk
*GetArgChunk(void)
1568 return currentArgument
;
1571 TexChunk
*GetNextChunk(void) // Look ahead to the next chunk
1576 TexChunk
*GetTopLevelChunk(void)
1581 int GetCurrentColumn(void)
1583 return currentColumn
;
1587 * Traverses document calling functions to allow the client to
1588 * write out the appropriate stuff
1592 void TraverseFromChunk(TexChunk
*chunk
, wxNode
*thisNode
, bool childrenOnly
)
1595 if (stopRunning
) return;
1597 switch (chunk
->type
)
1599 case CHUNK_TYPE_MACRO
:
1601 TexMacroDef
*def
= chunk
->def
;
1602 if (def
&& def
->ignore
)
1606 OnMacro(chunk
->macroId
, chunk
->no_args
, TRUE
);
1608 wxNode
*node
= chunk
->children
.First();
1611 TexChunk
*child_chunk
= (TexChunk
*)node
->Data();
1612 TraverseFromChunk(child_chunk
, node
);
1613 node
= node
->Next();
1616 if (thisNode
&& thisNode
->Next()) nextChunk
= (TexChunk
*)thisNode
->Next()->Data();
1619 OnMacro(chunk
->macroId
, chunk
->no_args
, FALSE
);
1622 case CHUNK_TYPE_ARG
:
1624 currentArgument
= chunk
;
1626 isArgOptional
= chunk
->optional
;
1627 noArgs
= chunk
->no_args
;
1629 // If OnArgument returns FALSE, don't output.
1631 if (childrenOnly
|| OnArgument(chunk
->macroId
, chunk
->argn
, TRUE
))
1633 wxNode
*node
= chunk
->children
.First();
1636 TexChunk
*child_chunk
= (TexChunk
*)node
->Data();
1637 TraverseFromChunk(child_chunk
, node
);
1638 node
= node
->Next();
1642 currentArgument
= chunk
;
1644 if (thisNode
&& thisNode
->Next()) nextChunk
= (TexChunk
*)thisNode
->Next()->Data();
1646 isArgOptional
= chunk
->optional
;
1647 noArgs
= chunk
->no_args
;
1650 (void)OnArgument(chunk
->macroId
, chunk
->argn
, FALSE
);
1653 case CHUNK_TYPE_STRING
:
1655 extern int issuedNewParagraph
;
1656 extern int forbidResetPar
;
1657 if (chunk
->value
&& (forbidResetPar
== 0))
1659 // If non-whitespace text, we no longer have a new paragraph.
1660 if (issuedNewParagraph
&& !((chunk
->value
[0] == 10 || chunk
->value
[0] == 13 || chunk
->value
[0] == 32)
1661 && chunk
->value
[1] == 0))
1662 issuedNewParagraph
= FALSE
;
1663 TexOutput(chunk
->value
, TRUE
);
1670 void TraverseDocument(void)
1672 TraverseFromChunk(TopLevel
, NULL
);
1675 void SetCurrentOutput(FILE *fd
)
1677 CurrentOutput1
= fd
;
1678 CurrentOutput2
= NULL
;
1681 void SetCurrentOutputs(FILE *fd1
, FILE *fd2
)
1683 CurrentOutput1
= fd1
;
1684 CurrentOutput2
= fd2
;
1687 void AddMacroDef(int the_id
, char *name
, int n
, bool ignore
, bool forbid
)
1689 MacroDefs
.Put(name
, new TexMacroDef(the_id
, name
, n
, ignore
, forbid
));
1692 void TexInitialize(int bufSize
)
1694 InitialiseColourTable();
1696 TexPathList
.AddEnvList("TEXINPUT");
1699 TexPathList
.AddEnvList("TEXINPUTS");
1702 for (i
= 0; i
< 15; i
++)
1706 FileNames
[i
] = NULL
;
1709 IgnorableInputFiles
.Add("psbox.tex");
1710 BigBuffer
= new char[(bufSize
*1000)];
1711 currentArgData
= new char[2000];
1712 TexFileRoot
= new char[300];
1713 TexBibName
= new char[300];
1714 TexTmpBibName
= new char[300];
1715 AddMacroDef(ltTOPLEVEL
, "toplevel", 1);
1716 TopLevel
= new TexChunk(CHUNK_TYPE_MACRO
);
1717 // TopLevel->name = copystring("toplevel");
1718 TopLevel
->macroId
= ltTOPLEVEL
;
1719 TopLevel
->no_args
= 1;
1720 VerbatimMacroDef
= (TexMacroDef
*)MacroDefs
.Get("verbatim");
1723 void TexCleanUp(void)
1726 for (i
= 0; i
< 15; i
++)
1732 subsubsectionNo
= 0;
1735 CurrentOutput1
= NULL
;
1736 CurrentOutput2
= NULL
;
1737 CurrentInputIndex
= 0;
1738 haveArgData
= FALSE
;
1743 TopLevel
= new TexChunk(CHUNK_TYPE_MACRO
);
1744 // TopLevel->name = copystring("toplevel");
1745 TopLevel
->macroId
= ltTOPLEVEL
;
1746 TopLevel
->no_args
= 1;
1748 DocumentTitle
= NULL
;
1749 DocumentAuthor
= NULL
;
1750 DocumentDate
= NULL
;
1751 DocumentStyle
= LATEX_REPORT
;
1752 MinorDocumentStyle
= 0;
1753 BibliographyStyleString
= copystring("plain");
1754 DocumentStyleString
= copystring("report");
1755 MinorDocumentStyleString
= NULL
;
1756 /* Don't want to remove custom macros after each pass.
1758 wxNode *node = CustomMacroList.First();
1761 CustomMacro *macro = (CustomMacro *)node->Data();
1764 node = CustomMacroList.First();
1767 TexReferences
.BeginFind();
1768 wxNode
*node
= TexReferences
.Next();
1771 TexRef
*ref
= (TexRef
*)node
->Data();
1773 node
= TexReferences
.Next();
1775 TexReferences
.Clear();
1777 node
= BibList
.First();
1780 BibEntry
*entry
= (BibEntry
*)node
->Data();
1783 node
= BibList
.First();
1785 CitationList
.Clear();
1786 ResetTopicCounter();
1789 // There is likely to be one set of macros used by all utilities.
1790 void DefineDefaultMacros(void)
1792 // Put names which subsume other names at the TOP
1793 // so they get recognized first
1795 AddMacroDef(ltACCENT_GRAVE
, "`", 1);
1796 AddMacroDef(ltACCENT_ACUTE
, "'", 1);
1797 AddMacroDef(ltACCENT_CARET
, "^", 1);
1798 AddMacroDef(ltACCENT_UMLAUT
, "\"", 1);
1799 AddMacroDef(ltACCENT_TILDE
, "~", 1);
1800 AddMacroDef(ltACCENT_DOT
, ".", 1);
1801 AddMacroDef(ltACCENT_CADILLA
, "c", 1);
1802 AddMacroDef(ltSMALLSPACE1
, ",", 0);
1803 AddMacroDef(ltSMALLSPACE2
, ";", 0);
1805 AddMacroDef(ltABSTRACT
, "abstract", 1);
1806 AddMacroDef(ltADDCONTENTSLINE
, "addcontentsline", 3);
1807 AddMacroDef(ltADDTOCOUNTER
, "addtocounter", 2);
1808 AddMacroDef(ltALEPH
, "aleph", 0);
1809 AddMacroDef(ltALPHA
, "alpha", 0);
1810 AddMacroDef(ltALPH1
, "alph", 1);
1811 AddMacroDef(ltALPH2
, "Alph", 1);
1812 AddMacroDef(ltANGLE
, "angle", 0);
1813 AddMacroDef(ltAPPENDIX
, "appendix", 0);
1814 AddMacroDef(ltAPPROX
, "approx", 0);
1815 AddMacroDef(ltARABIC
, "arabic", 1);
1816 AddMacroDef(ltARRAY
, "array", 1);
1817 AddMacroDef(ltAST
, "ast", 0);
1818 AddMacroDef(ltASYMP
, "asymp", 0);
1819 AddMacroDef(ltAUTHOR
, "author", 1);
1821 AddMacroDef(ltBACKGROUNDCOLOUR
, "backgroundcolour", 1);
1822 AddMacroDef(ltBACKGROUNDIMAGE
, "backgroundimage", 1);
1823 AddMacroDef(ltBACKGROUND
, "background", 1);
1824 AddMacroDef(ltBACKSLASHRAW
, "backslashraw", 0);
1825 AddMacroDef(ltBACKSLASH
, "backslash", 0);
1826 AddMacroDef(ltBASELINESKIP
, "baselineskip", 1);
1827 AddMacroDef(ltBCOL
, "bcol", 2);
1828 AddMacroDef(ltBETA
, "beta", 0);
1829 AddMacroDef(ltBFSERIES
, "bfseries", 1);
1830 AddMacroDef(ltBF
, "bf", 1);
1831 AddMacroDef(ltBIBITEM
, "bibitem", 2); // For convenience, bibitem has 2 args: label and item.
1832 // The Latex syntax permits writing as 2 args.
1833 AddMacroDef(ltBIBLIOGRAPHYSTYLE
, "bibliographystyle", 1);
1834 AddMacroDef(ltBIBLIOGRAPHY
, "bibliography", 1);
1835 AddMacroDef(ltBIGTRIANGLEDOWN
, "bigtriangledown", 0);
1836 AddMacroDef(ltBOT
, "bot", 0);
1837 AddMacroDef(ltBOXIT
, "boxit", 1);
1838 AddMacroDef(ltBOX
, "box", 0);
1839 AddMacroDef(ltBRCLEAR
, "brclear", 0);
1840 AddMacroDef(ltBULLET
, "bullet", 0);
1842 AddMacroDef(ltCAPTIONSTAR
, "caption*", 1);
1843 AddMacroDef(ltCAPTION
, "caption", 1);
1844 AddMacroDef(ltCAP
, "cap", 0);
1845 AddMacroDef(ltCDOTS
, "cdots", 0);
1846 AddMacroDef(ltCDOT
, "cdot", 0);
1847 AddMacroDef(ltCENTERLINE
, "centerline", 1);
1848 AddMacroDef(ltCENTERING
, "centering", 0);
1849 AddMacroDef(ltCENTER
, "center", 1);
1850 AddMacroDef(ltCEXTRACT
, "cextract", 0);
1851 AddMacroDef(ltCHAPTERHEADING
, "chapterheading", 1);
1852 AddMacroDef(ltCHAPTERSTAR
, "chapter*", 1);
1853 AddMacroDef(ltCHAPTER
, "chapter", 1);
1854 AddMacroDef(ltCHI
, "chi", 0);
1855 AddMacroDef(ltCINSERT
, "cinsert", 0);
1856 AddMacroDef(ltCIRC
, "circ", 0);
1857 AddMacroDef(ltCITE
, "cite", 1);
1858 AddMacroDef(ltCLASS
, "class", 1);
1859 AddMacroDef(ltCLEARDOUBLEPAGE
, "cleardoublepage", 0);
1860 AddMacroDef(ltCLEARPAGE
, "clearpage", 0);
1861 AddMacroDef(ltCLINE
, "cline", 1);
1862 AddMacroDef(ltCLIPSFUNC
, "clipsfunc", 3);
1863 AddMacroDef(ltCLUBSUIT
, "clubsuit", 0);
1864 AddMacroDef(ltCOLUMNSEP
, "columnsep", 1);
1865 AddMacroDef(ltCOMMENT
, "comment", 1, TRUE
);
1866 AddMacroDef(ltCONG
, "cong", 0);
1867 AddMacroDef(ltCOPYRIGHT
, "copyright", 0);
1868 AddMacroDef(ltCPARAM
, "cparam", 2);
1869 AddMacroDef(ltCHEAD
, "chead", 1);
1870 AddMacroDef(ltCFOOT
, "cfoot", 1);
1871 AddMacroDef(ltCUP
, "cup", 0);
1873 AddMacroDef(ltDASHV
, "dashv", 0);
1874 AddMacroDef(ltDATE
, "date", 1);
1875 AddMacroDef(ltDELTA
, "delta", 0);
1876 AddMacroDef(ltCAP_DELTA
, "Delta", 0);
1877 AddMacroDef(ltDEFINECOLOUR
, "definecolour", 4);
1878 AddMacroDef(ltDEFINECOLOR
, "definecolor", 4);
1879 AddMacroDef(ltDESCRIPTION
, "description", 1);
1880 AddMacroDef(ltDESTRUCT
, "destruct", 1);
1881 AddMacroDef(ltDIAMOND2
, "diamond2", 0);
1882 AddMacroDef(ltDIAMOND
, "diamond", 0);
1883 AddMacroDef(ltDIV
, "div", 0);
1884 AddMacroDef(ltDOCUMENTCLASS
, "documentclass", 1);
1885 AddMacroDef(ltDOCUMENTSTYLE
, "documentstyle", 1);
1886 AddMacroDef(ltDOCUMENT
, "document", 1);
1887 AddMacroDef(ltDOUBLESPACE
, "doublespace", 1);
1888 AddMacroDef(ltDOTEQ
, "doteq", 0);
1889 AddMacroDef(ltDOWNARROW
, "downarrow", 0);
1890 AddMacroDef(ltDOWNARROW2
, "Downarrow", 0);
1892 AddMacroDef(ltEMPTYSET
, "emptyset", 0);
1893 AddMacroDef(ltEMPH
, "emph", 1);
1894 AddMacroDef(ltEM
, "em", 1);
1895 AddMacroDef(ltENUMERATE
, "enumerate", 1);
1896 AddMacroDef(ltEPSILON
, "epsilon", 0);
1897 AddMacroDef(ltEQUATION
, "equation", 1);
1898 AddMacroDef(ltEQUIV
, "equiv", 0);
1899 AddMacroDef(ltETA
, "eta", 0);
1900 AddMacroDef(ltEVENSIDEMARGIN
, "evensidemargin", 1);
1901 AddMacroDef(ltEXISTS
, "exists", 0);
1903 AddMacroDef(ltFBOX
, "fbox", 1);
1904 AddMacroDef(ltFCOL
, "fcol", 2);
1905 AddMacroDef(ltFIGURE
, "figure", 1);
1906 AddMacroDef(ltFIGURESTAR
, "figure*", 1);
1907 AddMacroDef(ltFLUSHLEFT
, "flushleft", 1);
1908 AddMacroDef(ltFLUSHRIGHT
, "flushright", 1);
1909 AddMacroDef(ltFOLLOWEDLINKCOLOUR
, "followedlinkcolour", 1);
1910 AddMacroDef(ltFOOTHEIGHT
, "footheight", 1);
1911 AddMacroDef(ltFOOTNOTEPOPUP
, "footnotepopup", 2);
1912 AddMacroDef(ltFOOTNOTE
, "footnote", 1);
1913 AddMacroDef(ltFOOTSKIP
, "footskip", 1);
1914 AddMacroDef(ltFORALL
, "forall", 0);
1915 AddMacroDef(ltFRAMEBOX
, "framebox", 1);
1916 AddMacroDef(ltFROWN
, "frown", 0);
1917 AddMacroDef(ltFUNCTIONSECTION
, "functionsection", 1);
1918 AddMacroDef(ltFUNC
, "func", 3);
1919 AddMacroDef(ltFOOTNOTESIZE
, "footnotesize", 0);
1920 AddMacroDef(ltFANCYPLAIN
, "fancyplain", 2);
1922 AddMacroDef(ltGAMMA
, "gamma", 0);
1923 AddMacroDef(ltCAP_GAMMA
, "Gamma", 0);
1924 AddMacroDef(ltGEQ
, "geq", 0);
1925 AddMacroDef(ltGE
, "ge", 0);
1926 AddMacroDef(ltGG
, "gg", 0);
1927 AddMacroDef(ltGLOSSARY
, "glossary", 1);
1928 AddMacroDef(ltGLOSS
, "gloss", 1);
1930 AddMacroDef(ltHEADHEIGHT
, "headheight", 1);
1931 AddMacroDef(ltHEARTSUIT
, "heartsuit", 0);
1932 AddMacroDef(ltHELPGLOSSARY
, "helpglossary", 1);
1933 AddMacroDef(ltHELPIGNORE
, "helpignore", 1, TRUE
);
1934 AddMacroDef(ltHELPONLY
, "helponly", 1);
1935 AddMacroDef(ltHELPINPUT
, "helpinput", 1);
1936 AddMacroDef(ltHELPFONTFAMILY
, "helpfontfamily", 1);
1937 AddMacroDef(ltHELPFONTSIZE
, "helpfontsize", 1);
1938 AddMacroDef(ltHELPREFN
, "helprefn", 2);
1939 AddMacroDef(ltHELPREF
, "helpref", 2);
1940 AddMacroDef(ltHFILL
, "hfill", 0);
1941 AddMacroDef(ltHLINE
, "hline", 0);
1942 AddMacroDef(ltHRULE
, "hrule", 0);
1943 AddMacroDef(ltHSPACESTAR
, "hspace*", 1);
1944 AddMacroDef(ltHSPACE
, "hspace", 1);
1945 AddMacroDef(ltHSKIPSTAR
, "hskip*", 1);
1946 AddMacroDef(ltHSKIP
, "hskip", 1);
1947 AddMacroDef(lthuge
, "huge", 1);
1948 AddMacroDef(ltHuge
, "Huge", 1);
1949 AddMacroDef(ltHUGE
, "HUGE", 1);
1950 AddMacroDef(ltHTMLIGNORE
, "htmlignore", 1);
1951 AddMacroDef(ltHTMLONLY
, "htmlonly", 1);
1953 AddMacroDef(ltIM
, "im", 0);
1954 AddMacroDef(ltINCLUDEONLY
, "includeonly", 1);
1955 AddMacroDef(ltINCLUDE
, "include", 1);
1956 AddMacroDef(ltINDENTED
, "indented", 2);
1957 AddMacroDef(ltINDEX
, "index", 1);
1958 AddMacroDef(ltINPUT
, "input", 1, TRUE
);
1959 AddMacroDef(ltIOTA
, "iota", 0);
1960 AddMacroDef(ltITEMIZE
, "itemize", 1);
1961 AddMacroDef(ltITEM
, "item", 0);
1962 AddMacroDef(ltIMAGEMAP
, "imagemap", 3);
1963 AddMacroDef(ltIMAGEL
, "imagel", 2);
1964 AddMacroDef(ltIMAGER
, "imager", 2);
1965 AddMacroDef(ltIMAGE
, "image", 2);
1966 AddMacroDef(ltIN
, "in", 0);
1967 AddMacroDef(ltINFTY
, "infty", 0);
1968 AddMacroDef(ltITSHAPE
, "itshape", 1);
1969 AddMacroDef(ltIT
, "it", 1);
1970 AddMacroDef(ltITEMSEP
, "itemsep", 1);
1971 AddMacroDef(ltINSERTATLEVEL
, "insertatlevel", 2);
1973 AddMacroDef(ltKAPPA
, "kappa", 0);
1974 AddMacroDef(ltKILL
, "kill", 0);
1976 AddMacroDef(ltLABEL
, "label", 1);
1977 AddMacroDef(ltLAMBDA
, "lambda", 0);
1978 AddMacroDef(ltCAP_LAMBDA
, "Lambda", 0);
1979 AddMacroDef(ltlarge
, "large", 1);
1980 AddMacroDef(ltLarge
, "Large", 1);
1981 AddMacroDef(ltLARGE
, "LARGE", 1);
1982 AddMacroDef(ltLATEXIGNORE
, "latexignore", 1);
1983 AddMacroDef(ltLATEXONLY
, "latexonly", 1);
1984 AddMacroDef(ltLATEX
, "LaTeX", 0);
1985 AddMacroDef(ltLBOX
, "lbox", 1);
1986 AddMacroDef(ltLBRACERAW
, "lbraceraw", 0);
1987 AddMacroDef(ltLDOTS
, "ldots", 0);
1988 AddMacroDef(ltLEQ
, "leq", 0);
1989 AddMacroDef(ltLE
, "le", 0);
1990 AddMacroDef(ltLEFTARROW
, "leftarrow", 0);
1991 AddMacroDef(ltLEFTRIGHTARROW
, "leftrightarrow", 0);
1992 AddMacroDef(ltLEFTARROW2
, "Leftarrow", 0);
1993 AddMacroDef(ltLEFTRIGHTARROW2
, "Leftrightarrow", 0);
1994 AddMacroDef(ltLINEBREAK
, "linebreak", 0);
1995 AddMacroDef(ltLINKCOLOUR
, "linkcolour", 1);
1996 AddMacroDef(ltLISTOFFIGURES
, "listoffigures", 0);
1997 AddMacroDef(ltLISTOFTABLES
, "listoftables", 0);
1998 AddMacroDef(ltLHEAD
, "lhead", 1);
1999 AddMacroDef(ltLFOOT
, "lfoot", 1);
2000 AddMacroDef(ltLOWERCASE
, "lowercase", 1);
2001 AddMacroDef(ltLL
, "ll", 0);
2003 AddMacroDef(ltMAKEGLOSSARY
, "makeglossary", 0);
2004 AddMacroDef(ltMAKEINDEX
, "makeindex", 0);
2005 AddMacroDef(ltMAKETITLE
, "maketitle", 0);
2006 AddMacroDef(ltMARKRIGHT
, "markright", 1);
2007 AddMacroDef(ltMARKBOTH
, "markboth", 2);
2008 AddMacroDef(ltMARGINPARWIDTH
, "marginparwidth", 1);
2009 AddMacroDef(ltMARGINPARSEP
, "marginparsep", 1);
2010 AddMacroDef(ltMARGINPARODD
, "marginparodd", 1);
2011 AddMacroDef(ltMARGINPAREVEN
, "marginpareven", 1);
2012 AddMacroDef(ltMARGINPAR
, "marginpar", 1);
2013 AddMacroDef(ltMBOX
, "mbox", 1);
2014 AddMacroDef(ltMDSERIES
, "mdseries", 1);
2015 AddMacroDef(ltMEMBERSECTION
, "membersection", 1);
2016 AddMacroDef(ltMEMBER
, "member", 2);
2017 AddMacroDef(ltMID
, "mid", 0);
2018 AddMacroDef(ltMODELS
, "models", 0);
2019 AddMacroDef(ltMP
, "mp", 0);
2020 AddMacroDef(ltMULTICOLUMN
, "multicolumn", 3);
2021 AddMacroDef(ltMU
, "mu", 0);
2023 AddMacroDef(ltNABLA
, "nabla", 0);
2024 AddMacroDef(ltNEG
, "neg", 0);
2025 AddMacroDef(ltNEQ
, "neq", 0);
2026 AddMacroDef(ltNEWCOUNTER
, "newcounter", 1, FALSE
, FORBID_ABSOLUTELY
);
2027 AddMacroDef(ltNEWLINE
, "newline", 0);
2028 AddMacroDef(ltNEWPAGE
, "newpage", 0);
2029 AddMacroDef(ltNI
, "ni", 0);
2030 AddMacroDef(ltNOCITE
, "nocite", 1);
2031 AddMacroDef(ltNOINDENT
, "noindent", 0);
2032 AddMacroDef(ltNOLINEBREAK
, "nolinebreak", 0);
2033 AddMacroDef(ltNOPAGEBREAK
, "nopagebreak", 0);
2034 AddMacroDef(ltNORMALSIZE
, "normalsize", 1);
2035 AddMacroDef(ltNORMALBOX
, "normalbox", 1);
2036 AddMacroDef(ltNORMALBOXD
, "normalboxd", 1);
2037 AddMacroDef(ltNOTEQ
, "noteq", 0);
2038 AddMacroDef(ltNOTIN
, "notin", 0);
2039 AddMacroDef(ltNOTSUBSET
, "notsubset", 0);
2040 AddMacroDef(ltNU
, "nu", 0);
2042 AddMacroDef(ltODDSIDEMARGIN
, "oddsidemargin", 1);
2043 AddMacroDef(ltOMEGA
, "omega", 0);
2044 AddMacroDef(ltCAP_OMEGA
, "Omega", 0);
2045 AddMacroDef(ltONECOLUMN
, "onecolumn", 0);
2046 AddMacroDef(ltOPLUS
, "oplus", 0);
2047 AddMacroDef(ltOSLASH
, "oslash", 0);
2048 AddMacroDef(ltOTIMES
, "otimes", 0);
2050 AddMacroDef(ltPAGEBREAK
, "pagebreak", 0);
2051 AddMacroDef(ltPAGEREF
, "pageref", 1);
2052 AddMacroDef(ltPAGESTYLE
, "pagestyle", 1);
2053 AddMacroDef(ltPAGENUMBERING
, "pagenumbering", 1);
2054 AddMacroDef(ltPARAGRAPHSTAR
, "paragraph*", 1);
2055 AddMacroDef(ltPARAGRAPH
, "paragraph", 1);
2056 AddMacroDef(ltPARALLEL
, "parallel", 0);
2057 AddMacroDef(ltPARAM
, "param", 2);
2058 AddMacroDef(ltPARINDENT
, "parindent", 1);
2059 AddMacroDef(ltPARSKIP
, "parskip", 1);
2060 AddMacroDef(ltPARTIAL
, "partial", 0);
2061 AddMacroDef(ltPARTSTAR
, "part*", 1);
2062 AddMacroDef(ltPART
, "part", 1);
2063 AddMacroDef(ltPAR
, "par", 0);
2064 AddMacroDef(ltPERP
, "perp", 0);
2065 AddMacroDef(ltPHI
, "phi", 0);
2066 AddMacroDef(ltCAP_PHI
, "Phi", 0);
2067 AddMacroDef(ltPFUNC
, "pfunc", 3);
2068 AddMacroDef(ltPICTURE
, "picture", 1);
2069 AddMacroDef(ltPI
, "pi", 0);
2070 AddMacroDef(ltCAP_PI
, "Pi", 0);
2071 AddMacroDef(ltPM
, "pm", 0);
2072 AddMacroDef(ltPOPREFONLY
, "poprefonly", 1);
2073 AddMacroDef(ltPOPREF
, "popref", 2);
2074 AddMacroDef(ltPOUNDS
, "pounds", 0);
2075 AddMacroDef(ltPREC
, "prec", 0);
2076 AddMacroDef(ltPRECEQ
, "preceq", 0);
2077 AddMacroDef(ltPRINTINDEX
, "printindex", 0);
2078 AddMacroDef(ltPROPTO
, "propto", 0);
2079 AddMacroDef(ltPSBOXTO
, "psboxto", 1, FALSE
, FORBID_ABSOLUTELY
);
2080 AddMacroDef(ltPSBOX
, "psbox", 1, FALSE
, FORBID_ABSOLUTELY
);
2081 AddMacroDef(ltPSI
, "psi", 0);
2082 AddMacroDef(ltCAP_PSI
, "Psi", 0);
2084 AddMacroDef(ltQUOTE
, "quote", 1);
2085 AddMacroDef(ltQUOTATION
, "quotation", 1);
2087 AddMacroDef(ltRAGGEDBOTTOM
, "raggedbottom", 0);
2088 AddMacroDef(ltRAGGEDLEFT
, "raggedleft", 0);
2089 AddMacroDef(ltRAGGEDRIGHT
, "raggedright", 0);
2090 AddMacroDef(ltRBRACERAW
, "rbraceraw", 0);
2091 AddMacroDef(ltREF
, "ref", 1);
2092 AddMacroDef(ltREGISTERED
, "registered", 0);
2093 AddMacroDef(ltRE
, "we", 0);
2094 AddMacroDef(ltRHO
, "rho", 0);
2095 AddMacroDef(ltRIGHTARROW
, "rightarrow", 0);
2096 AddMacroDef(ltRIGHTARROW2
, "rightarrow2", 0);
2097 AddMacroDef(ltRMFAMILY
, "rmfamily", 1);
2098 AddMacroDef(ltRM
, "rm", 1);
2099 AddMacroDef(ltROMAN
, "roman", 1);
2100 AddMacroDef(ltROMAN2
, "Roman", 1);
2101 // AddMacroDef(lt"row", 1);
2102 AddMacroDef(ltRTFSP
, "rtfsp", 0);
2103 AddMacroDef(ltRTFIGNORE
, "rtfignore", 1);
2104 AddMacroDef(ltRTFONLY
, "rtfonly", 1);
2105 AddMacroDef(ltRULEDROW
, "ruledrow", 1);
2106 AddMacroDef(ltDRULED
, "druled", 1);
2107 AddMacroDef(ltRULE
, "rule", 2);
2108 AddMacroDef(ltRHEAD
, "rhead", 1);
2109 AddMacroDef(ltRFOOT
, "rfoot", 1);
2110 AddMacroDef(ltROW
, "row", 1);
2112 AddMacroDef(ltSCSHAPE
, "scshape", 1);
2113 AddMacroDef(ltSC
, "sc", 1);
2114 AddMacroDef(ltSECTIONHEADING
, "sectionheading", 1);
2115 AddMacroDef(ltSECTIONSTAR
, "section*", 1);
2116 AddMacroDef(ltSECTION
, "section", 1);
2117 AddMacroDef(ltSETCOUNTER
, "setcounter", 2);
2118 AddMacroDef(ltSFFAMILY
, "sffamily", 1);
2119 AddMacroDef(ltSF
, "sf", 1);
2120 AddMacroDef(ltSHARP
, "sharp", 0);
2121 AddMacroDef(ltSHORTCITE
, "shortcite", 1);
2122 AddMacroDef(ltSIGMA
, "sigma", 0);
2123 AddMacroDef(ltCAP_SIGMA
, "Sigma", 0);
2124 AddMacroDef(ltSIM
, "sim", 0);
2125 AddMacroDef(ltSIMEQ
, "simeq", 0);
2126 AddMacroDef(ltSINGLESPACE
, "singlespace", 1);
2127 AddMacroDef(ltSIZEDBOX
, "sizedbox", 2);
2128 AddMacroDef(ltSIZEDBOXD
, "sizedboxd", 2);
2129 AddMacroDef(ltSLOPPYPAR
, "sloppypar", 1);
2130 AddMacroDef(ltSLOPPY
, "sloppy", 0);
2131 AddMacroDef(ltSLSHAPE
, "slshape", 1);
2132 AddMacroDef(ltSL
, "sl", 1);
2133 AddMacroDef(ltSMALL
, "small", 1);
2134 AddMacroDef(ltSMILE
, "smile", 0);
2135 AddMacroDef(ltSS
, "ss", 0);
2136 AddMacroDef(ltSTAR
, "star", 0);
2137 AddMacroDef(ltSUBITEM
, "subitem", 0);
2138 AddMacroDef(ltSUBPARAGRAPHSTAR
, "subparagraph*", 1);
2139 AddMacroDef(ltSUBPARAGRAPH
, "subparagraph", 1);
2140 AddMacroDef(ltSPECIAL
, "special", 1);
2141 AddMacroDef(ltSUBSECTIONSTAR
, "subsection*", 1);
2142 AddMacroDef(ltSUBSECTION
, "subsection", 1);
2143 AddMacroDef(ltSUBSETEQ
, "subseteq", 0);
2144 AddMacroDef(ltSUBSET
, "subset", 0);
2145 AddMacroDef(ltSUCC
, "succ", 0);
2146 AddMacroDef(ltSUCCEQ
, "succeq", 0);
2147 AddMacroDef(ltSUPSETEQ
, "supseteq", 0);
2148 AddMacroDef(ltSUPSET
, "supset", 0);
2149 AddMacroDef(ltSUBSUBSECTIONSTAR
,"subsubsection*", 1);
2150 AddMacroDef(ltSUBSUBSECTION
, "subsubsection", 1);
2151 AddMacroDef(ltSUPERTABULAR
, "supertabular", 2, FALSE
);
2152 AddMacroDef(ltSURD
, "surd", 0);
2153 AddMacroDef(ltSCRIPTSIZE
, "scriptsize", 1);
2154 AddMacroDef(ltSETHEADER
, "setheader", 6);
2155 AddMacroDef(ltSETFOOTER
, "setfooter", 6);
2156 AddMacroDef(ltSETHOTSPOTCOLOUR
, "sethotspotcolour", 1);
2157 AddMacroDef(ltSETHOTSPOTCOLOR
, "sethotspotcolor", 1);
2158 AddMacroDef(ltSETHOTSPOTUNDERLINE
, "sethotspotunderline", 1);
2159 AddMacroDef(ltSETTRANSPARENCY
, "settransparency", 1);
2160 AddMacroDef(ltSPADESUIT
, "spadesuit", 0);
2162 AddMacroDef(ltTABBING
, "tabbing", 2);
2163 AddMacroDef(ltTABLEOFCONTENTS
, "tableofcontents", 0);
2164 AddMacroDef(ltTABLE
, "table", 1);
2165 AddMacroDef(ltTABULAR
, "tabular", 2, FALSE
);
2166 AddMacroDef(ltTAB
, "tab", 0);
2167 AddMacroDef(ltTAU
, "tau", 0);
2168 AddMacroDef(ltTEXTRM
, "textrm", 1);
2169 AddMacroDef(ltTEXTSF
, "textsf", 1);
2170 AddMacroDef(ltTEXTTT
, "texttt", 1);
2171 AddMacroDef(ltTEXTBF
, "textbf", 1);
2172 AddMacroDef(ltTEXTIT
, "textit", 1);
2173 AddMacroDef(ltTEXTSL
, "textsl", 1);
2174 AddMacroDef(ltTEXTSC
, "textsc", 1);
2175 AddMacroDef(ltTEXTWIDTH
, "textwidth", 1);
2176 AddMacroDef(ltTEXTHEIGHT
, "textheight", 1);
2177 AddMacroDef(ltTEXTCOLOUR
, "textcolour", 1);
2178 AddMacroDef(ltTEX
, "TeX", 0);
2179 AddMacroDef(ltTHEBIBLIOGRAPHY
, "thebibliography", 2);
2180 AddMacroDef(ltTHETA
, "theta", 0);
2181 AddMacroDef(ltTIMES
, "times", 0);
2182 AddMacroDef(ltCAP_THETA
, "Theta", 0);
2183 AddMacroDef(ltTITLEPAGE
, "titlepage", 1);
2184 AddMacroDef(ltTITLE
, "title", 1);
2185 AddMacroDef(ltTINY
, "tiny", 1);
2186 AddMacroDef(ltTODAY
, "today", 0);
2187 AddMacroDef(ltTOPMARGIN
, "topmargin", 1);
2188 AddMacroDef(ltTOPSKIP
, "topskip", 1);
2189 AddMacroDef(ltTRIANGLE
, "triangle", 0);
2190 AddMacroDef(ltTTFAMILY
, "ttfamily", 1);
2191 AddMacroDef(ltTT
, "tt", 1);
2192 AddMacroDef(ltTYPEIN
, "typein", 1);
2193 AddMacroDef(ltTYPEOUT
, "typeout", 1);
2194 AddMacroDef(ltTWOCOLWIDTHA
, "twocolwidtha", 1);
2195 AddMacroDef(ltTWOCOLWIDTHB
, "twocolwidthb", 1);
2196 AddMacroDef(ltTWOCOLSPACING
, "twocolspacing", 1);
2197 AddMacroDef(ltTWOCOLITEMRULED
, "twocolitemruled", 2);
2198 AddMacroDef(ltTWOCOLITEM
, "twocolitem", 2);
2199 AddMacroDef(ltTWOCOLLIST
, "twocollist", 1);
2200 AddMacroDef(ltTWOCOLUMN
, "twocolumn", 0);
2201 AddMacroDef(ltTHEPAGE
, "thepage", 0);
2202 AddMacroDef(ltTHECHAPTER
, "thechapter", 0);
2203 AddMacroDef(ltTHESECTION
, "thesection", 0);
2204 AddMacroDef(ltTHISPAGESTYLE
, "thispagestyle", 1);
2206 AddMacroDef(ltUNDERLINE
, "underline", 1);
2207 AddMacroDef(ltUPSILON
, "upsilon", 0);
2208 AddMacroDef(ltCAP_UPSILON
, "Upsilon", 0);
2209 AddMacroDef(ltUPARROW
, "uparrow", 0);
2210 AddMacroDef(ltUPARROW2
, "Uparrow", 0);
2211 AddMacroDef(ltUPPERCASE
, "uppercase", 1);
2212 AddMacroDef(ltUPSHAPE
, "upshape", 1);
2213 AddMacroDef(ltURLREF
, "urlref", 2);
2214 AddMacroDef(ltUSEPACKAGE
, "usepackage", 1);
2216 AddMacroDef(ltVAREPSILON
, "varepsilon", 0);
2217 AddMacroDef(ltVARPHI
, "varphi", 0);
2218 AddMacroDef(ltVARPI
, "varpi", 0);
2219 AddMacroDef(ltVARRHO
, "varrho", 0);
2220 AddMacroDef(ltVARSIGMA
, "varsigma", 0);
2221 AddMacroDef(ltVARTHETA
, "vartheta", 0);
2222 AddMacroDef(ltVDOTS
, "vdots", 0);
2223 AddMacroDef(ltVEE
, "vee", 0);
2224 AddMacroDef(ltVERBATIMINPUT
, "verbatiminput", 1);
2225 AddMacroDef(ltVERBATIM
, "verbatim", 1);
2226 AddMacroDef(ltVERBSTAR
, "verb*", 1);
2227 AddMacroDef(ltVERB
, "verb", 1);
2228 AddMacroDef(ltVERSE
, "verse", 1);
2229 AddMacroDef(ltVFILL
, "vfill", 0);
2230 AddMacroDef(ltVLINE
, "vline", 0);
2231 AddMacroDef(ltVOID
, "void", 0);
2232 AddMacroDef(ltVDASH
, "vdash", 0);
2233 AddMacroDef(ltVRULE
, "vrule", 0);
2234 AddMacroDef(ltVSPACESTAR
, "vspace*", 1);
2235 AddMacroDef(ltVSKIPSTAR
, "vskip*", 1);
2236 AddMacroDef(ltVSPACE
, "vspace", 1);
2237 AddMacroDef(ltVSKIP
, "vskip", 1);
2239 AddMacroDef(ltWEDGE
, "wedge", 0);
2240 AddMacroDef(ltWXCLIPS
, "wxclips", 0);
2241 AddMacroDef(ltWINHELPIGNORE
, "winhelpignore", 1);
2242 AddMacroDef(ltWINHELPONLY
, "winhelponly", 1);
2243 AddMacroDef(ltWP
, "wp", 0);
2245 AddMacroDef(ltXI
, "xi", 0);
2246 AddMacroDef(ltCAP_XI
, "Xi", 0);
2247 AddMacroDef(ltXLPIGNORE
, "xlpignore", 1);
2248 AddMacroDef(ltXLPONLY
, "xlponly", 1);
2250 AddMacroDef(ltZETA
, "zeta", 0);
2252 AddMacroDef(ltSPACE
, " ", 0);
2253 AddMacroDef(ltBACKSLASHCHAR
, "\\", 0);
2254 AddMacroDef(ltPIPE
, "|", 0);
2255 AddMacroDef(ltFORWARDSLASH
, "/", 0);
2256 AddMacroDef(ltUNDERSCORE
, "_", 0);
2257 AddMacroDef(ltAMPERSAND
, "&", 0);
2258 AddMacroDef(ltPERCENT
, "%", 0);
2259 AddMacroDef(ltDOLLAR
, "$", 0);
2260 AddMacroDef(ltHASH
, "#", 0);
2261 AddMacroDef(ltLPARENTH
, "(", 0);
2262 AddMacroDef(ltRPARENTH
, ")", 0);
2263 AddMacroDef(ltLBRACE
, "{", 0);
2264 AddMacroDef(ltRBRACE
, "}", 0);
2265 // AddMacroDef(ltEQUALS, "=", 0);
2266 AddMacroDef(ltRANGLEBRA
, ">", 0);
2267 AddMacroDef(ltLANGLEBRA
, "<", 0);
2268 AddMacroDef(ltPLUS
, "+", 0);
2269 AddMacroDef(ltDASH
, "-", 0);
2270 AddMacroDef(ltAT_SYMBOL
, "@", 0);
2271 // AddMacroDef(ltSINGLEQUOTE, "'", 0);
2272 // AddMacroDef(ltBACKQUOTE, "`", 0);
2276 * Default behaviour, should be called by client if can't match locally.
2280 // Called on start/end of macro examination
2281 void DefaultOnMacro(int macroId
, int no_args
, bool start
)
2285 // Default behaviour for abstract
2290 // Write the heading
2291 FakeCurrentSection(AbstractNameString
);
2292 OnMacro(ltPAR
, 0, TRUE
);
2293 OnMacro(ltPAR
, 0, FALSE
);
2297 if (DocumentStyle
== LATEX_ARTICLE
)
2305 // Default behaviour for glossary
2306 case ltHELPGLOSSARY
:
2310 // Write the heading
2311 FakeCurrentSection(GlossaryNameString
);
2312 OnMacro(ltPAR
, 0, TRUE
);
2313 OnMacro(ltPAR
, 0, FALSE
);
2314 if ((convertMode
== TEX_RTF
) && !winHelp
)
2316 OnMacro(ltPAR
, 0, TRUE
);
2317 OnMacro(ltPAR
, 0, FALSE
);
2322 case ltSPECIALAMPERSAND
:
2329 TexOutput("<<", TRUE
);
2333 TexOutput(">>", TRUE
);
2337 TexOutput("~", TRUE
);
2341 TexOutput("~", TRUE
);
2343 case ltSPECIALTILDE
:
2345 TexOutput(" ", TRUE
);
2349 TexOutput("_", TRUE
);
2353 TexOutput("#", TRUE
);
2357 TexOutput("&", TRUE
);
2361 TexOutput(" ", TRUE
);
2365 TexOutput("|", TRUE
);
2369 TexOutput("%", TRUE
);
2373 TexOutput("$", TRUE
);
2377 TexOutput("", TRUE
);
2381 TexOutput("", TRUE
);
2385 TexOutput("{", TRUE
);
2389 TexOutput("}", TRUE
);
2393 TexOutput("(c)", TRUE
);
2397 TexOutput("(r)", TRUE
);
2401 TexOutput("\\", TRUE
);
2406 TexOutput("...", TRUE
);
2410 TexOutput("|", TRUE
);
2414 TexOutput("LaTeX", TRUE
);
2418 TexOutput("TeX", TRUE
);
2422 TexOutput("£", TRUE
);
2424 case ltSPECIALDOUBLEDOLLAR
: // Interpret as center
2425 OnMacro(ltCENTER
, no_args
, start
);
2431 OnMacro(ltIT
, no_args
, start
);
2434 case ltPARAGRAPHSTAR
:
2435 case ltSUBPARAGRAPH
:
2436 case ltSUBPARAGRAPHSTAR
:
2437 OnMacro(ltSUBSUBSECTION
, no_args
, start
);
2445 TexOutput(ctime(&when
), TRUE
);
2456 if (start
) TexOutput("alpha");
2459 if (start
) TexOutput("beta");
2462 if (start
) TexOutput("gamma");
2465 if (start
) TexOutput("delta");
2469 if (start
) TexOutput("epsilon");
2472 if (start
) TexOutput("zeta");
2475 if (start
) TexOutput("eta");
2479 if (start
) TexOutput("theta");
2482 if (start
) TexOutput("iota");
2485 if (start
) TexOutput("kappa");
2488 if (start
) TexOutput("lambda");
2491 if (start
) TexOutput("mu");
2494 if (start
) TexOutput("nu");
2497 if (start
) TexOutput("xi");
2501 if (start
) TexOutput("pi");
2505 if (start
) TexOutput("rho");
2509 if (start
) TexOutput("sigma");
2512 if (start
) TexOutput("tau");
2515 if (start
) TexOutput("upsilon");
2519 if (start
) TexOutput("phi");
2522 if (start
) TexOutput("chi");
2525 if (start
) TexOutput("psi");
2528 if (start
) TexOutput("omega");
2531 if (start
) TexOutput("GAMMA");
2534 if (start
) TexOutput("DELTA");
2537 if (start
) TexOutput("THETA");
2540 if (start
) TexOutput("LAMBDA");
2543 if (start
) TexOutput("XI");
2546 if (start
) TexOutput("PI");
2549 if (start
) TexOutput("SIGMA");
2552 if (start
) TexOutput("UPSILON");
2555 if (start
) TexOutput("PHI");
2558 if (start
) TexOutput("PSI");
2561 if (start
) TexOutput("OMEGA");
2564 // Binary operation symbols
2567 if (start
) TexOutput("<=");
2570 if (start
) TexOutput("<<");
2573 if (start
) TexOutput("SUBSET");
2576 if (start
) TexOutput("SUBSETEQ");
2579 if (start
) TexOutput("IN");
2582 if (start
) TexOutput("VDASH");
2585 if (start
) TexOutput("MODELS");
2589 if (start
) TexOutput(">=");
2592 if (start
) TexOutput(">>");
2595 if (start
) TexOutput("SUPSET");
2598 if (start
) TexOutput("SUPSETEQ");
2601 if (start
) TexOutput("NI");
2604 if (start
) TexOutput("DASHV");
2607 if (start
) TexOutput("PERP");
2610 if (start
) TexOutput("NEQ");
2613 if (start
) TexOutput("DOTEQ");
2616 if (start
) TexOutput("APPROX");
2619 if (start
) TexOutput("CONG");
2622 if (start
) TexOutput("EQUIV");
2625 if (start
) TexOutput("PROPTO");
2628 if (start
) TexOutput("PREC");
2631 if (start
) TexOutput("PRECEQ");
2634 if (start
) TexOutput("|");
2637 if (start
) TexOutput("~");
2640 if (start
) TexOutput("SIMEQ");
2643 if (start
) TexOutput("ASYMP");
2646 if (start
) TexOutput(":-)");
2649 if (start
) TexOutput(":-(");
2652 if (start
) TexOutput("SUCC");
2655 if (start
) TexOutput("SUCCEQ");
2658 if (start
) TexOutput("|");
2661 // Negated relation symbols
2663 if (start
) TexOutput("!=");
2666 if (start
) TexOutput("NOTIN");
2669 if (start
) TexOutput("NOTSUBSET");
2674 if (start
) TexOutput("<--");
2677 if (start
) TexOutput("<==");
2680 if (start
) TexOutput("-->");
2683 if (start
) TexOutput("==>");
2685 case ltLEFTRIGHTARROW
:
2686 if (start
) TexOutput("<-->");
2688 case ltLEFTRIGHTARROW2
:
2689 if (start
) TexOutput("<==>");
2692 if (start
) TexOutput("UPARROW");
2695 if (start
) TexOutput("UPARROW2");
2698 if (start
) TexOutput("DOWNARROW");
2701 if (start
) TexOutput("DOWNARROW2");
2703 // Miscellaneous symbols
2705 if (start
) TexOutput("ALEPH");
2708 if (start
) TexOutput("WP");
2711 if (start
) TexOutput("RE");
2714 if (start
) TexOutput("IM");
2717 if (start
) TexOutput("EMPTYSET");
2720 if (start
) TexOutput("NABLA");
2723 if (start
) TexOutput("SURD");
2726 if (start
) TexOutput("PARTIAL");
2729 if (start
) TexOutput("BOT");
2732 if (start
) TexOutput("FORALL");
2735 if (start
) TexOutput("EXISTS");
2738 if (start
) TexOutput("NEG");
2741 if (start
) TexOutput("SHARP");
2744 if (start
) TexOutput("ANGLE");
2747 if (start
) TexOutput("TRIANGLE");
2750 if (start
) TexOutput("CLUBSUIT");
2753 if (start
) TexOutput("DIAMONDSUIT");
2756 if (start
) TexOutput("HEARTSUIT");
2759 if (start
) TexOutput("SPADESUIT");
2762 if (start
) TexOutput("INFTY");
2765 if (start
) TexOutput("PM");
2768 if (start
) TexOutput("MP");
2771 if (start
) TexOutput("TIMES");
2774 if (start
) TexOutput("DIV");
2777 if (start
) TexOutput("CDOT");
2780 if (start
) TexOutput("AST");
2783 if (start
) TexOutput("STAR");
2786 if (start
) TexOutput("CAP");
2789 if (start
) TexOutput("CUP");
2792 if (start
) TexOutput("VEE");
2795 if (start
) TexOutput("WEDGE");
2798 if (start
) TexOutput("CIRC");
2801 if (start
) TexOutput("BULLET");
2804 if (start
) TexOutput("DIAMOND");
2807 if (start
) TexOutput("OSLASH");
2810 if (start
) TexOutput("BOX");
2813 if (start
) TexOutput("DIAMOND2");
2815 case ltBIGTRIANGLEDOWN
:
2816 if (start
) TexOutput("BIGTRIANGLEDOWN");
2819 if (start
) TexOutput("OPLUS");
2822 if (start
) TexOutput("OTIMES");
2825 if (start
) TexOutput("s");
2827 case ltBACKSLASHRAW
:
2828 if (start
) TexOutput("\\");
2831 if (start
) TexOutput("{");
2834 if (start
) TexOutput("}");
2838 if (start
) TexOutput(" ");
2845 // Called on start/end of argument examination
2846 bool DefaultOnArgument(int macroId
, int arg_no
, bool start
)
2852 if (arg_no
== 1 && start
)
2854 char *refName
= GetArgData();
2857 TexRef
*texRef
= FindReference(refName
);
2860 // Must strip the 'section' or 'chapter' or 'figure' text
2861 // from a normal 'ref' reference
2863 strcpy(buf
, texRef
->sectionNumber
);
2864 int len
= strlen(buf
);
2866 if (strcmp(buf
, "??") != 0)
2878 TexOutput(texRef
->sectionNumber
+ i
, TRUE
);
2883 TexOutput("??", TRUE
);
2884 sprintf(buf
, "Warning: unresolved reference %s.", refName
);
2888 else TexOutput("??", TRUE
);
2900 if (start
&& (arg_no
== 1))
2901 DocumentAuthor
= GetArgChunk();
2907 if (start
&& (arg_no
== 1))
2908 DocumentDate
= GetArgChunk();
2914 if (start
&& (arg_no
== 1))
2915 DocumentTitle
= GetArgChunk();
2919 case ltDOCUMENTCLASS
:
2920 case ltDOCUMENTSTYLE
:
2922 if (start
&& !IsArgOptional())
2924 DocumentStyleString
= copystring(GetArgData());
2925 if (strncmp(DocumentStyleString
, "art", 3) == 0)
2926 DocumentStyle
= LATEX_ARTICLE
;
2927 else if (strncmp(DocumentStyleString
, "rep", 3) == 0)
2928 DocumentStyle
= LATEX_REPORT
;
2929 else if (strncmp(DocumentStyleString
, "book", 4) == 0 ||
2930 strncmp(DocumentStyleString
, "thesis", 6) == 0)
2931 DocumentStyle
= LATEX_BOOK
;
2932 else if (strncmp(DocumentStyleString
, "letter", 6) == 0)
2933 DocumentStyle
= LATEX_LETTER
;
2934 else if (strncmp(DocumentStyleString
, "slides", 6) == 0)
2935 DocumentStyle
= LATEX_SLIDES
;
2937 if (StringMatch("10", DocumentStyleString
))
2939 else if (StringMatch("11", DocumentStyleString
))
2941 else if (StringMatch("12", DocumentStyleString
))
2944 OnMacro(ltHELPFONTSIZE
, 1, TRUE
);
2945 sprintf(currentArgData
, "%d", normalFont
);
2947 OnArgument(ltHELPFONTSIZE
, 1, TRUE
);
2948 OnArgument(ltHELPFONTSIZE
, 1, FALSE
);
2949 haveArgData
= FALSE
;
2950 OnMacro(ltHELPFONTSIZE
, 1, FALSE
);
2952 else if (start
&& IsArgOptional())
2954 MinorDocumentStyleString
= copystring(GetArgData());
2956 if (StringMatch("10", MinorDocumentStyleString
))
2958 else if (StringMatch("11", MinorDocumentStyleString
))
2960 else if (StringMatch("12", MinorDocumentStyleString
))
2966 case ltBIBLIOGRAPHYSTYLE
:
2968 if (start
&& !IsArgOptional())
2969 BibliographyStyleString
= copystring(GetArgData());
2975 if (start
&& !IsArgOptional())
2977 if (PageStyle
) delete[] PageStyle
;
2978 PageStyle
= copystring(GetArgData());
2986 if (start && !IsArgOptional())
2987 LeftHeader = GetArgChunk();
2993 if (start && !IsArgOptional())
2994 LeftFooter = GetArgChunk();
3000 if (start && !IsArgOptional())
3001 CentreHeader = GetArgChunk();
3007 if (start && !IsArgOptional())
3008 CentreFooter = GetArgChunk();
3014 if (start && !IsArgOptional())
3015 RightHeader = GetArgChunk();
3021 if (start && !IsArgOptional())
3022 RightFooter = GetArgChunk();
3030 if (start
&& !IsArgOptional())
3032 char *citeKeys
= GetArgData();
3034 char *citeKey
= ParseMultifieldString(citeKeys
, &pos
);
3037 AddCitation(citeKey
);
3038 TexRef
*ref
= FindReference(citeKey
);
3041 TexOutput(ref
->sectionNumber
, TRUE
);
3042 if (strcmp(ref
->sectionNumber
, "??") == 0)
3045 sprintf(buf
, "Warning: unresolved citation %s.", citeKey
);
3049 citeKey
= ParseMultifieldString(citeKeys
, &pos
);
3052 TexOutput(", ", TRUE
);
3061 if (start
&& !IsArgOptional())
3063 char *citeKey
= GetArgData();
3064 AddCitation(citeKey
);
3069 case ltHELPFONTSIZE
:
3073 char *data
= GetArgData();
3074 if (strcmp(data
, "10") == 0)
3076 else if (strcmp(data
, "11") == 0)
3078 else if (strcmp(data
, "12") == 0)
3088 TexOutput(" ??", TRUE
);
3095 if (start
&& arg_no
== 1)
3097 char *data
= GetArgData();
3098 ParSkip
= ParseUnitArgument(data
);
3105 if (start
&& arg_no
== 1)
3107 char *data
= GetArgData();
3108 ParIndent
= ParseUnitArgument(data
);
3115 return OnArgument(ltIT
, arg_no
, start
);
3118 case ltSPECIALDOUBLEDOLLAR
:
3120 return OnArgument(ltCENTER
, arg_no
, start
);
3124 case ltPARAGRAPHSTAR
:
3125 case ltSUBPARAGRAPH
:
3126 case ltSUBPARAGRAPHSTAR
:
3128 return OnArgument(ltSUBSUBSECTION
, arg_no
, start
);
3134 OnInform(GetArgData());
3140 TexOutput(" (", TRUE
);
3142 TexOutput(")", TRUE
);
3145 case ltBIBLIOGRAPHY
:
3153 if ((fd
= fopen(TexBibName
, "r")))
3159 TexOutput(smallBuf
);
3167 OnInform("Run Tex2RTF again to include bibliography.");
3170 // Read in the .bib file, resolve all known references, write out the RTF.
3171 char *allFiles
= GetArgData();
3173 char *bibFile
= ParseMultifieldString(allFiles
, &pos
);
3177 strcpy(fileBuf
, bibFile
);
3178 wxString actualFile
= TexPathList
.FindValidPath(fileBuf
);
3179 if (actualFile
== "")
3181 strcat(fileBuf
, ".bib");
3182 actualFile
= TexPathList
.FindValidPath(fileBuf
);
3184 if (actualFile
!= "")
3186 if (!ReadBib((char*) (const char*) actualFile
))
3189 sprintf(buf
, ".bib file %s not found or malformed", (const char*) actualFile
);
3196 sprintf(buf
, ".bib file %s not found", fileBuf
);
3199 bibFile
= ParseMultifieldString(allFiles
, &pos
);
3202 ResolveBibReferences();
3204 // Write it a new bib section in the appropriate format.
3205 FILE *save1
= CurrentOutput1
;
3206 FILE *save2
= CurrentOutput2
;
3207 FILE *Biblio
= fopen(TexTmpBibName
, "w");
3208 SetCurrentOutput(Biblio
);
3211 if (wxFileExists(TexTmpBibName
))
3213 if (wxFileExists(TexBibName
)) wxRemoveFile(TexBibName
);
3214 wxRenameFile(TexTmpBibName
, TexBibName
);
3216 SetCurrentOutputs(save1
, save2
);
3223 if (start
&& (arg_no
== 3))
3233 if (start
&& (arg_no
== 1))
3235 char *s
= GetArgData();
3238 char *s1
= copystring(s
);
3240 for (i
= 0; i
< (int)strlen(s
); i
++)
3241 s1
[i
] = toupper(s
[i
]);
3254 if (start
&& (arg_no
== 1))
3256 char *s
= GetArgData();
3259 char *s1
= copystring(s
);
3261 for (i
= 0; i
< (int)strlen(s
); i
++)
3262 s1
[i
] = tolower(s
[i
]);
3275 if (start
&& (arg_no
== 1))
3277 char *s
= GetArgData();
3280 char *s1
= copystring(s
);
3282 for (i
= 0; i
< (int)strlen(s
); i
++)
3283 s1
[i
] = toupper(s
[i
]);
3294 case ltPOPREF
: // Ignore second argument by default
3296 if (start
&& (arg_no
== 1))
3306 return ((convertMode
== TEX_XLP
) ? FALSE
: TRUE
);
3309 return ((convertMode
!= TEX_XLP
) ? FALSE
: TRUE
);
3312 return ((convertMode
== TEX_HTML
) ? FALSE
: TRUE
);
3315 return ((convertMode
!= TEX_HTML
) ? FALSE
: TRUE
);
3318 return (((convertMode
== TEX_RTF
) && !winHelp
) ? FALSE
: TRUE
);
3321 return (!((convertMode
== TEX_RTF
) && !winHelp
) ? FALSE
: TRUE
);
3323 case ltWINHELPIGNORE
:
3324 return (winHelp
? FALSE
: TRUE
);
3327 return (!winHelp
? FALSE
: TRUE
);
3342 case ltADDTOCOUNTER
:
3343 case ltADDCONTENTSLINE
:
3347 case ltBASELINESKIP
:
3356 case ltPAGENUMBERING
:
3368 case ltTHISPAGESTYLE
:
3371 case ltEVENSIDEMARGIN
:
3372 case ltODDSIDEMARGIN
:
3374 case ltMARGINPARWIDTH
:
3375 case ltMARGINPARSEP
:
3376 case ltMARGINPAREVEN
:
3377 case ltMARGINPARODD
:
3378 case ltTWOCOLWIDTHA
:
3379 case ltTWOCOLWIDTHB
:
3380 case ltTWOCOLSPACING
:
3387 case ltSETHOTSPOTCOLOUR
:
3388 case ltSETHOTSPOTCOLOR
:
3389 case ltSETHOTSPOTUNDERLINE
:
3390 case ltSETTRANSPARENCY
:
3393 case ltBACKGROUNDCOLOUR
:
3394 case ltBACKGROUNDIMAGE
:
3396 case ltFOLLOWEDLINKCOLOUR
:
3403 case ltINSERTATLEVEL
:
3407 case ltSUPERTABULAR
:
3416 if (arg_no
== 2) return TRUE
;
3423 if (arg_no
== 2) return TRUE
;
3427 case ltDEFINECOLOUR
:
3430 static int redVal
= 0;
3431 static int greenVal
= 0;
3432 static int blueVal
= 0;
3433 static char *colourName
= NULL
;
3440 if (colourName
) delete[] colourName
;
3441 colourName
= copystring(GetArgData());
3446 redVal
= atoi(GetArgData());
3451 greenVal
= atoi(GetArgData());
3456 blueVal
= atoi(GetArgData());
3457 AddColour(colourName
, redVal
, greenVal
, blueVal
);
3473 if (IsArgOptional())