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
;
124 bool htmlWorkshopFiles
= FALSE
;
127 * International support
130 // Names to help with internationalisation
131 char *ContentsNameString
= copystring("Contents");
132 char *AbstractNameString
= copystring("Abstract");
133 char *GlossaryNameString
= copystring("Glossary");
134 char *ReferencesNameString
= copystring("References");
135 char *FiguresNameString
= copystring("List of Figures");
136 char *TablesNameString
= copystring("List of Tables");
137 char *FigureNameString
= copystring("Figure");
138 char *TableNameString
= copystring("Table");
139 char *IndexNameString
= copystring("Index");
140 char *ChapterNameString
= copystring("chapter");
141 char *SectionNameString
= copystring("section");
142 char *SubsectionNameString
= copystring("subsection");
143 char *SubsubsectionNameString
= copystring("subsubsection");
144 char *UpNameString
= copystring("Up");
153 int subsectionNo
= 0;
154 int subsubsectionNo
= 0;
163 FILE *CurrentOutput1
= NULL
;
164 FILE *CurrentOutput2
= NULL
;
168 int CurrentInputIndex
= 0;
170 char *TexFileRoot
= NULL
;
171 char *TexBibName
= NULL
; // Bibliography output file name
172 char *TexTmpBibName
= NULL
; // Temporary bibliography output file name
173 bool isSync
= FALSE
; // If TRUE, should not yield to other processes.
174 bool stopRunning
= FALSE
; // If TRUE, should abort.
176 static int currentColumn
= 0;
177 char *currentArgData
= NULL
;
178 bool haveArgData
= FALSE
; // If TRUE, we're simulating the data.
179 TexChunk
*currentArgument
= NULL
;
180 TexChunk
*nextChunk
= NULL
;
181 bool isArgOptional
= FALSE
;
184 TexChunk
*TopLevel
= NULL
;
185 // wxList MacroDefs(wxKEY_STRING);
186 wxHashTable
MacroDefs(wxKEY_STRING
);
187 wxStringList IgnorableInputFiles
; // Ignorable \input files, e.g. psbox.tex
188 char *BigBuffer
= NULL
; // For reading in large chunks of text
189 TexMacroDef
*SoloBlockDef
= NULL
;
190 TexMacroDef
*VerbatimMacroDef
= NULL
;
192 #define IncrementLineNumber() LineNumbers[CurrentInputIndex] ++
194 void TexOutput(char *s
, bool ordinaryText
)
198 // Update current column, but only if we're guaranteed to
199 // be ordinary text (not mark-up stuff)
202 for (i
= 0; i
< len
; i
++)
204 if (s
[i
] == 13 || s
[i
] == 10)
211 fprintf(CurrentOutput1
, "%s", s
);
213 fprintf(CurrentOutput2
, "%s", s
);
217 * Try to find a Latex macro, in one of the following forms:
218 * (1) \begin{} ... \end{}
219 * (2) \macroname{arg1}...{argn}
223 void ForbidWarning(TexMacroDef
*def
)
226 switch (def
->forbidden
)
230 sprintf(buf
, "Warning: it is recommended that command %s is not used.", def
->name
);
234 case FORBID_ABSOLUTELY
:
236 sprintf(buf
, "Error: command %s cannot be used and will lead to errors.", def
->name
);
245 TexMacroDef
*MatchMacro(char *buffer
, int *pos
, char **env
, bool *parseToBrace
)
247 *parseToBrace
= TRUE
;
249 TexMacroDef
*def
= NULL
;
252 // First, try to find begin{thing}
253 if (strncmp(buffer
+i
, "begin{", 6) == 0)
258 while ((isalpha(buffer
[j
]) || buffer
[j
] == '*') && ((j
- i
) < 39))
260 macroBuf
[j
-i
] = buffer
[j
];
264 def
= (TexMacroDef
*)MacroDefs
.Get(macroBuf
);
268 *pos
= j
+ 1; // BUGBUG Should this be + 1???
276 // Failed, so try to find macro from definition list
279 // First try getting a one-character macro, but ONLY
280 // if these TWO characters are not both alphabetical (could
281 // be a longer macro)
282 if (!(isalpha(buffer
[i
]) && isalpha(buffer
[i
+1])))
284 macroBuf
[0] = buffer
[i
];
287 def
= (TexMacroDef
*)MacroDefs
.Get(macroBuf
);
293 while ((isalpha(buffer
[j
]) || buffer
[j
] == '*') && ((j
- i
) < 39))
295 macroBuf
[j
-i
] = buffer
[j
];
299 def
= (TexMacroDef
*)MacroDefs
.Get(macroBuf
);
306 // We want to check whether this is a space-consuming macro
308 // No brace, e.g. \input thing.tex instead of \input{thing};
309 // or a numeric argument, such as \parindent0pt
310 if ((def
->no_args
> 0) && ((buffer
[i
] == 32) || (buffer
[i
] == '=') || (isdigit(buffer
[i
]))))
312 if ((buffer
[i
] == 32) || (buffer
[i
] == '='))
315 *parseToBrace
= FALSE
;
324 void EatWhiteSpace(char *buffer
, int *pos
)
326 int len
= strlen(buffer
);
328 bool keepGoing
= TRUE
;
329 bool moreLines
= TRUE
;
330 while ((j
< len
) && keepGoing
&&
331 (buffer
[j
] == 10 || buffer
[j
] == 13 || buffer
[j
] == ' ' || buffer
[j
] == 9))
338 moreLines
= read_a_line(buffer
);
339 len
= strlen(buffer
);
349 bool FindEndEnvironment(char *buffer
, int *pos
, char *env
)
353 // Try to find end{thing}
354 if ((strncmp(buffer
+i
, "end{", 4) == 0) &&
355 (strncmp(buffer
+i
+4, env
, strlen(env
)) == 0))
357 *pos
= i
+ 5 + strlen(env
);
363 bool readingVerbatim
= FALSE
;
364 bool readInVerbatim
= FALSE
; // Within a verbatim, but not nec. verbatiminput
366 bool read_a_line(char *buf
)
368 if (CurrentInputIndex
< 0)
377 while (ch
!= EOF
&& ch
!= 10)
379 if (((i
== 14) && (strncmp(buf
, "\\end{verbatim}", 14) == 0)) ||
380 ((i
== 16) && (strncmp(buf
, "\\end{toocomplex}", 16) == 0)))
381 readInVerbatim
= FALSE
;
383 ch
= getc(Inputs
[CurrentInputIndex
]);
386 // Check for 2 consecutive newlines and replace with \par
387 if (ch
== 10 && !readInVerbatim
)
389 int ch1
= getc(Inputs
[CurrentInputIndex
]);
390 if ((ch1
== 10) || (ch1
== 13))
392 // Eliminate newline (10) following DOS linefeed
393 if (ch1
== 13) ch1
= getc(Inputs
[CurrentInputIndex
]);
395 IncrementLineNumber();
396 // strcat(buf, "\\par\n");
398 strcat(buf
, "\\par");
403 ungetc(ch1
, Inputs
[CurrentInputIndex
]);
411 // Convert embedded characters to RTF equivalents
425 case 0xf6:buf
[i
++]='o';break; // ö
426 case 0xe4:buf
[i
++]='a';break; // ä
427 case 0xfc:buf
[i
++]='u';break; // ü
428 case 0xd6:buf
[i
++]='O';break; // Ö
429 case 0xc4:buf
[i
++]='A';break; // Ä
430 case 0xdc:buf
[i
++]='U';break; // Ü
451 fclose(Inputs
[CurrentInputIndex
]);
452 Inputs
[CurrentInputIndex
] = NULL
;
453 if (CurrentInputIndex
> 0) ch
= ' '; // No real end of file
454 CurrentInputIndex
--;
457 readingVerbatim
= FALSE
;
458 readInVerbatim
= FALSE
;
459 strcat(buf
, "\\end{verbatim}\n");
464 IncrementLineNumber();
468 // Strip out comment environment
469 if (strncmp(buf
, "\\begin{comment}", 15) == 0)
471 while (strncmp(buf
, "\\end{comment}", 13) != 0)
473 return read_a_line(buf
);
475 // Read a verbatim input file as if it were a verbatim environment
476 else if (strncmp(buf
, "\\verbatiminput", 14) == 0)
479 char *fileName
= buf
+ wordLen
+ 1;
484 // thing}\par -- eliminate the \par!
485 if (strncmp((buf
+ strlen(buf
)-5), "\\par", 4) == 0)
491 if (buf
[j
-1] == '}') buf
[j
-1] = 0; // Ignore final brace
493 wxString actualFile
= TexPathList
.FindValidPath(fileName
);
494 if (actualFile
== "")
497 strcpy(errBuf
, "Could not find file: ");
498 strncat(errBuf
, fileName
, 100);
503 CurrentInputIndex
++;
504 Inputs
[CurrentInputIndex
] = fopen(actualFile
, "r");
505 LineNumbers
[CurrentInputIndex
] = 1;
506 if (FileNames
[CurrentInputIndex
])
507 delete[] FileNames
[CurrentInputIndex
];
508 FileNames
[CurrentInputIndex
] = copystring(actualFile
);
510 if (!Inputs
[CurrentInputIndex
])
512 CurrentInputIndex
--;
513 OnError("Could not open verbatiminput file.");
517 readingVerbatim
= TRUE
;
518 readInVerbatim
= TRUE
;
519 strcpy(buf
, "\\begin{verbatim}\n");
525 else if (strncmp(buf
, "\\input", 6) == 0 || strncmp(buf
, "\\helpinput", 10) == 0 ||
526 strncmp(buf
, "\\include", 8) == 0)
529 if (strncmp(buf
, "\\input", 6) == 0)
532 if (strncmp(buf
, "\\include", 8) == 0)
537 char *fileName
= buf
+ wordLen
+ 1;
542 // \input{thing}\par -- eliminate the \par!
543 // if (strncmp((buf + strlen(buf)-5), "\\par", 4) == 0)
544 if (strncmp((buf
+ strlen(buf
)-4), "\\par", 4) == 0) // Bug fix 8/2/95 Ulrich Leodolter
551 if (buf
[j
-1] == '}') buf
[j
-1] = 0; // Ignore final brace
553 // Ignore some types of input files (e.g. macro definition files)
554 char *fileOnly
= FileNameFromPath(fileName
);
555 if (IgnorableInputFiles
.Member(fileOnly
))
556 return read_a_line(buf
);
558 wxString actualFile
= TexPathList
.FindValidPath(fileName
);
559 if (actualFile
== "")
562 sprintf(buf2
, "%s.tex", fileName
);
563 actualFile
= TexPathList
.FindValidPath(buf2
);
565 if (actualFile
== "")
568 strcpy(errBuf
, "Could not find file: ");
569 strncat(errBuf
, fileName
, 100);
574 // Ensure that if this file includes another,
575 // then we look in the same directory as this one.
576 TexPathList
.EnsureFileAccessible(actualFile
);
578 CurrentInputIndex
++;
579 Inputs
[CurrentInputIndex
] = fopen(actualFile
, "r");
580 LineNumbers
[CurrentInputIndex
] = 1;
581 if (FileNames
[CurrentInputIndex
])
582 delete[] FileNames
[CurrentInputIndex
];
583 FileNames
[CurrentInputIndex
] = copystring(actualFile
);
585 if (!Inputs
[CurrentInputIndex
])
588 sprintf(errBuf
, "Could not open include file %s", (const char*) actualFile
);
589 CurrentInputIndex
--;
593 bool succ
= read_a_line(buf
);
596 if (strncmp(buf
, "\\begin{verbatim}", 16) == 0 ||
597 strncmp(buf
, "\\begin{toocomplex}", 18) == 0)
598 readInVerbatim
= TRUE
;
599 else if (strncmp(buf
, "\\end{verbatim}", 14) == 0 ||
600 strncmp(buf
, "\\end{toocomplex}", 16) == 0)
601 readInVerbatim
= FALSE
;
611 bool ParseNewCommand(char *buffer
, int *pos
)
613 if ((strncmp((buffer
+(*pos
)), "newcommand", 10) == 0) ||
614 (strncmp((buffer
+(*pos
)), "renewcommand", 12) == 0))
616 if (strncmp((buffer
+(*pos
)), "newcommand", 10) == 0)
621 char commandName
[100];
622 char commandValue
[1000];
625 while (buffer
[*pos
] != '}' && (buffer
[*pos
] != 0))
627 commandName
[i
] = buffer
[*pos
];
634 if (buffer
[*pos
] == '[')
637 noArgs
= (int)(buffer
[*pos
]) - 48;
638 *pos
+= 2; // read past argument and '['
644 char ch
= buffer
[*pos
];
655 if (!read_a_line(buffer
))
660 commandValue
[i
] = ch
;
666 CustomMacro
*macro
= new CustomMacro(commandName
, noArgs
, NULL
);
667 if (strlen(commandValue
) > 0)
668 macro
->macroBody
= copystring(commandValue
);
669 if (!CustomMacroList
.Find(commandName
))
671 CustomMacroList
.Append(commandName
, macro
);
672 AddMacroDef(ltCUSTOM_MACRO
, commandName
, noArgs
);
679 void MacroError(char *buffer
)
686 while (((ch
= buffer
[i
-1]) != '\n') && (ch
!= 0))
695 sprintf(errBuf
, "Could not find macro: %s at line %d, file %s",
696 macroBuf
, (int)(LineNumbers
[CurrentInputIndex
]-1), FileNames
[CurrentInputIndex
]);
702 * 'environment' specifies the name of the macro IFF if we're looking for the end
703 * of an environment, e.g. \end{itemize}. Otherwise it's NULL.
704 * 'parseToBrace' is TRUE if the argument should extend to the next right brace,
705 * e.g. in {\bf an argument} as opposed to \vskip 30pt
708 int ParseArg(TexChunk
*thisArg
, wxList
& children
, char *buffer
, int pos
, char *environment
, bool parseToBrace
, TexChunk
*customMacroArgs
)
711 if (stopRunning
) return pos
;
720 // Consume leading brace or square bracket, but ONLY if not following
721 // a space, because this could be e.g. {\large {\bf thing}} where {\bf thing}
722 // is the argument of \large AS WELL as being a block in its
726 if ((pos > 0) && (buffer[pos-1] != ' ') && buffer[pos] == '{')
730 if ((pos > 0) && (buffer[pos-1] != ' ') && (buffer[pos] == '[' || buffer[pos] == '('))
735 else if ((pos > 1) && (buffer[pos-1] != ' ') && (buffer[pos+1] == '[' || buffer[pos+1] == '('))
743 // If not parsing to brace, just read the next word
744 // (e.g. \vskip 20pt)
747 int ch
= buffer
[pos
];
748 while (!eof
&& ch
!= 13 && ch
!= 32 && ch
!= 10 &&
749 ch
!= 0 && ch
!= '{')
751 BigBuffer
[buf_ptr
] = ch
;
758 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_STRING
);
759 BigBuffer
[buf_ptr
] = 0;
761 chunk
->value
= copystring(BigBuffer
);
762 children
.Append((wxObject
*)chunk
);
769 len
= strlen(buffer
);
772 if (customMacroArgs
) return 0;
774 eof
= read_a_line(buffer
);
776 len
= strlen(buffer
);
777 // Check for verbatim (or toocomplex, which comes to the same thing)
778 if (strncmp(buffer
, "\\begin{verbatim}", 16) == 0 ||
779 strncmp(buffer
, "\\begin{toocomplex}", 18) == 0)
783 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_STRING
);
784 BigBuffer
[buf_ptr
] = 0;
786 chunk
->value
= copystring(BigBuffer
);
787 children
.Append((wxObject
*)chunk
);
792 eof
= read_a_line(buffer
);
793 while (!eof
&& (strncmp(buffer
, "\\end{verbatim}", 14) != 0) &&
794 (strncmp(buffer
, "\\end{toocomplex}", 16) != 0)
797 strcat(BigBuffer
, buffer
);
798 buf_ptr
+= strlen(buffer
);
799 eof
= read_a_line(buffer
);
801 eof
= read_a_line(buffer
);
804 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_MACRO
, VerbatimMacroDef
);
806 chunk
->macroId
= ltVERBATIM
;
807 TexChunk
*arg
= new TexChunk(CHUNK_TYPE_ARG
, VerbatimMacroDef
);
809 arg
->macroId
= ltVERBATIM
;
810 TexChunk
*str
= new TexChunk(CHUNK_TYPE_STRING
);
811 str
->value
= copystring(BigBuffer
);
813 children
.Append((wxObject
*)chunk
);
814 chunk
->children
.Append((wxObject
*)arg
);
815 arg
->children
.Append((wxObject
*)str
);
817 // Also want to include the following newline (is always a newline
818 // after a verbatim): EXCEPT in HTML
819 if (convertMode
!= TEX_HTML
)
821 TexMacroDef
*parDef
= (TexMacroDef
*)MacroDefs
.Get("\\");
822 TexChunk
*parChunk
= new TexChunk(CHUNK_TYPE_MACRO
, parDef
);
823 parChunk
->no_args
= 0;
824 parChunk
->macroId
= ltBACKSLASHCHAR
;
825 children
.Append((wxObject
*)parChunk
);
830 char ch
= buffer
[pos
];
831 // End of optional argument -- pretend it's right brace for simplicity
832 if (thisArg
->optional
&& (ch
== ']'))
838 case '}': // End of argument
842 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_STRING
);
843 BigBuffer
[buf_ptr
] = 0;
845 chunk
->value
= copystring(BigBuffer
);
846 children
.Append((wxObject
*)chunk
);
848 if (ch
== '}') pos
++;
854 if (buf_ptr
> 0) // Finish off the string we've read so far
856 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_STRING
);
857 BigBuffer
[buf_ptr
] = 0;
859 chunk
->value
= copystring(BigBuffer
);
860 children
.Append((wxObject
*)chunk
);
865 // Try matching \end{environment}
866 if (environment
&& FindEndEnvironment(buffer
, &pos
, environment
))
868 // Eliminate newline after an \end{} if possible
869 if (buffer
[pos
] == 13)
872 if (buffer
[pos
] == 10)
878 if (ParseNewCommand(buffer
, &pos
))
881 if (strncmp(buffer
+pos
, "special", 7) == 0)
894 int ch
= buffer
[pos
];
916 else if (ch
== '\\' && buffer
[pos
+1] == '}')
922 else if (ch
== '\\' && buffer
[pos
+1] == '{')
937 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_MACRO
);
939 chunk
->macroId
= ltSPECIAL
;
940 TexMacroDef
*specialDef
= (TexMacroDef
*)MacroDefs
.Get("special");
941 chunk
->def
= specialDef
;
942 TexChunk
*arg
= new TexChunk(CHUNK_TYPE_ARG
, specialDef
);
943 chunk
->children
.Append((wxObject
*)arg
);
945 arg
->macroId
= chunk
->macroId
;
947 // The value in the first argument.
948 TexChunk
*argValue
= new TexChunk(CHUNK_TYPE_STRING
);
949 arg
->children
.Append((wxObject
*)argValue
);
951 argValue
->value
= copystring(wxBuffer
);
953 children
.Append((wxObject
*)chunk
);
955 else if (strncmp(buffer
+pos
, "verb", 4) == 0)
958 if (buffer
[pos
] == '*')
961 // Find the delimiter character
962 int ch
= buffer
[pos
];
964 // Now at start of verbatim text
966 while ((buffer
[pos
] != ch
) && buffer
[pos
] != 0)
968 char *val
= new char[pos
- j
+ 1];
970 for (i
= j
; i
< pos
; i
++)
972 val
[i
-j
] = buffer
[i
];
978 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_MACRO
);
980 chunk
->macroId
= ltVERB
;
981 TexMacroDef
*verbDef
= (TexMacroDef
*)MacroDefs
.Get("verb");
982 chunk
->def
= verbDef
;
983 TexChunk
*arg
= new TexChunk(CHUNK_TYPE_ARG
, verbDef
);
984 chunk
->children
.Append((wxObject
*)arg
);
986 arg
->macroId
= chunk
->macroId
;
988 // The value in the first argument.
989 TexChunk
*argValue
= new TexChunk(CHUNK_TYPE_STRING
);
990 arg
->children
.Append((wxObject
*)argValue
);
992 argValue
->value
= val
;
994 children
.Append((wxObject
*)chunk
);
999 bool tmpParseToBrace
= TRUE
;
1000 TexMacroDef
*def
= MatchMacro(buffer
, &pos
, &env
, &tmpParseToBrace
);
1003 CustomMacro
*customMacro
= FindCustomMacro(def
->name
);
1005 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_MACRO
, def
);
1006 chunk
->no_args
= def
->no_args
;
1007 // chunk->name = copystring(def->name);
1008 chunk
->macroId
= def
->macroId
;
1011 children
.Append((wxObject
*)chunk
);
1013 // Eliminate newline after a \begin{} or a \\ if possible
1014 if (env
|| strcmp(def
->name
, "\\") == 0)
1015 if (buffer
[pos
] == 13)
1018 if (buffer
[pos
] == 10)
1022 pos
= ParseMacroBody(def
->name
, chunk
, chunk
->no_args
,
1023 buffer
, pos
, env
, tmpParseToBrace
, customMacroArgs
);
1025 // If custom macro, parse the body substituting the above found args.
1028 if (customMacro
->macroBody
)
1031 // strcpy(macroBuf, "{");
1032 strcpy(macroBuf
, customMacro
->macroBody
);
1033 strcat(macroBuf
, "}");
1034 ParseArg(thisArg
, children
, macroBuf
, 0, NULL
, TRUE
, chunk
);
1037 // delete chunk; // Might delete children
1042 MacroError(buffer
+pos
);
1047 // Parse constructs like {\bf thing} as if they were
1052 if (buffer
[pos
] == '\\')
1056 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_STRING
);
1057 BigBuffer
[buf_ptr
] = 0;
1059 chunk
->value
= copystring(BigBuffer
);
1060 children
.Append((wxObject
*)chunk
);
1065 bool tmpParseToBrace
;
1066 TexMacroDef
*def
= MatchMacro(buffer
, &pos
, &env
, &tmpParseToBrace
);
1069 CustomMacro
*customMacro
= FindCustomMacro(def
->name
);
1071 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_MACRO
, def
);
1072 chunk
->no_args
= def
->no_args
;
1073 // chunk->name = copystring(def->name);
1074 chunk
->macroId
= def
->macroId
;
1076 children
.Append((wxObject
*)chunk
);
1078 pos
= ParseMacroBody(def
->name
, chunk
, chunk
->no_args
,
1079 buffer
, pos
, NULL
, TRUE
, customMacroArgs
);
1081 // If custom macro, parse the body substituting the above found args.
1084 if (customMacro
->macroBody
)
1087 // strcpy(macroBuf, "{");
1088 strcpy(macroBuf
, customMacro
->macroBody
);
1089 strcat(macroBuf
, "}");
1090 ParseArg(thisArg
, children
, macroBuf
, 0, NULL
, TRUE
, chunk
);
1093 // delete chunk; // Might delete children
1098 MacroError(buffer
+pos
);
1104 * If all else fails, we assume that we have
1105 * a pair of braces on their own, so return a `dummy' macro
1106 * definition with just one argument to parse.
1110 SoloBlockDef
= new TexMacroDef(ltSOLO_BLOCK
, "solo block", 1, FALSE
);
1115 TexChunk
*chunk1
= new TexChunk(CHUNK_TYPE_STRING
);
1116 BigBuffer
[buf_ptr
] = 0;
1118 chunk1
->value
= copystring(BigBuffer
);
1119 children
.Append((wxObject
*)chunk1
);
1121 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_MACRO
, SoloBlockDef
);
1122 chunk
->no_args
= SoloBlockDef
->no_args
;
1123 // chunk->name = copystring(SoloBlockDef->name);
1124 chunk
->macroId
= SoloBlockDef
->macroId
;
1125 children
.Append((wxObject
*)chunk
);
1127 TexChunk
*arg
= new TexChunk(CHUNK_TYPE_ARG
, SoloBlockDef
);
1129 chunk
->children
.Append((wxObject
*)arg
);
1130 // arg->name = copystring(SoloBlockDef->name);
1132 arg
->macroId
= chunk
->macroId
;
1134 pos
= ParseArg(arg
, arg
->children
, buffer
, pos
, NULL
, TRUE
, customMacroArgs
);
1142 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_STRING
);
1143 BigBuffer
[buf_ptr
] = 0;
1145 chunk
->value
= copystring(BigBuffer
);
1146 children
.Append((wxObject
*)chunk
);
1151 if (buffer
[pos
] == '$')
1153 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_MACRO
);
1155 // chunk->name = copystring("$$");
1156 chunk
->macroId
= ltSPECIALDOUBLEDOLLAR
;
1157 children
.Append((wxObject
*)chunk
);
1162 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_MACRO
);
1164 // chunk->name = copystring("_$");
1165 chunk
->macroId
= ltSPECIALDOLLAR
;
1166 children
.Append((wxObject
*)chunk
);
1174 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_STRING
);
1175 BigBuffer
[buf_ptr
] = 0;
1177 chunk
->value
= copystring(BigBuffer
);
1178 children
.Append((wxObject
*)chunk
);
1182 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_MACRO
);
1184 // chunk->name = copystring("_~");
1185 chunk
->macroId
= ltSPECIALTILDE
;
1186 children
.Append((wxObject
*)chunk
);
1189 case '#': // Either treat as a special TeX character or as a macro arg
1193 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_STRING
);
1194 BigBuffer
[buf_ptr
] = 0;
1196 chunk
->value
= copystring(BigBuffer
);
1197 children
.Append((wxObject
*)chunk
);
1201 if (!customMacroArgs
)
1203 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_MACRO
);
1205 // chunk->name = copystring("_#");
1206 chunk
->macroId
= ltSPECIALHASH
;
1207 children
.Append((wxObject
*)chunk
);
1211 if (isdigit(buffer
[pos
]))
1213 int n
= buffer
[pos
] - 48;
1215 wxNode
*node
= customMacroArgs
->children
.Nth(n
-1);
1218 TexChunk
*argChunk
= (TexChunk
*)node
->Data();
1219 children
.Append((wxObject
*)new TexChunk(*argChunk
));
1227 // Remove white space before and after the ampersand,
1228 // since this is probably a table column separator with
1229 // some convenient -- but useless -- white space in the text.
1230 while ((buf_ptr
> 0) && ((BigBuffer
[buf_ptr
-1] == ' ') || (BigBuffer
[buf_ptr
-1] == 9)))
1235 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_STRING
);
1236 BigBuffer
[buf_ptr
] = 0;
1238 chunk
->value
= copystring(BigBuffer
);
1239 children
.Append((wxObject
*)chunk
);
1244 while (buffer
[pos
] == ' ' || buffer
[pos
] == 9)
1247 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_MACRO
);
1249 // chunk->name = copystring("_&");
1250 chunk
->macroId
= ltSPECIALAMPERSAND
;
1251 children
.Append((wxObject
*)chunk
);
1254 // Eliminate end-of-line comment
1258 while (ch
!= 10 && ch
!= 13 && ch
!= 0)
1263 if (buffer
[pos
] == 10 || buffer
[pos
] == 13)
1266 if (buffer
[pos
] == 10) pos
++; // Eliminate newline following DOS line feed
1273 BigBuffer
[buf_ptr
] = ' ';
1274 BigBuffer
[buf_ptr
+1] = 0;
1281 BigBuffer
[buf_ptr
] = ch
;
1282 BigBuffer
[buf_ptr
+1] = 0;
1293 * Consume as many arguments as the macro definition specifies
1297 int ParseMacroBody(char *macro_name
, TexChunk
*parent
,
1298 int no_args
, char *buffer
, int pos
,
1299 char *environment
, bool parseToBrace
,
1300 TexChunk
*customMacroArgs
)
1303 if (stopRunning
) return pos
;
1305 // Check for a first optional argument
1306 if (buffer
[pos
] == ' ' && buffer
[pos
+1] == '[')
1308 // Fool following code into thinking that this is definitely
1309 // an optional first argument. (If a space before a non-first argument,
1310 // [ is interpreted as a [, not an optional argument.)
1316 if (buffer
[pos
] == '[')
1322 for (i
= 0; i
< no_args
; i
++)
1325 TexChunk
*arg
= new TexChunk(CHUNK_TYPE_ARG
, parent
->def
);
1327 parent
->children
.Append((wxObject
*)arg
);
1328 // arg->name = copystring(macro_name);
1329 arg
->argn
= maxArgs
;
1330 arg
->macroId
= parent
->macroId
;
1332 // To parse the first arg of a 2 arg \begin{thing}{arg} ... \end{thing}
1333 // have to fool parser into thinking this is a regular kind of block.
1335 if ((no_args
== 2) && (i
== 0))
1338 actualEnv
= environment
;
1340 bool isOptional
= FALSE
;
1342 // Remove the first { of the argument so it doesn't get recognized as { ... }
1343 // EatWhiteSpace(buffer, &pos);
1346 // The reason for these tests is to not consume braces that don't
1347 // belong to this macro.
1348 // E.g. {\bf {\small thing}}
1349 if ((pos
> 0) && (buffer
[pos
-1] != ' ') && buffer
[pos
] == '{')
1352 if ((pos
> 0) && (buffer
[pos
-1] != ' ') && (buffer
[pos
] == '['))
1357 else if ((pos
> 1) && (buffer
[pos
-1] != ' ') && (buffer
[pos
+1] == '['))
1363 arg
->optional
= isOptional
;
1365 pos
= ParseArg(arg
, arg
->children
, buffer
, pos
, actualEnv
, parseToBrace
, customMacroArgs
);
1367 // If we've encountered an OPTIONAL argument, go another time around
1368 // the loop, because we've got more than we thought.
1369 // Hopefully optional args don't occur at the end of a macro use
1370 // or we might miss it.
1371 // Don't increment no of times round loop if the first optional arg
1372 // -- we already did it before the loop.
1373 if (arg
->optional
&& (i
> 0))
1376 parent
->no_args
= maxArgs
;
1378 // Tell each argument how many args there are (useful when processing an arg)
1379 wxNode
*node
= parent
->children
.First();
1382 TexChunk
*chunk
= (TexChunk
*)node
->Data();
1383 chunk
->no_args
= maxArgs
;
1384 node
= node
->Next();
1389 bool TexLoadFile(char *filename
)
1391 stopRunning
= FALSE
;
1392 strcpy(TexFileRoot
, filename
);
1393 StripExtension(TexFileRoot
);
1394 sprintf(TexBibName
, "%s.bb", TexFileRoot
);
1395 sprintf(TexTmpBibName
, "%s.bb1", TexFileRoot
);
1397 TexPathList
.EnsureFileAccessible(filename
);
1400 static char *line_buffer
= new char[600];
1402 static char *line_buffer
= new char[11000];
1405 Inputs
[0] = fopen(filename
, "r");
1407 FileNames
[0] = copystring(filename
);
1410 read_a_line(line_buffer
);
1411 ParseMacroBody("toplevel", TopLevel
, 1, line_buffer
, 0, NULL
, TRUE
);
1412 if (Inputs
[0]) fclose(Inputs
[0]);
1418 TexMacroDef::TexMacroDef(int the_id
, char *the_name
, int n
, bool ig
, bool forbidLevel
)
1420 name
= copystring(the_name
);
1424 forbidden
= forbidLevel
;
1427 TexMacroDef::~TexMacroDef(void)
1429 if (name
) delete[] name
;
1432 TexChunk::TexChunk(int the_type
, TexMacroDef
*the_def
)
1444 TexChunk::TexChunk(TexChunk
& toCopy
)
1447 no_args
= toCopy
.no_args
;
1449 macroId
= toCopy
.macroId
;
1452 // name = copystring(toCopy.name);
1458 value
= copystring(toCopy
.value
);
1462 optional
= toCopy
.optional
;
1463 wxNode
*node
= toCopy
.children
.First();
1466 TexChunk
*child
= (TexChunk
*)node
->Data();
1467 children
.Append((wxObject
*)new TexChunk(*child
));
1468 node
= node
->Next();
1472 TexChunk::~TexChunk(void)
1474 // if (name) delete[] name;
1475 if (value
) delete[] value
;
1476 wxNode
*node
= children
.First();
1479 TexChunk
*child
= (TexChunk
*)node
->Data();
1481 wxNode
*next
= node
->Next();
1487 bool IsArgOptional(void) // Is this argument an optional argument?
1489 return isArgOptional
;
1492 int GetNoArgs(void) // Number of args for this macro
1497 /* Gets the text of a chunk on request (must be for small arguments
1502 void GetArgData1(TexChunk
*chunk
)
1504 switch (chunk
->type
)
1506 case CHUNK_TYPE_MACRO
:
1508 TexMacroDef
*def
= chunk
->def
;
1509 if (def
&& def
->ignore
)
1512 if (def
&& (strcmp(def
->name
, "solo block") != 0))
1514 strcat(currentArgData
, "\\");
1515 strcat(currentArgData
, def
->name
);
1518 wxNode
*node
= chunk
->children
.First();
1521 TexChunk
*child_chunk
= (TexChunk
*)node
->Data();
1522 strcat(currentArgData
, "{");
1523 GetArgData1(child_chunk
);
1524 strcat(currentArgData
, "}");
1525 node
= node
->Next();
1529 case CHUNK_TYPE_ARG
:
1531 wxNode
*node
= chunk
->children
.First();
1534 TexChunk
*child_chunk
= (TexChunk
*)node
->Data();
1535 GetArgData1(child_chunk
);
1536 node
= node
->Next();
1540 case CHUNK_TYPE_STRING
:
1543 strcat(currentArgData
, chunk
->value
);
1549 char *GetArgData(TexChunk
*chunk
)
1551 currentArgData
[0] = 0;
1552 GetArgData1(currentArgument
);
1553 haveArgData
= FALSE
;
1554 return currentArgData
;
1557 char *GetArgData(void)
1561 currentArgData
[0] = 0;
1562 GetArgData1(currentArgument
);
1564 return currentArgData
;
1567 TexChunk
*GetArgChunk(void)
1569 return currentArgument
;
1572 TexChunk
*GetNextChunk(void) // Look ahead to the next chunk
1577 TexChunk
*GetTopLevelChunk(void)
1582 int GetCurrentColumn(void)
1584 return currentColumn
;
1588 * Traverses document calling functions to allow the client to
1589 * write out the appropriate stuff
1593 void TraverseFromChunk(TexChunk
*chunk
, wxNode
*thisNode
, bool childrenOnly
)
1596 if (stopRunning
) return;
1598 switch (chunk
->type
)
1600 case CHUNK_TYPE_MACRO
:
1602 TexMacroDef
*def
= chunk
->def
;
1603 if (def
&& def
->ignore
)
1607 OnMacro(chunk
->macroId
, chunk
->no_args
, TRUE
);
1609 wxNode
*node
= chunk
->children
.First();
1612 TexChunk
*child_chunk
= (TexChunk
*)node
->Data();
1613 TraverseFromChunk(child_chunk
, node
);
1614 node
= node
->Next();
1617 if (thisNode
&& thisNode
->Next()) nextChunk
= (TexChunk
*)thisNode
->Next()->Data();
1620 OnMacro(chunk
->macroId
, chunk
->no_args
, FALSE
);
1623 case CHUNK_TYPE_ARG
:
1625 currentArgument
= chunk
;
1627 isArgOptional
= chunk
->optional
;
1628 noArgs
= chunk
->no_args
;
1630 // If OnArgument returns FALSE, don't output.
1632 if (childrenOnly
|| OnArgument(chunk
->macroId
, chunk
->argn
, TRUE
))
1634 wxNode
*node
= chunk
->children
.First();
1637 TexChunk
*child_chunk
= (TexChunk
*)node
->Data();
1638 TraverseFromChunk(child_chunk
, node
);
1639 node
= node
->Next();
1643 currentArgument
= chunk
;
1645 if (thisNode
&& thisNode
->Next()) nextChunk
= (TexChunk
*)thisNode
->Next()->Data();
1647 isArgOptional
= chunk
->optional
;
1648 noArgs
= chunk
->no_args
;
1651 (void)OnArgument(chunk
->macroId
, chunk
->argn
, FALSE
);
1654 case CHUNK_TYPE_STRING
:
1656 extern int issuedNewParagraph
;
1657 extern int forbidResetPar
;
1658 if (chunk
->value
&& (forbidResetPar
== 0))
1660 // If non-whitespace text, we no longer have a new paragraph.
1661 if (issuedNewParagraph
&& !((chunk
->value
[0] == 10 || chunk
->value
[0] == 13 || chunk
->value
[0] == 32)
1662 && chunk
->value
[1] == 0))
1663 issuedNewParagraph
= FALSE
;
1664 TexOutput(chunk
->value
, TRUE
);
1671 void TraverseDocument(void)
1673 TraverseFromChunk(TopLevel
, NULL
);
1676 void SetCurrentOutput(FILE *fd
)
1678 CurrentOutput1
= fd
;
1679 CurrentOutput2
= NULL
;
1682 void SetCurrentOutputs(FILE *fd1
, FILE *fd2
)
1684 CurrentOutput1
= fd1
;
1685 CurrentOutput2
= fd2
;
1688 void AddMacroDef(int the_id
, char *name
, int n
, bool ignore
, bool forbid
)
1690 MacroDefs
.Put(name
, new TexMacroDef(the_id
, name
, n
, ignore
, forbid
));
1693 void TexInitialize(int bufSize
)
1695 InitialiseColourTable();
1697 TexPathList
.AddEnvList("TEXINPUT");
1700 TexPathList
.AddEnvList("TEXINPUTS");
1703 for (i
= 0; i
< 15; i
++)
1707 FileNames
[i
] = NULL
;
1710 IgnorableInputFiles
.Add("psbox.tex");
1711 BigBuffer
= new char[(bufSize
*1000)];
1712 currentArgData
= new char[2000];
1713 TexFileRoot
= new char[300];
1714 TexBibName
= new char[300];
1715 TexTmpBibName
= new char[300];
1716 AddMacroDef(ltTOPLEVEL
, "toplevel", 1);
1717 TopLevel
= new TexChunk(CHUNK_TYPE_MACRO
);
1718 // TopLevel->name = copystring("toplevel");
1719 TopLevel
->macroId
= ltTOPLEVEL
;
1720 TopLevel
->no_args
= 1;
1721 VerbatimMacroDef
= (TexMacroDef
*)MacroDefs
.Get("verbatim");
1724 void TexCleanUp(void)
1727 for (i
= 0; i
< 15; i
++)
1733 subsubsectionNo
= 0;
1736 CurrentOutput1
= NULL
;
1737 CurrentOutput2
= NULL
;
1738 CurrentInputIndex
= 0;
1739 haveArgData
= FALSE
;
1744 TopLevel
= new TexChunk(CHUNK_TYPE_MACRO
);
1745 // TopLevel->name = copystring("toplevel");
1746 TopLevel
->macroId
= ltTOPLEVEL
;
1747 TopLevel
->no_args
= 1;
1749 DocumentTitle
= NULL
;
1750 DocumentAuthor
= NULL
;
1751 DocumentDate
= NULL
;
1752 DocumentStyle
= LATEX_REPORT
;
1753 MinorDocumentStyle
= 0;
1754 BibliographyStyleString
= copystring("plain");
1755 DocumentStyleString
= copystring("report");
1756 MinorDocumentStyleString
= NULL
;
1757 /* Don't want to remove custom macros after each pass.
1759 wxNode *node = CustomMacroList.First();
1762 CustomMacro *macro = (CustomMacro *)node->Data();
1765 node = CustomMacroList.First();
1768 TexReferences
.BeginFind();
1769 wxNode
*node
= TexReferences
.Next();
1772 TexRef
*ref
= (TexRef
*)node
->Data();
1774 node
= TexReferences
.Next();
1776 TexReferences
.Clear();
1778 node
= BibList
.First();
1781 BibEntry
*entry
= (BibEntry
*)node
->Data();
1784 node
= BibList
.First();
1786 CitationList
.Clear();
1787 ResetTopicCounter();
1790 // There is likely to be one set of macros used by all utilities.
1791 void DefineDefaultMacros(void)
1793 // Put names which subsume other names at the TOP
1794 // so they get recognized first
1796 AddMacroDef(ltACCENT_GRAVE
, "`", 1);
1797 AddMacroDef(ltACCENT_ACUTE
, "'", 1);
1798 AddMacroDef(ltACCENT_CARET
, "^", 1);
1799 AddMacroDef(ltACCENT_UMLAUT
, "\"", 1);
1800 AddMacroDef(ltACCENT_TILDE
, "~", 1);
1801 AddMacroDef(ltACCENT_DOT
, ".", 1);
1802 AddMacroDef(ltACCENT_CADILLA
, "c", 1);
1803 AddMacroDef(ltSMALLSPACE1
, ",", 0);
1804 AddMacroDef(ltSMALLSPACE2
, ";", 0);
1806 AddMacroDef(ltABSTRACT
, "abstract", 1);
1807 AddMacroDef(ltADDCONTENTSLINE
, "addcontentsline", 3);
1808 AddMacroDef(ltADDTOCOUNTER
, "addtocounter", 2);
1809 AddMacroDef(ltALEPH
, "aleph", 0);
1810 AddMacroDef(ltALPHA
, "alpha", 0);
1811 AddMacroDef(ltALPH1
, "alph", 1);
1812 AddMacroDef(ltALPH2
, "Alph", 1);
1813 AddMacroDef(ltANGLE
, "angle", 0);
1814 AddMacroDef(ltAPPENDIX
, "appendix", 0);
1815 AddMacroDef(ltAPPROX
, "approx", 0);
1816 AddMacroDef(ltARABIC
, "arabic", 1);
1817 AddMacroDef(ltARRAY
, "array", 1);
1818 AddMacroDef(ltAST
, "ast", 0);
1819 AddMacroDef(ltASYMP
, "asymp", 0);
1820 AddMacroDef(ltAUTHOR
, "author", 1);
1822 AddMacroDef(ltBACKGROUNDCOLOUR
, "backgroundcolour", 1);
1823 AddMacroDef(ltBACKGROUNDIMAGE
, "backgroundimage", 1);
1824 AddMacroDef(ltBACKGROUND
, "background", 1);
1825 AddMacroDef(ltBACKSLASHRAW
, "backslashraw", 0);
1826 AddMacroDef(ltBACKSLASH
, "backslash", 0);
1827 AddMacroDef(ltBASELINESKIP
, "baselineskip", 1);
1828 AddMacroDef(ltBCOL
, "bcol", 2);
1829 AddMacroDef(ltBETA
, "beta", 0);
1830 AddMacroDef(ltBFSERIES
, "bfseries", 1);
1831 AddMacroDef(ltBF
, "bf", 1);
1832 AddMacroDef(ltBIBITEM
, "bibitem", 2); // For convenience, bibitem has 2 args: label and item.
1833 // The Latex syntax permits writing as 2 args.
1834 AddMacroDef(ltBIBLIOGRAPHYSTYLE
, "bibliographystyle", 1);
1835 AddMacroDef(ltBIBLIOGRAPHY
, "bibliography", 1);
1836 AddMacroDef(ltBIGTRIANGLEDOWN
, "bigtriangledown", 0);
1837 AddMacroDef(ltBOT
, "bot", 0);
1838 AddMacroDef(ltBOXIT
, "boxit", 1);
1839 AddMacroDef(ltBOX
, "box", 0);
1840 AddMacroDef(ltBRCLEAR
, "brclear", 0);
1841 AddMacroDef(ltBULLET
, "bullet", 0);
1843 AddMacroDef(ltCAPTIONSTAR
, "caption*", 1);
1844 AddMacroDef(ltCAPTION
, "caption", 1);
1845 AddMacroDef(ltCAP
, "cap", 0);
1846 AddMacroDef(ltCDOTS
, "cdots", 0);
1847 AddMacroDef(ltCDOT
, "cdot", 0);
1848 AddMacroDef(ltCENTERLINE
, "centerline", 1);
1849 AddMacroDef(ltCENTERING
, "centering", 0);
1850 AddMacroDef(ltCENTER
, "center", 1);
1851 AddMacroDef(ltCEXTRACT
, "cextract", 0);
1852 AddMacroDef(ltCHAPTERHEADING
, "chapterheading", 1);
1853 AddMacroDef(ltCHAPTERSTAR
, "chapter*", 1);
1854 AddMacroDef(ltCHAPTER
, "chapter", 1);
1855 AddMacroDef(ltCHI
, "chi", 0);
1856 AddMacroDef(ltCINSERT
, "cinsert", 0);
1857 AddMacroDef(ltCIRC
, "circ", 0);
1858 AddMacroDef(ltCITE
, "cite", 1);
1859 AddMacroDef(ltCLASS
, "class", 1);
1860 AddMacroDef(ltCLEARDOUBLEPAGE
, "cleardoublepage", 0);
1861 AddMacroDef(ltCLEARPAGE
, "clearpage", 0);
1862 AddMacroDef(ltCLINE
, "cline", 1);
1863 AddMacroDef(ltCLIPSFUNC
, "clipsfunc", 3);
1864 AddMacroDef(ltCLUBSUIT
, "clubsuit", 0);
1865 AddMacroDef(ltCOLUMNSEP
, "columnsep", 1);
1866 AddMacroDef(ltCOMMENT
, "comment", 1, TRUE
);
1867 AddMacroDef(ltCONG
, "cong", 0);
1868 AddMacroDef(ltCOPYRIGHT
, "copyright", 0);
1869 AddMacroDef(ltCPARAM
, "cparam", 2);
1870 AddMacroDef(ltCHEAD
, "chead", 1);
1871 AddMacroDef(ltCFOOT
, "cfoot", 1);
1872 AddMacroDef(ltCUP
, "cup", 0);
1874 AddMacroDef(ltDASHV
, "dashv", 0);
1875 AddMacroDef(ltDATE
, "date", 1);
1876 AddMacroDef(ltDELTA
, "delta", 0);
1877 AddMacroDef(ltCAP_DELTA
, "Delta", 0);
1878 AddMacroDef(ltDEFINECOLOUR
, "definecolour", 4);
1879 AddMacroDef(ltDEFINECOLOR
, "definecolor", 4);
1880 AddMacroDef(ltDESCRIPTION
, "description", 1);
1881 AddMacroDef(ltDESTRUCT
, "destruct", 1);
1882 AddMacroDef(ltDIAMOND2
, "diamond2", 0);
1883 AddMacroDef(ltDIAMOND
, "diamond", 0);
1884 AddMacroDef(ltDIV
, "div", 0);
1885 AddMacroDef(ltDOCUMENTCLASS
, "documentclass", 1);
1886 AddMacroDef(ltDOCUMENTSTYLE
, "documentstyle", 1);
1887 AddMacroDef(ltDOCUMENT
, "document", 1);
1888 AddMacroDef(ltDOUBLESPACE
, "doublespace", 1);
1889 AddMacroDef(ltDOTEQ
, "doteq", 0);
1890 AddMacroDef(ltDOWNARROW
, "downarrow", 0);
1891 AddMacroDef(ltDOWNARROW2
, "Downarrow", 0);
1893 AddMacroDef(ltEMPTYSET
, "emptyset", 0);
1894 AddMacroDef(ltEMPH
, "emph", 1);
1895 AddMacroDef(ltEM
, "em", 1);
1896 AddMacroDef(ltENUMERATE
, "enumerate", 1);
1897 AddMacroDef(ltEPSILON
, "epsilon", 0);
1898 AddMacroDef(ltEQUATION
, "equation", 1);
1899 AddMacroDef(ltEQUIV
, "equiv", 0);
1900 AddMacroDef(ltETA
, "eta", 0);
1901 AddMacroDef(ltEVENSIDEMARGIN
, "evensidemargin", 1);
1902 AddMacroDef(ltEXISTS
, "exists", 0);
1904 AddMacroDef(ltFBOX
, "fbox", 1);
1905 AddMacroDef(ltFCOL
, "fcol", 2);
1906 AddMacroDef(ltFIGURE
, "figure", 1);
1907 AddMacroDef(ltFIGURESTAR
, "figure*", 1);
1908 AddMacroDef(ltFLUSHLEFT
, "flushleft", 1);
1909 AddMacroDef(ltFLUSHRIGHT
, "flushright", 1);
1910 AddMacroDef(ltFOLLOWEDLINKCOLOUR
, "followedlinkcolour", 1);
1911 AddMacroDef(ltFOOTHEIGHT
, "footheight", 1);
1912 AddMacroDef(ltFOOTNOTEPOPUP
, "footnotepopup", 2);
1913 AddMacroDef(ltFOOTNOTE
, "footnote", 1);
1914 AddMacroDef(ltFOOTSKIP
, "footskip", 1);
1915 AddMacroDef(ltFORALL
, "forall", 0);
1916 AddMacroDef(ltFRAMEBOX
, "framebox", 1);
1917 AddMacroDef(ltFROWN
, "frown", 0);
1918 AddMacroDef(ltFUNCTIONSECTION
, "functionsection", 1);
1919 AddMacroDef(ltFUNC
, "func", 3);
1920 AddMacroDef(ltFOOTNOTESIZE
, "footnotesize", 0);
1921 AddMacroDef(ltFANCYPLAIN
, "fancyplain", 2);
1923 AddMacroDef(ltGAMMA
, "gamma", 0);
1924 AddMacroDef(ltCAP_GAMMA
, "Gamma", 0);
1925 AddMacroDef(ltGEQ
, "geq", 0);
1926 AddMacroDef(ltGE
, "ge", 0);
1927 AddMacroDef(ltGG
, "gg", 0);
1928 AddMacroDef(ltGLOSSARY
, "glossary", 1);
1929 AddMacroDef(ltGLOSS
, "gloss", 1);
1931 AddMacroDef(ltHEADHEIGHT
, "headheight", 1);
1932 AddMacroDef(ltHEARTSUIT
, "heartsuit", 0);
1933 AddMacroDef(ltHELPGLOSSARY
, "helpglossary", 1);
1934 AddMacroDef(ltHELPIGNORE
, "helpignore", 1, TRUE
);
1935 AddMacroDef(ltHELPONLY
, "helponly", 1);
1936 AddMacroDef(ltHELPINPUT
, "helpinput", 1);
1937 AddMacroDef(ltHELPFONTFAMILY
, "helpfontfamily", 1);
1938 AddMacroDef(ltHELPFONTSIZE
, "helpfontsize", 1);
1939 AddMacroDef(ltHELPREFN
, "helprefn", 2);
1940 AddMacroDef(ltHELPREF
, "helpref", 2);
1941 AddMacroDef(ltHFILL
, "hfill", 0);
1942 AddMacroDef(ltHLINE
, "hline", 0);
1943 AddMacroDef(ltHRULE
, "hrule", 0);
1944 AddMacroDef(ltHSPACESTAR
, "hspace*", 1);
1945 AddMacroDef(ltHSPACE
, "hspace", 1);
1946 AddMacroDef(ltHSKIPSTAR
, "hskip*", 1);
1947 AddMacroDef(ltHSKIP
, "hskip", 1);
1948 AddMacroDef(lthuge
, "huge", 1);
1949 AddMacroDef(ltHuge
, "Huge", 1);
1950 AddMacroDef(ltHUGE
, "HUGE", 1);
1951 AddMacroDef(ltHTMLIGNORE
, "htmlignore", 1);
1952 AddMacroDef(ltHTMLONLY
, "htmlonly", 1);
1954 AddMacroDef(ltIM
, "im", 0);
1955 AddMacroDef(ltINCLUDEONLY
, "includeonly", 1);
1956 AddMacroDef(ltINCLUDE
, "include", 1);
1957 AddMacroDef(ltINDENTED
, "indented", 2);
1958 AddMacroDef(ltINDEX
, "index", 1);
1959 AddMacroDef(ltINPUT
, "input", 1, TRUE
);
1960 AddMacroDef(ltIOTA
, "iota", 0);
1961 AddMacroDef(ltITEMIZE
, "itemize", 1);
1962 AddMacroDef(ltITEM
, "item", 0);
1963 AddMacroDef(ltIMAGEMAP
, "imagemap", 3);
1964 AddMacroDef(ltIMAGEL
, "imagel", 2);
1965 AddMacroDef(ltIMAGER
, "imager", 2);
1966 AddMacroDef(ltIMAGE
, "image", 2);
1967 AddMacroDef(ltIN
, "in", 0);
1968 AddMacroDef(ltINFTY
, "infty", 0);
1969 AddMacroDef(ltITSHAPE
, "itshape", 1);
1970 AddMacroDef(ltIT
, "it", 1);
1971 AddMacroDef(ltITEMSEP
, "itemsep", 1);
1972 AddMacroDef(ltINSERTATLEVEL
, "insertatlevel", 2);
1974 AddMacroDef(ltKAPPA
, "kappa", 0);
1975 AddMacroDef(ltKILL
, "kill", 0);
1977 AddMacroDef(ltLABEL
, "label", 1);
1978 AddMacroDef(ltLAMBDA
, "lambda", 0);
1979 AddMacroDef(ltCAP_LAMBDA
, "Lambda", 0);
1980 AddMacroDef(ltlarge
, "large", 1);
1981 AddMacroDef(ltLarge
, "Large", 1);
1982 AddMacroDef(ltLARGE
, "LARGE", 1);
1983 AddMacroDef(ltLATEXIGNORE
, "latexignore", 1);
1984 AddMacroDef(ltLATEXONLY
, "latexonly", 1);
1985 AddMacroDef(ltLATEX
, "LaTeX", 0);
1986 AddMacroDef(ltLBOX
, "lbox", 1);
1987 AddMacroDef(ltLBRACERAW
, "lbraceraw", 0);
1988 AddMacroDef(ltLDOTS
, "ldots", 0);
1989 AddMacroDef(ltLEQ
, "leq", 0);
1990 AddMacroDef(ltLE
, "le", 0);
1991 AddMacroDef(ltLEFTARROW
, "leftarrow", 0);
1992 AddMacroDef(ltLEFTRIGHTARROW
, "leftrightarrow", 0);
1993 AddMacroDef(ltLEFTARROW2
, "Leftarrow", 0);
1994 AddMacroDef(ltLEFTRIGHTARROW2
, "Leftrightarrow", 0);
1995 AddMacroDef(ltLINEBREAK
, "linebreak", 0);
1996 AddMacroDef(ltLINKCOLOUR
, "linkcolour", 1);
1997 AddMacroDef(ltLISTOFFIGURES
, "listoffigures", 0);
1998 AddMacroDef(ltLISTOFTABLES
, "listoftables", 0);
1999 AddMacroDef(ltLHEAD
, "lhead", 1);
2000 AddMacroDef(ltLFOOT
, "lfoot", 1);
2001 AddMacroDef(ltLOWERCASE
, "lowercase", 1);
2002 AddMacroDef(ltLL
, "ll", 0);
2004 AddMacroDef(ltMAKEGLOSSARY
, "makeglossary", 0);
2005 AddMacroDef(ltMAKEINDEX
, "makeindex", 0);
2006 AddMacroDef(ltMAKETITLE
, "maketitle", 0);
2007 AddMacroDef(ltMARKRIGHT
, "markright", 1);
2008 AddMacroDef(ltMARKBOTH
, "markboth", 2);
2009 AddMacroDef(ltMARGINPARWIDTH
, "marginparwidth", 1);
2010 AddMacroDef(ltMARGINPARSEP
, "marginparsep", 1);
2011 AddMacroDef(ltMARGINPARODD
, "marginparodd", 1);
2012 AddMacroDef(ltMARGINPAREVEN
, "marginpareven", 1);
2013 AddMacroDef(ltMARGINPAR
, "marginpar", 1);
2014 AddMacroDef(ltMBOX
, "mbox", 1);
2015 AddMacroDef(ltMDSERIES
, "mdseries", 1);
2016 AddMacroDef(ltMEMBERSECTION
, "membersection", 1);
2017 AddMacroDef(ltMEMBER
, "member", 2);
2018 AddMacroDef(ltMID
, "mid", 0);
2019 AddMacroDef(ltMODELS
, "models", 0);
2020 AddMacroDef(ltMP
, "mp", 0);
2021 AddMacroDef(ltMULTICOLUMN
, "multicolumn", 3);
2022 AddMacroDef(ltMU
, "mu", 0);
2024 AddMacroDef(ltNABLA
, "nabla", 0);
2025 AddMacroDef(ltNEG
, "neg", 0);
2026 AddMacroDef(ltNEQ
, "neq", 0);
2027 AddMacroDef(ltNEWCOUNTER
, "newcounter", 1, FALSE
, FORBID_ABSOLUTELY
);
2028 AddMacroDef(ltNEWLINE
, "newline", 0);
2029 AddMacroDef(ltNEWPAGE
, "newpage", 0);
2030 AddMacroDef(ltNI
, "ni", 0);
2031 AddMacroDef(ltNOCITE
, "nocite", 1);
2032 AddMacroDef(ltNOINDENT
, "noindent", 0);
2033 AddMacroDef(ltNOLINEBREAK
, "nolinebreak", 0);
2034 AddMacroDef(ltNOPAGEBREAK
, "nopagebreak", 0);
2035 AddMacroDef(ltNORMALSIZE
, "normalsize", 1);
2036 AddMacroDef(ltNORMALBOX
, "normalbox", 1);
2037 AddMacroDef(ltNORMALBOXD
, "normalboxd", 1);
2038 AddMacroDef(ltNOTEQ
, "noteq", 0);
2039 AddMacroDef(ltNOTIN
, "notin", 0);
2040 AddMacroDef(ltNOTSUBSET
, "notsubset", 0);
2041 AddMacroDef(ltNU
, "nu", 0);
2043 AddMacroDef(ltODDSIDEMARGIN
, "oddsidemargin", 1);
2044 AddMacroDef(ltOMEGA
, "omega", 0);
2045 AddMacroDef(ltCAP_OMEGA
, "Omega", 0);
2046 AddMacroDef(ltONECOLUMN
, "onecolumn", 0);
2047 AddMacroDef(ltOPLUS
, "oplus", 0);
2048 AddMacroDef(ltOSLASH
, "oslash", 0);
2049 AddMacroDef(ltOTIMES
, "otimes", 0);
2051 AddMacroDef(ltPAGEBREAK
, "pagebreak", 0);
2052 AddMacroDef(ltPAGEREF
, "pageref", 1);
2053 AddMacroDef(ltPAGESTYLE
, "pagestyle", 1);
2054 AddMacroDef(ltPAGENUMBERING
, "pagenumbering", 1);
2055 AddMacroDef(ltPARAGRAPHSTAR
, "paragraph*", 1);
2056 AddMacroDef(ltPARAGRAPH
, "paragraph", 1);
2057 AddMacroDef(ltPARALLEL
, "parallel", 0);
2058 AddMacroDef(ltPARAM
, "param", 2);
2059 AddMacroDef(ltPARINDENT
, "parindent", 1);
2060 AddMacroDef(ltPARSKIP
, "parskip", 1);
2061 AddMacroDef(ltPARTIAL
, "partial", 0);
2062 AddMacroDef(ltPARTSTAR
, "part*", 1);
2063 AddMacroDef(ltPART
, "part", 1);
2064 AddMacroDef(ltPAR
, "par", 0);
2065 AddMacroDef(ltPERP
, "perp", 0);
2066 AddMacroDef(ltPHI
, "phi", 0);
2067 AddMacroDef(ltCAP_PHI
, "Phi", 0);
2068 AddMacroDef(ltPFUNC
, "pfunc", 3);
2069 AddMacroDef(ltPICTURE
, "picture", 1);
2070 AddMacroDef(ltPI
, "pi", 0);
2071 AddMacroDef(ltCAP_PI
, "Pi", 0);
2072 AddMacroDef(ltPM
, "pm", 0);
2073 AddMacroDef(ltPOPREFONLY
, "poprefonly", 1);
2074 AddMacroDef(ltPOPREF
, "popref", 2);
2075 AddMacroDef(ltPOUNDS
, "pounds", 0);
2076 AddMacroDef(ltPREC
, "prec", 0);
2077 AddMacroDef(ltPRECEQ
, "preceq", 0);
2078 AddMacroDef(ltPRINTINDEX
, "printindex", 0);
2079 AddMacroDef(ltPROPTO
, "propto", 0);
2080 AddMacroDef(ltPSBOXTO
, "psboxto", 1, FALSE
, FORBID_ABSOLUTELY
);
2081 AddMacroDef(ltPSBOX
, "psbox", 1, FALSE
, FORBID_ABSOLUTELY
);
2082 AddMacroDef(ltPSI
, "psi", 0);
2083 AddMacroDef(ltCAP_PSI
, "Psi", 0);
2085 AddMacroDef(ltQUOTE
, "quote", 1);
2086 AddMacroDef(ltQUOTATION
, "quotation", 1);
2088 AddMacroDef(ltRAGGEDBOTTOM
, "raggedbottom", 0);
2089 AddMacroDef(ltRAGGEDLEFT
, "raggedleft", 0);
2090 AddMacroDef(ltRAGGEDRIGHT
, "raggedright", 0);
2091 AddMacroDef(ltRBRACERAW
, "rbraceraw", 0);
2092 AddMacroDef(ltREF
, "ref", 1);
2093 AddMacroDef(ltREGISTERED
, "registered", 0);
2094 AddMacroDef(ltRE
, "we", 0);
2095 AddMacroDef(ltRHO
, "rho", 0);
2096 AddMacroDef(ltRIGHTARROW
, "rightarrow", 0);
2097 AddMacroDef(ltRIGHTARROW2
, "rightarrow2", 0);
2098 AddMacroDef(ltRMFAMILY
, "rmfamily", 1);
2099 AddMacroDef(ltRM
, "rm", 1);
2100 AddMacroDef(ltROMAN
, "roman", 1);
2101 AddMacroDef(ltROMAN2
, "Roman", 1);
2102 // AddMacroDef(lt"row", 1);
2103 AddMacroDef(ltRTFSP
, "rtfsp", 0);
2104 AddMacroDef(ltRTFIGNORE
, "rtfignore", 1);
2105 AddMacroDef(ltRTFONLY
, "rtfonly", 1);
2106 AddMacroDef(ltRULEDROW
, "ruledrow", 1);
2107 AddMacroDef(ltDRULED
, "druled", 1);
2108 AddMacroDef(ltRULE
, "rule", 2);
2109 AddMacroDef(ltRHEAD
, "rhead", 1);
2110 AddMacroDef(ltRFOOT
, "rfoot", 1);
2111 AddMacroDef(ltROW
, "row", 1);
2113 AddMacroDef(ltSCSHAPE
, "scshape", 1);
2114 AddMacroDef(ltSC
, "sc", 1);
2115 AddMacroDef(ltSECTIONHEADING
, "sectionheading", 1);
2116 AddMacroDef(ltSECTIONSTAR
, "section*", 1);
2117 AddMacroDef(ltSECTION
, "section", 1);
2118 AddMacroDef(ltSETCOUNTER
, "setcounter", 2);
2119 AddMacroDef(ltSFFAMILY
, "sffamily", 1);
2120 AddMacroDef(ltSF
, "sf", 1);
2121 AddMacroDef(ltSHARP
, "sharp", 0);
2122 AddMacroDef(ltSHORTCITE
, "shortcite", 1);
2123 AddMacroDef(ltSIGMA
, "sigma", 0);
2124 AddMacroDef(ltCAP_SIGMA
, "Sigma", 0);
2125 AddMacroDef(ltSIM
, "sim", 0);
2126 AddMacroDef(ltSIMEQ
, "simeq", 0);
2127 AddMacroDef(ltSINGLESPACE
, "singlespace", 1);
2128 AddMacroDef(ltSIZEDBOX
, "sizedbox", 2);
2129 AddMacroDef(ltSIZEDBOXD
, "sizedboxd", 2);
2130 AddMacroDef(ltSLOPPYPAR
, "sloppypar", 1);
2131 AddMacroDef(ltSLOPPY
, "sloppy", 0);
2132 AddMacroDef(ltSLSHAPE
, "slshape", 1);
2133 AddMacroDef(ltSL
, "sl", 1);
2134 AddMacroDef(ltSMALL
, "small", 1);
2135 AddMacroDef(ltSMILE
, "smile", 0);
2136 AddMacroDef(ltSS
, "ss", 0);
2137 AddMacroDef(ltSTAR
, "star", 0);
2138 AddMacroDef(ltSUBITEM
, "subitem", 0);
2139 AddMacroDef(ltSUBPARAGRAPHSTAR
, "subparagraph*", 1);
2140 AddMacroDef(ltSUBPARAGRAPH
, "subparagraph", 1);
2141 AddMacroDef(ltSPECIAL
, "special", 1);
2142 AddMacroDef(ltSUBSECTIONSTAR
, "subsection*", 1);
2143 AddMacroDef(ltSUBSECTION
, "subsection", 1);
2144 AddMacroDef(ltSUBSETEQ
, "subseteq", 0);
2145 AddMacroDef(ltSUBSET
, "subset", 0);
2146 AddMacroDef(ltSUCC
, "succ", 0);
2147 AddMacroDef(ltSUCCEQ
, "succeq", 0);
2148 AddMacroDef(ltSUPSETEQ
, "supseteq", 0);
2149 AddMacroDef(ltSUPSET
, "supset", 0);
2150 AddMacroDef(ltSUBSUBSECTIONSTAR
,"subsubsection*", 1);
2151 AddMacroDef(ltSUBSUBSECTION
, "subsubsection", 1);
2152 AddMacroDef(ltSUPERTABULAR
, "supertabular", 2, FALSE
);
2153 AddMacroDef(ltSURD
, "surd", 0);
2154 AddMacroDef(ltSCRIPTSIZE
, "scriptsize", 1);
2155 AddMacroDef(ltSETHEADER
, "setheader", 6);
2156 AddMacroDef(ltSETFOOTER
, "setfooter", 6);
2157 AddMacroDef(ltSETHOTSPOTCOLOUR
, "sethotspotcolour", 1);
2158 AddMacroDef(ltSETHOTSPOTCOLOR
, "sethotspotcolor", 1);
2159 AddMacroDef(ltSETHOTSPOTUNDERLINE
, "sethotspotunderline", 1);
2160 AddMacroDef(ltSETTRANSPARENCY
, "settransparency", 1);
2161 AddMacroDef(ltSPADESUIT
, "spadesuit", 0);
2163 AddMacroDef(ltTABBING
, "tabbing", 2);
2164 AddMacroDef(ltTABLEOFCONTENTS
, "tableofcontents", 0);
2165 AddMacroDef(ltTABLE
, "table", 1);
2166 AddMacroDef(ltTABULAR
, "tabular", 2, FALSE
);
2167 AddMacroDef(ltTAB
, "tab", 0);
2168 AddMacroDef(ltTAU
, "tau", 0);
2169 AddMacroDef(ltTEXTRM
, "textrm", 1);
2170 AddMacroDef(ltTEXTSF
, "textsf", 1);
2171 AddMacroDef(ltTEXTTT
, "texttt", 1);
2172 AddMacroDef(ltTEXTBF
, "textbf", 1);
2173 AddMacroDef(ltTEXTIT
, "textit", 1);
2174 AddMacroDef(ltTEXTSL
, "textsl", 1);
2175 AddMacroDef(ltTEXTSC
, "textsc", 1);
2176 AddMacroDef(ltTEXTWIDTH
, "textwidth", 1);
2177 AddMacroDef(ltTEXTHEIGHT
, "textheight", 1);
2178 AddMacroDef(ltTEXTCOLOUR
, "textcolour", 1);
2179 AddMacroDef(ltTEX
, "TeX", 0);
2180 AddMacroDef(ltTHEBIBLIOGRAPHY
, "thebibliography", 2);
2181 AddMacroDef(ltTHETA
, "theta", 0);
2182 AddMacroDef(ltTIMES
, "times", 0);
2183 AddMacroDef(ltCAP_THETA
, "Theta", 0);
2184 AddMacroDef(ltTITLEPAGE
, "titlepage", 1);
2185 AddMacroDef(ltTITLE
, "title", 1);
2186 AddMacroDef(ltTINY
, "tiny", 1);
2187 AddMacroDef(ltTODAY
, "today", 0);
2188 AddMacroDef(ltTOPMARGIN
, "topmargin", 1);
2189 AddMacroDef(ltTOPSKIP
, "topskip", 1);
2190 AddMacroDef(ltTRIANGLE
, "triangle", 0);
2191 AddMacroDef(ltTTFAMILY
, "ttfamily", 1);
2192 AddMacroDef(ltTT
, "tt", 1);
2193 AddMacroDef(ltTYPEIN
, "typein", 1);
2194 AddMacroDef(ltTYPEOUT
, "typeout", 1);
2195 AddMacroDef(ltTWOCOLWIDTHA
, "twocolwidtha", 1);
2196 AddMacroDef(ltTWOCOLWIDTHB
, "twocolwidthb", 1);
2197 AddMacroDef(ltTWOCOLSPACING
, "twocolspacing", 1);
2198 AddMacroDef(ltTWOCOLITEMRULED
, "twocolitemruled", 2);
2199 AddMacroDef(ltTWOCOLITEM
, "twocolitem", 2);
2200 AddMacroDef(ltTWOCOLLIST
, "twocollist", 1);
2201 AddMacroDef(ltTWOCOLUMN
, "twocolumn", 0);
2202 AddMacroDef(ltTHEPAGE
, "thepage", 0);
2203 AddMacroDef(ltTHECHAPTER
, "thechapter", 0);
2204 AddMacroDef(ltTHESECTION
, "thesection", 0);
2205 AddMacroDef(ltTHISPAGESTYLE
, "thispagestyle", 1);
2207 AddMacroDef(ltUNDERLINE
, "underline", 1);
2208 AddMacroDef(ltUPSILON
, "upsilon", 0);
2209 AddMacroDef(ltCAP_UPSILON
, "Upsilon", 0);
2210 AddMacroDef(ltUPARROW
, "uparrow", 0);
2211 AddMacroDef(ltUPARROW2
, "Uparrow", 0);
2212 AddMacroDef(ltUPPERCASE
, "uppercase", 1);
2213 AddMacroDef(ltUPSHAPE
, "upshape", 1);
2214 AddMacroDef(ltURLREF
, "urlref", 2);
2215 AddMacroDef(ltUSEPACKAGE
, "usepackage", 1);
2217 AddMacroDef(ltVAREPSILON
, "varepsilon", 0);
2218 AddMacroDef(ltVARPHI
, "varphi", 0);
2219 AddMacroDef(ltVARPI
, "varpi", 0);
2220 AddMacroDef(ltVARRHO
, "varrho", 0);
2221 AddMacroDef(ltVARSIGMA
, "varsigma", 0);
2222 AddMacroDef(ltVARTHETA
, "vartheta", 0);
2223 AddMacroDef(ltVDOTS
, "vdots", 0);
2224 AddMacroDef(ltVEE
, "vee", 0);
2225 AddMacroDef(ltVERBATIMINPUT
, "verbatiminput", 1);
2226 AddMacroDef(ltVERBATIM
, "verbatim", 1);
2227 AddMacroDef(ltVERBSTAR
, "verb*", 1);
2228 AddMacroDef(ltVERB
, "verb", 1);
2229 AddMacroDef(ltVERSE
, "verse", 1);
2230 AddMacroDef(ltVFILL
, "vfill", 0);
2231 AddMacroDef(ltVLINE
, "vline", 0);
2232 AddMacroDef(ltVOID
, "void", 0);
2233 AddMacroDef(ltVDASH
, "vdash", 0);
2234 AddMacroDef(ltVRULE
, "vrule", 0);
2235 AddMacroDef(ltVSPACESTAR
, "vspace*", 1);
2236 AddMacroDef(ltVSKIPSTAR
, "vskip*", 1);
2237 AddMacroDef(ltVSPACE
, "vspace", 1);
2238 AddMacroDef(ltVSKIP
, "vskip", 1);
2240 AddMacroDef(ltWEDGE
, "wedge", 0);
2241 AddMacroDef(ltWXCLIPS
, "wxclips", 0);
2242 AddMacroDef(ltWINHELPIGNORE
, "winhelpignore", 1);
2243 AddMacroDef(ltWINHELPONLY
, "winhelponly", 1);
2244 AddMacroDef(ltWP
, "wp", 0);
2246 AddMacroDef(ltXI
, "xi", 0);
2247 AddMacroDef(ltCAP_XI
, "Xi", 0);
2248 AddMacroDef(ltXLPIGNORE
, "xlpignore", 1);
2249 AddMacroDef(ltXLPONLY
, "xlponly", 1);
2251 AddMacroDef(ltZETA
, "zeta", 0);
2253 AddMacroDef(ltSPACE
, " ", 0);
2254 AddMacroDef(ltBACKSLASHCHAR
, "\\", 0);
2255 AddMacroDef(ltPIPE
, "|", 0);
2256 AddMacroDef(ltFORWARDSLASH
, "/", 0);
2257 AddMacroDef(ltUNDERSCORE
, "_", 0);
2258 AddMacroDef(ltAMPERSAND
, "&", 0);
2259 AddMacroDef(ltPERCENT
, "%", 0);
2260 AddMacroDef(ltDOLLAR
, "$", 0);
2261 AddMacroDef(ltHASH
, "#", 0);
2262 AddMacroDef(ltLPARENTH
, "(", 0);
2263 AddMacroDef(ltRPARENTH
, ")", 0);
2264 AddMacroDef(ltLBRACE
, "{", 0);
2265 AddMacroDef(ltRBRACE
, "}", 0);
2266 // AddMacroDef(ltEQUALS, "=", 0);
2267 AddMacroDef(ltRANGLEBRA
, ">", 0);
2268 AddMacroDef(ltLANGLEBRA
, "<", 0);
2269 AddMacroDef(ltPLUS
, "+", 0);
2270 AddMacroDef(ltDASH
, "-", 0);
2271 AddMacroDef(ltAT_SYMBOL
, "@", 0);
2272 // AddMacroDef(ltSINGLEQUOTE, "'", 0);
2273 // AddMacroDef(ltBACKQUOTE, "`", 0);
2277 * Default behaviour, should be called by client if can't match locally.
2281 // Called on start/end of macro examination
2282 void DefaultOnMacro(int macroId
, int no_args
, bool start
)
2286 // Default behaviour for abstract
2291 // Write the heading
2292 FakeCurrentSection(AbstractNameString
);
2293 OnMacro(ltPAR
, 0, TRUE
);
2294 OnMacro(ltPAR
, 0, FALSE
);
2298 if (DocumentStyle
== LATEX_ARTICLE
)
2306 // Default behaviour for glossary
2307 case ltHELPGLOSSARY
:
2311 // Write the heading
2312 FakeCurrentSection(GlossaryNameString
);
2313 OnMacro(ltPAR
, 0, TRUE
);
2314 OnMacro(ltPAR
, 0, FALSE
);
2315 if ((convertMode
== TEX_RTF
) && !winHelp
)
2317 OnMacro(ltPAR
, 0, TRUE
);
2318 OnMacro(ltPAR
, 0, FALSE
);
2323 case ltSPECIALAMPERSAND
:
2330 TexOutput("<<", TRUE
);
2334 TexOutput(">>", TRUE
);
2338 TexOutput("~", TRUE
);
2342 TexOutput("~", TRUE
);
2344 case ltSPECIALTILDE
:
2346 TexOutput(" ", TRUE
);
2350 TexOutput("_", TRUE
);
2354 TexOutput("#", TRUE
);
2358 TexOutput("&", TRUE
);
2362 TexOutput(" ", TRUE
);
2366 TexOutput("|", TRUE
);
2370 TexOutput("%", TRUE
);
2374 TexOutput("$", TRUE
);
2378 TexOutput("", TRUE
);
2382 TexOutput("", TRUE
);
2386 TexOutput("{", TRUE
);
2390 TexOutput("}", TRUE
);
2394 TexOutput("(c)", TRUE
);
2398 TexOutput("(r)", TRUE
);
2402 TexOutput("\\", TRUE
);
2407 TexOutput("...", TRUE
);
2411 TexOutput("|", TRUE
);
2415 TexOutput("LaTeX", TRUE
);
2419 TexOutput("TeX", TRUE
);
2423 TexOutput("£", TRUE
);
2425 case ltSPECIALDOUBLEDOLLAR
: // Interpret as center
2426 OnMacro(ltCENTER
, no_args
, start
);
2432 OnMacro(ltIT
, no_args
, start
);
2435 case ltPARAGRAPHSTAR
:
2436 case ltSUBPARAGRAPH
:
2437 case ltSUBPARAGRAPHSTAR
:
2438 OnMacro(ltSUBSUBSECTION
, no_args
, start
);
2446 TexOutput(ctime(&when
), TRUE
);
2457 if (start
) TexOutput("alpha");
2460 if (start
) TexOutput("beta");
2463 if (start
) TexOutput("gamma");
2466 if (start
) TexOutput("delta");
2470 if (start
) TexOutput("epsilon");
2473 if (start
) TexOutput("zeta");
2476 if (start
) TexOutput("eta");
2480 if (start
) TexOutput("theta");
2483 if (start
) TexOutput("iota");
2486 if (start
) TexOutput("kappa");
2489 if (start
) TexOutput("lambda");
2492 if (start
) TexOutput("mu");
2495 if (start
) TexOutput("nu");
2498 if (start
) TexOutput("xi");
2502 if (start
) TexOutput("pi");
2506 if (start
) TexOutput("rho");
2510 if (start
) TexOutput("sigma");
2513 if (start
) TexOutput("tau");
2516 if (start
) TexOutput("upsilon");
2520 if (start
) TexOutput("phi");
2523 if (start
) TexOutput("chi");
2526 if (start
) TexOutput("psi");
2529 if (start
) TexOutput("omega");
2532 if (start
) TexOutput("GAMMA");
2535 if (start
) TexOutput("DELTA");
2538 if (start
) TexOutput("THETA");
2541 if (start
) TexOutput("LAMBDA");
2544 if (start
) TexOutput("XI");
2547 if (start
) TexOutput("PI");
2550 if (start
) TexOutput("SIGMA");
2553 if (start
) TexOutput("UPSILON");
2556 if (start
) TexOutput("PHI");
2559 if (start
) TexOutput("PSI");
2562 if (start
) TexOutput("OMEGA");
2565 // Binary operation symbols
2568 if (start
) TexOutput("<=");
2571 if (start
) TexOutput("<<");
2574 if (start
) TexOutput("SUBSET");
2577 if (start
) TexOutput("SUBSETEQ");
2580 if (start
) TexOutput("IN");
2583 if (start
) TexOutput("VDASH");
2586 if (start
) TexOutput("MODELS");
2590 if (start
) TexOutput(">=");
2593 if (start
) TexOutput(">>");
2596 if (start
) TexOutput("SUPSET");
2599 if (start
) TexOutput("SUPSETEQ");
2602 if (start
) TexOutput("NI");
2605 if (start
) TexOutput("DASHV");
2608 if (start
) TexOutput("PERP");
2611 if (start
) TexOutput("NEQ");
2614 if (start
) TexOutput("DOTEQ");
2617 if (start
) TexOutput("APPROX");
2620 if (start
) TexOutput("CONG");
2623 if (start
) TexOutput("EQUIV");
2626 if (start
) TexOutput("PROPTO");
2629 if (start
) TexOutput("PREC");
2632 if (start
) TexOutput("PRECEQ");
2635 if (start
) TexOutput("|");
2638 if (start
) TexOutput("~");
2641 if (start
) TexOutput("SIMEQ");
2644 if (start
) TexOutput("ASYMP");
2647 if (start
) TexOutput(":-)");
2650 if (start
) TexOutput(":-(");
2653 if (start
) TexOutput("SUCC");
2656 if (start
) TexOutput("SUCCEQ");
2659 if (start
) TexOutput("|");
2662 // Negated relation symbols
2664 if (start
) TexOutput("!=");
2667 if (start
) TexOutput("NOTIN");
2670 if (start
) TexOutput("NOTSUBSET");
2675 if (start
) TexOutput("<--");
2678 if (start
) TexOutput("<==");
2681 if (start
) TexOutput("-->");
2684 if (start
) TexOutput("==>");
2686 case ltLEFTRIGHTARROW
:
2687 if (start
) TexOutput("<-->");
2689 case ltLEFTRIGHTARROW2
:
2690 if (start
) TexOutput("<==>");
2693 if (start
) TexOutput("UPARROW");
2696 if (start
) TexOutput("UPARROW2");
2699 if (start
) TexOutput("DOWNARROW");
2702 if (start
) TexOutput("DOWNARROW2");
2704 // Miscellaneous symbols
2706 if (start
) TexOutput("ALEPH");
2709 if (start
) TexOutput("WP");
2712 if (start
) TexOutput("RE");
2715 if (start
) TexOutput("IM");
2718 if (start
) TexOutput("EMPTYSET");
2721 if (start
) TexOutput("NABLA");
2724 if (start
) TexOutput("SURD");
2727 if (start
) TexOutput("PARTIAL");
2730 if (start
) TexOutput("BOT");
2733 if (start
) TexOutput("FORALL");
2736 if (start
) TexOutput("EXISTS");
2739 if (start
) TexOutput("NEG");
2742 if (start
) TexOutput("SHARP");
2745 if (start
) TexOutput("ANGLE");
2748 if (start
) TexOutput("TRIANGLE");
2751 if (start
) TexOutput("CLUBSUIT");
2754 if (start
) TexOutput("DIAMONDSUIT");
2757 if (start
) TexOutput("HEARTSUIT");
2760 if (start
) TexOutput("SPADESUIT");
2763 if (start
) TexOutput("INFTY");
2766 if (start
) TexOutput("PM");
2769 if (start
) TexOutput("MP");
2772 if (start
) TexOutput("TIMES");
2775 if (start
) TexOutput("DIV");
2778 if (start
) TexOutput("CDOT");
2781 if (start
) TexOutput("AST");
2784 if (start
) TexOutput("STAR");
2787 if (start
) TexOutput("CAP");
2790 if (start
) TexOutput("CUP");
2793 if (start
) TexOutput("VEE");
2796 if (start
) TexOutput("WEDGE");
2799 if (start
) TexOutput("CIRC");
2802 if (start
) TexOutput("BULLET");
2805 if (start
) TexOutput("DIAMOND");
2808 if (start
) TexOutput("OSLASH");
2811 if (start
) TexOutput("BOX");
2814 if (start
) TexOutput("DIAMOND2");
2816 case ltBIGTRIANGLEDOWN
:
2817 if (start
) TexOutput("BIGTRIANGLEDOWN");
2820 if (start
) TexOutput("OPLUS");
2823 if (start
) TexOutput("OTIMES");
2826 if (start
) TexOutput("s");
2828 case ltBACKSLASHRAW
:
2829 if (start
) TexOutput("\\");
2832 if (start
) TexOutput("{");
2835 if (start
) TexOutput("}");
2839 if (start
) TexOutput(" ");
2846 // Called on start/end of argument examination
2847 bool DefaultOnArgument(int macroId
, int arg_no
, bool start
)
2853 if (arg_no
== 1 && start
)
2855 char *refName
= GetArgData();
2858 TexRef
*texRef
= FindReference(refName
);
2861 // Must strip the 'section' or 'chapter' or 'figure' text
2862 // from a normal 'ref' reference
2864 strcpy(buf
, texRef
->sectionNumber
);
2865 int len
= strlen(buf
);
2867 if (strcmp(buf
, "??") != 0)
2879 TexOutput(texRef
->sectionNumber
+ i
, TRUE
);
2884 TexOutput("??", TRUE
);
2885 sprintf(buf
, "Warning: unresolved reference %s.", refName
);
2889 else TexOutput("??", TRUE
);
2901 if (start
&& (arg_no
== 1))
2902 DocumentAuthor
= GetArgChunk();
2908 if (start
&& (arg_no
== 1))
2909 DocumentDate
= GetArgChunk();
2915 if (start
&& (arg_no
== 1))
2916 DocumentTitle
= GetArgChunk();
2920 case ltDOCUMENTCLASS
:
2921 case ltDOCUMENTSTYLE
:
2923 if (start
&& !IsArgOptional())
2925 DocumentStyleString
= copystring(GetArgData());
2926 if (strncmp(DocumentStyleString
, "art", 3) == 0)
2927 DocumentStyle
= LATEX_ARTICLE
;
2928 else if (strncmp(DocumentStyleString
, "rep", 3) == 0)
2929 DocumentStyle
= LATEX_REPORT
;
2930 else if (strncmp(DocumentStyleString
, "book", 4) == 0 ||
2931 strncmp(DocumentStyleString
, "thesis", 6) == 0)
2932 DocumentStyle
= LATEX_BOOK
;
2933 else if (strncmp(DocumentStyleString
, "letter", 6) == 0)
2934 DocumentStyle
= LATEX_LETTER
;
2935 else if (strncmp(DocumentStyleString
, "slides", 6) == 0)
2936 DocumentStyle
= LATEX_SLIDES
;
2938 if (StringMatch("10", DocumentStyleString
))
2940 else if (StringMatch("11", DocumentStyleString
))
2942 else if (StringMatch("12", DocumentStyleString
))
2945 OnMacro(ltHELPFONTSIZE
, 1, TRUE
);
2946 sprintf(currentArgData
, "%d", normalFont
);
2948 OnArgument(ltHELPFONTSIZE
, 1, TRUE
);
2949 OnArgument(ltHELPFONTSIZE
, 1, FALSE
);
2950 haveArgData
= FALSE
;
2951 OnMacro(ltHELPFONTSIZE
, 1, FALSE
);
2953 else if (start
&& IsArgOptional())
2955 MinorDocumentStyleString
= copystring(GetArgData());
2957 if (StringMatch("10", MinorDocumentStyleString
))
2959 else if (StringMatch("11", MinorDocumentStyleString
))
2961 else if (StringMatch("12", MinorDocumentStyleString
))
2967 case ltBIBLIOGRAPHYSTYLE
:
2969 if (start
&& !IsArgOptional())
2970 BibliographyStyleString
= copystring(GetArgData());
2976 if (start
&& !IsArgOptional())
2978 if (PageStyle
) delete[] PageStyle
;
2979 PageStyle
= copystring(GetArgData());
2987 if (start && !IsArgOptional())
2988 LeftHeader = GetArgChunk();
2994 if (start && !IsArgOptional())
2995 LeftFooter = GetArgChunk();
3001 if (start && !IsArgOptional())
3002 CentreHeader = GetArgChunk();
3008 if (start && !IsArgOptional())
3009 CentreFooter = GetArgChunk();
3015 if (start && !IsArgOptional())
3016 RightHeader = GetArgChunk();
3022 if (start && !IsArgOptional())
3023 RightFooter = GetArgChunk();
3031 if (start
&& !IsArgOptional())
3033 char *citeKeys
= GetArgData();
3035 char *citeKey
= ParseMultifieldString(citeKeys
, &pos
);
3038 AddCitation(citeKey
);
3039 TexRef
*ref
= FindReference(citeKey
);
3042 TexOutput(ref
->sectionNumber
, TRUE
);
3043 if (strcmp(ref
->sectionNumber
, "??") == 0)
3046 sprintf(buf
, "Warning: unresolved citation %s.", citeKey
);
3050 citeKey
= ParseMultifieldString(citeKeys
, &pos
);
3053 TexOutput(", ", TRUE
);
3062 if (start
&& !IsArgOptional())
3064 char *citeKey
= GetArgData();
3065 AddCitation(citeKey
);
3070 case ltHELPFONTSIZE
:
3074 char *data
= GetArgData();
3075 if (strcmp(data
, "10") == 0)
3077 else if (strcmp(data
, "11") == 0)
3079 else if (strcmp(data
, "12") == 0)
3089 TexOutput(" ??", TRUE
);
3096 if (start
&& arg_no
== 1)
3098 char *data
= GetArgData();
3099 ParSkip
= ParseUnitArgument(data
);
3106 if (start
&& arg_no
== 1)
3108 char *data
= GetArgData();
3109 ParIndent
= ParseUnitArgument(data
);
3116 return OnArgument(ltIT
, arg_no
, start
);
3119 case ltSPECIALDOUBLEDOLLAR
:
3121 return OnArgument(ltCENTER
, arg_no
, start
);
3125 case ltPARAGRAPHSTAR
:
3126 case ltSUBPARAGRAPH
:
3127 case ltSUBPARAGRAPHSTAR
:
3129 return OnArgument(ltSUBSUBSECTION
, arg_no
, start
);
3135 OnInform(GetArgData());
3141 TexOutput(" (", TRUE
);
3143 TexOutput(")", TRUE
);
3146 case ltBIBLIOGRAPHY
:
3154 if ((fd
= fopen(TexBibName
, "r")))
3160 TexOutput(smallBuf
);
3168 OnInform("Run Tex2RTF again to include bibliography.");
3171 // Read in the .bib file, resolve all known references, write out the RTF.
3172 char *allFiles
= GetArgData();
3174 char *bibFile
= ParseMultifieldString(allFiles
, &pos
);
3178 strcpy(fileBuf
, bibFile
);
3179 wxString actualFile
= TexPathList
.FindValidPath(fileBuf
);
3180 if (actualFile
== "")
3182 strcat(fileBuf
, ".bib");
3183 actualFile
= TexPathList
.FindValidPath(fileBuf
);
3185 if (actualFile
!= "")
3187 if (!ReadBib((char*) (const char*) actualFile
))
3190 sprintf(buf
, ".bib file %s not found or malformed", (const char*) actualFile
);
3197 sprintf(buf
, ".bib file %s not found", fileBuf
);
3200 bibFile
= ParseMultifieldString(allFiles
, &pos
);
3203 ResolveBibReferences();
3205 // Write it a new bib section in the appropriate format.
3206 FILE *save1
= CurrentOutput1
;
3207 FILE *save2
= CurrentOutput2
;
3208 FILE *Biblio
= fopen(TexTmpBibName
, "w");
3209 SetCurrentOutput(Biblio
);
3212 if (wxFileExists(TexTmpBibName
))
3214 if (wxFileExists(TexBibName
)) wxRemoveFile(TexBibName
);
3215 wxRenameFile(TexTmpBibName
, TexBibName
);
3217 SetCurrentOutputs(save1
, save2
);
3224 if (start
&& (arg_no
== 3))
3234 if (start
&& (arg_no
== 1))
3236 char *s
= GetArgData();
3239 char *s1
= copystring(s
);
3241 for (i
= 0; i
< (int)strlen(s
); i
++)
3242 s1
[i
] = toupper(s
[i
]);
3255 if (start
&& (arg_no
== 1))
3257 char *s
= GetArgData();
3260 char *s1
= copystring(s
);
3262 for (i
= 0; i
< (int)strlen(s
); i
++)
3263 s1
[i
] = tolower(s
[i
]);
3276 if (start
&& (arg_no
== 1))
3278 char *s
= GetArgData();
3281 char *s1
= copystring(s
);
3283 for (i
= 0; i
< (int)strlen(s
); i
++)
3284 s1
[i
] = toupper(s
[i
]);
3295 case ltPOPREF
: // Ignore second argument by default
3297 if (start
&& (arg_no
== 1))
3307 return ((convertMode
== TEX_XLP
) ? FALSE
: TRUE
);
3310 return ((convertMode
!= TEX_XLP
) ? FALSE
: TRUE
);
3313 return ((convertMode
== TEX_HTML
) ? FALSE
: TRUE
);
3316 return ((convertMode
!= TEX_HTML
) ? FALSE
: TRUE
);
3319 return (((convertMode
== TEX_RTF
) && !winHelp
) ? FALSE
: TRUE
);
3322 return (!((convertMode
== TEX_RTF
) && !winHelp
) ? FALSE
: TRUE
);
3324 case ltWINHELPIGNORE
:
3325 return (winHelp
? FALSE
: TRUE
);
3328 return (!winHelp
? FALSE
: TRUE
);
3343 case ltADDTOCOUNTER
:
3344 case ltADDCONTENTSLINE
:
3348 case ltBASELINESKIP
:
3357 case ltPAGENUMBERING
:
3369 case ltTHISPAGESTYLE
:
3372 case ltEVENSIDEMARGIN
:
3373 case ltODDSIDEMARGIN
:
3375 case ltMARGINPARWIDTH
:
3376 case ltMARGINPARSEP
:
3377 case ltMARGINPAREVEN
:
3378 case ltMARGINPARODD
:
3379 case ltTWOCOLWIDTHA
:
3380 case ltTWOCOLWIDTHB
:
3381 case ltTWOCOLSPACING
:
3388 case ltSETHOTSPOTCOLOUR
:
3389 case ltSETHOTSPOTCOLOR
:
3390 case ltSETHOTSPOTUNDERLINE
:
3391 case ltSETTRANSPARENCY
:
3394 case ltBACKGROUNDCOLOUR
:
3395 case ltBACKGROUNDIMAGE
:
3397 case ltFOLLOWEDLINKCOLOUR
:
3404 case ltINSERTATLEVEL
:
3408 case ltSUPERTABULAR
:
3417 if (arg_no
== 2) return TRUE
;
3424 if (arg_no
== 2) return TRUE
;
3428 case ltDEFINECOLOUR
:
3431 static int redVal
= 0;
3432 static int greenVal
= 0;
3433 static int blueVal
= 0;
3434 static char *colourName
= NULL
;
3441 if (colourName
) delete[] colourName
;
3442 colourName
= copystring(GetArgData());
3447 redVal
= atoi(GetArgData());
3452 greenVal
= atoi(GetArgData());
3457 blueVal
= atoi(GetArgData());
3458 AddColour(colourName
, redVal
, greenVal
, blueVal
);
3474 if (IsArgOptional())