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
;
126 extern int passNumber
;
128 extern wxHashTable TexReferences
;
131 * International support
134 // Names to help with internationalisation
135 char *ContentsNameString
= copystring("Contents");
136 char *AbstractNameString
= copystring("Abstract");
137 char *GlossaryNameString
= copystring("Glossary");
138 char *ReferencesNameString
= copystring("References");
139 char *FiguresNameString
= copystring("List of Figures");
140 char *TablesNameString
= copystring("List of Tables");
141 char *FigureNameString
= copystring("Figure");
142 char *TableNameString
= copystring("Table");
143 char *IndexNameString
= copystring("Index");
144 char *ChapterNameString
= copystring("chapter");
145 char *SectionNameString
= copystring("section");
146 char *SubsectionNameString
= copystring("subsection");
147 char *SubsubsectionNameString
= copystring("subsubsection");
148 char *UpNameString
= copystring("Up");
157 int subsectionNo
= 0;
158 int subsubsectionNo
= 0;
167 FILE *CurrentOutput1
= NULL
;
168 FILE *CurrentOutput2
= NULL
;
172 int CurrentInputIndex
= 0;
174 char *TexFileRoot
= NULL
;
175 char *TexBibName
= NULL
; // Bibliography output file name
176 char *TexTmpBibName
= NULL
; // Temporary bibliography output file name
177 bool isSync
= FALSE
; // If TRUE, should not yield to other processes.
178 bool stopRunning
= FALSE
; // If TRUE, should abort.
180 static int currentColumn
= 0;
181 char *currentArgData
= NULL
;
182 bool haveArgData
= FALSE
; // If TRUE, we're simulating the data.
183 TexChunk
*currentArgument
= NULL
;
184 TexChunk
*nextChunk
= NULL
;
185 bool isArgOptional
= FALSE
;
188 TexChunk
*TopLevel
= NULL
;
189 // wxList MacroDefs(wxKEY_STRING);
190 wxHashTable
MacroDefs(wxKEY_STRING
);
191 wxStringList IgnorableInputFiles
; // Ignorable \input files, e.g. psbox.tex
192 char *BigBuffer
= NULL
; // For reading in large chunks of text
193 TexMacroDef
*SoloBlockDef
= NULL
;
194 TexMacroDef
*VerbatimMacroDef
= NULL
;
196 #define IncrementLineNumber() LineNumbers[CurrentInputIndex] ++
199 TexRef::TexRef(char *label
, char *file
, char *section
, char *sectionN
)
201 refLabel
= copystring(label
);
202 refFile
= file
? copystring(file
) : (char*) NULL
;
203 sectionNumber
= section
? copystring(section
) : copystring("??");
204 sectionName
= sectionN
? copystring(sectionN
) : copystring("??");
207 TexRef::~TexRef(void)
209 delete [] refLabel
; refLabel
= NULL
;
210 delete [] refFile
; refFile
= NULL
;
211 delete [] sectionNumber
; sectionNumber
= NULL
;
212 delete [] sectionName
; sectionName
= NULL
;
216 CustomMacro::~CustomMacro()
224 void TexOutput(char *s
, bool ordinaryText
)
228 // Update current column, but only if we're guaranteed to
229 // be ordinary text (not mark-up stuff)
232 for (i
= 0; i
< len
; i
++)
234 if (s
[i
] == 13 || s
[i
] == 10)
241 fprintf(CurrentOutput1
, "%s", s
);
243 fprintf(CurrentOutput2
, "%s", s
);
247 * Try to find a Latex macro, in one of the following forms:
248 * (1) \begin{} ... \end{}
249 * (2) \macroname{arg1}...{argn}
253 void ForbidWarning(TexMacroDef
*def
)
256 switch (def
->forbidden
)
260 sprintf(buf
, "Warning: it is recommended that command %s is not used.", def
->name
);
264 case FORBID_ABSOLUTELY
:
266 sprintf(buf
, "Error: command %s cannot be used and will lead to errors.", def
->name
);
275 TexMacroDef
*MatchMacro(char *buffer
, int *pos
, char **env
, bool *parseToBrace
)
277 *parseToBrace
= TRUE
;
279 TexMacroDef
*def
= NULL
;
282 // First, try to find begin{thing}
283 if (strncmp(buffer
+i
, "begin{", 6) == 0)
288 while ((isalpha(buffer
[j
]) || buffer
[j
] == '*') && ((j
- i
) < 39))
290 macroBuf
[j
-i
] = buffer
[j
];
294 def
= (TexMacroDef
*)MacroDefs
.Get(macroBuf
);
298 *pos
= j
+ 1; // BUGBUG Should this be + 1???
306 // Failed, so try to find macro from definition list
309 // First try getting a one-character macro, but ONLY
310 // if these TWO characters are not both alphabetical (could
311 // be a longer macro)
312 if (!(isalpha(buffer
[i
]) && isalpha(buffer
[i
+1])))
314 macroBuf
[0] = buffer
[i
];
317 def
= (TexMacroDef
*)MacroDefs
.Get(macroBuf
);
323 while ((isalpha(buffer
[j
]) || buffer
[j
] == '*') && ((j
- i
) < 39))
325 macroBuf
[j
-i
] = buffer
[j
];
329 def
= (TexMacroDef
*)MacroDefs
.Get(macroBuf
);
336 // We want to check whether this is a space-consuming macro
338 // No brace, e.g. \input thing.tex instead of \input{thing};
339 // or a numeric argument, such as \parindent0pt
340 if ((def
->no_args
> 0) && ((buffer
[i
] == 32) || (buffer
[i
] == '=') || (isdigit(buffer
[i
]))))
342 if ((buffer
[i
] == 32) || (buffer
[i
] == '='))
345 *parseToBrace
= FALSE
;
354 void EatWhiteSpace(char *buffer
, int *pos
)
356 int len
= strlen(buffer
);
358 bool keepGoing
= TRUE
;
359 bool moreLines
= TRUE
;
360 while ((j
< len
) && keepGoing
&&
361 (buffer
[j
] == 10 || buffer
[j
] == 13 || buffer
[j
] == ' ' || buffer
[j
] == 9))
368 moreLines
= read_a_line(buffer
);
369 len
= strlen(buffer
);
379 bool FindEndEnvironment(char *buffer
, int *pos
, char *env
)
383 // Try to find end{thing}
384 if ((strncmp(buffer
+i
, "end{", 4) == 0) &&
385 (strncmp(buffer
+i
+4, env
, strlen(env
)) == 0))
387 *pos
= i
+ 5 + strlen(env
);
393 bool readingVerbatim
= FALSE
;
394 bool readInVerbatim
= FALSE
; // Within a verbatim, but not nec. verbatiminput
396 // Switched this off because e.g. \verb${$ causes it to fail. There is no
397 // detection of \verb yet.
398 #define CHECK_BRACES 1
400 unsigned long leftCurly
= 0;
401 unsigned long rightCurly
= 0;
402 static wxString currentFileName
= "";
404 bool read_a_line(char *buf
)
406 if (CurrentInputIndex
< 0)
416 while (ch
!= EOF
&& ch
!= 10)
418 if (bufIndex
>= MAX_LINE_BUFFER_SIZE
)
421 errBuf
.Printf("Line %lu of file %s is too long. Lines can be no longer than %lu characters. Truncated.",
422 LineNumbers
[CurrentInputIndex
], (const char*) currentFileName
.c_str(),MAX_LINE_BUFFER_SIZE
);
423 OnError((char *)errBuf
.c_str());
427 if (((bufIndex
== 14) && (strncmp(buf
, "\\end{verbatim}", 14) == 0)) ||
428 ((bufIndex
== 16) && (strncmp(buf
, "\\end{toocomplex}", 16) == 0)))
429 readInVerbatim
= FALSE
;
431 ch
= getc(Inputs
[CurrentInputIndex
]);
434 if (ch
== '{' && !readInVerbatim
)
436 if (ch
== '}' && !readInVerbatim
)
439 if (rightCurly
> leftCurly
)
442 errBuf
.Printf("An extra right curly brace ('}') was detected at line %lu inside file %s",LineNumbers
[CurrentInputIndex
], (const char*) currentFileName
.c_str());
443 OnError((char *)errBuf
.c_str());
445 // Reduce the count of right curly braces, so the mismatched count
446 // isn't reported on every line that has a '}' after the first mismatch
454 // Check for 2 consecutive newlines and replace with \par
455 if (ch
== 10 && !readInVerbatim
)
457 int ch1
= getc(Inputs
[CurrentInputIndex
]);
458 if ((ch1
== 10) || (ch1
== 13))
460 // Eliminate newline (10) following DOS linefeed
462 ch1
= getc(Inputs
[CurrentInputIndex
]);
464 IncrementLineNumber();
465 // strcat(buf, "\\par\n");
467 if (bufIndex
+5 >= MAX_LINE_BUFFER_SIZE
)
470 errBuf
.Printf("Line %lu of file %s is too long. Lines can be no longer than %lu characters. Truncated.",
471 LineNumbers
[CurrentInputIndex
], (const char*) currentFileName
.c_str(),MAX_LINE_BUFFER_SIZE
);
472 OnError((char *)errBuf
.c_str());
475 strcat(buf
, "\\par");
481 ungetc(ch1
, Inputs
[CurrentInputIndex
]);
482 if (bufIndex
>= MAX_LINE_BUFFER_SIZE
)
485 errBuf
.Printf("Line %lu of file %s is too long. Lines can be no longer than %lu characters. Truncated.",
486 LineNumbers
[CurrentInputIndex
], (const char*) currentFileName
.c_str(),MAX_LINE_BUFFER_SIZE
);
487 OnError((char *)errBuf
.c_str());
498 // Convert embedded characters to RTF equivalents
507 if (bufIndex
+5 >= MAX_LINE_BUFFER_SIZE
)
510 errBuf
.Printf("Line %lu of file %s is too long. Lines can be no longer than %lu characters. Truncated.",
511 LineNumbers
[CurrentInputIndex
], (const char*) currentFileName
.c_str(),MAX_LINE_BUFFER_SIZE
);
512 OnError((char *)errBuf
.c_str());
515 buf
[bufIndex
++]='\\';
520 case 0xf6:buf
[bufIndex
++]='o';break; // ö
521 case 0xe4:buf
[bufIndex
++]='a';break; // ä
522 case 0xfc:buf
[bufIndex
++]='u';break; // ü
523 case 0xd6:buf
[bufIndex
++]='O';break; // Ö
524 case 0xc4:buf
[bufIndex
++]='A';break; // Ä
525 case 0xdc:buf
[bufIndex
++]='U';break; // Ü
530 if (bufIndex
+5 >= MAX_LINE_BUFFER_SIZE
)
533 errBuf
.Printf("Line %lu of file %s is too long. Lines can be no longer than %lu characters. Truncated.",
534 LineNumbers
[CurrentInputIndex
], (const char*) currentFileName
.c_str(),MAX_LINE_BUFFER_SIZE
);
535 OnError((char *)errBuf
.c_str());
538 buf
[bufIndex
++]='\\';
541 buf
[bufIndex
++]='\\';
545 if (bufIndex
>= MAX_LINE_BUFFER_SIZE
)
548 errBuf
.Printf("Line %lu of file %s is too long. Lines can be no longer than %lu characters. Truncated.",
549 LineNumbers
[CurrentInputIndex
], (const char*) currentFileName
.c_str(),MAX_LINE_BUFFER_SIZE
);
550 OnError((char *)errBuf
.c_str());
553 buf
[bufIndex
++] = ch
;
561 fclose(Inputs
[CurrentInputIndex
]);
562 Inputs
[CurrentInputIndex
] = NULL
;
563 if (CurrentInputIndex
> 0)
564 ch
= ' '; // No real end of file
565 CurrentInputIndex
--;
567 if (leftCurly
!= rightCurly
)
570 errBuf
.Printf("Curly braces do not match inside file %s\n%lu opens, %lu closes", (const char*) currentFileName
.c_str(),leftCurly
,rightCurly
);
571 OnError((char *)errBuf
.c_str());
578 readingVerbatim
= FALSE
;
579 readInVerbatim
= FALSE
;
580 strcat(buf
, "\\end{verbatim}\n");
585 IncrementLineNumber();
589 // Strip out comment environment
590 if (strncmp(buf
, "\\begin{comment}", 15) == 0)
592 while (strncmp(buf
, "\\end{comment}", 13) != 0)
594 return read_a_line(buf
);
596 // Read a verbatim input file as if it were a verbatim environment
597 else if (strncmp(buf
, "\\verbatiminput", 14) == 0)
600 char *fileName
= buf
+ wordLen
+ 1;
602 int j
= bufIndex
- 1;
605 // thing}\par -- eliminate the \par!
606 if (strncmp((buf
+ strlen(buf
)-5), "\\par", 4) == 0)
613 buf
[j
-1] = 0; // Ignore final brace
615 wxString actualFile
= TexPathList
.FindValidPath(fileName
);
616 currentFileName
= actualFile
;
617 if (actualFile
== "")
620 errBuf
.Printf("Could not find file: %s",fileName
);
621 OnError((char *)errBuf
.c_str());
626 informStr
.Printf("Processing: %s",actualFile
.c_str());
627 OnInform((char *)informStr
.c_str());
628 CurrentInputIndex
++;
630 Inputs
[CurrentInputIndex
] = fopen(actualFile
, "r");
631 LineNumbers
[CurrentInputIndex
] = 1;
632 if (FileNames
[CurrentInputIndex
])
633 delete[] FileNames
[CurrentInputIndex
];
634 FileNames
[CurrentInputIndex
] = copystring(actualFile
);
636 if (!Inputs
[CurrentInputIndex
])
638 CurrentInputIndex
--;
639 OnError("Could not open verbatiminput file.");
643 readingVerbatim
= TRUE
;
644 readInVerbatim
= TRUE
;
645 strcpy(buf
, "\\begin{verbatim}\n");
651 else if (strncmp(buf
, "\\input", 6) == 0 || strncmp(buf
, "\\helpinput", 10) == 0 ||
652 strncmp(buf
, "\\include", 8) == 0)
655 if (strncmp(buf
, "\\input", 6) == 0)
658 if (strncmp(buf
, "\\include", 8) == 0)
663 char *fileName
= buf
+ wordLen
+ 1;
665 int j
= bufIndex
- 1;
668 // \input{thing}\par -- eliminate the \par!
669 // if (strncmp((buf + strlen(buf)-5), "\\par", 4) == 0)
670 if (strncmp((buf
+ strlen(buf
)-4), "\\par", 4) == 0) // Bug fix 8/2/95 Ulrich Leodolter
678 buf
[j
-1] = 0; // Ignore final brace
680 // Remove backslashes from name
681 wxString
fileNameStr(fileName
);
682 fileNameStr
.Replace("\\", "");
684 // Ignore some types of input files (e.g. macro definition files)
685 char *fileOnly
= FileNameFromPath((char*) (const char*) fileNameStr
);
686 currentFileName
= fileOnly
;
687 if (IgnorableInputFiles
.Member(fileOnly
))
688 return read_a_line(buf
);
690 wxString actualFile
= TexPathList
.FindValidPath(fileNameStr
);
691 if (actualFile
== "")
694 sprintf(buf2
, "%s.tex", (const char*) fileNameStr
);
695 actualFile
= TexPathList
.FindValidPath(buf2
);
697 currentFileName
= actualFile
;
699 if (actualFile
== "")
702 errBuf
.Printf("Could not find file: %s",fileName
);
703 OnError((char *)errBuf
.c_str());
707 // Ensure that if this file includes another,
708 // then we look in the same directory as this one.
709 TexPathList
.EnsureFileAccessible(actualFile
);
712 informStr
.Printf("Processing: %s",actualFile
.c_str());
713 OnInform((char *)informStr
.c_str());
714 CurrentInputIndex
++;
716 Inputs
[CurrentInputIndex
] = fopen(actualFile
, "r");
717 LineNumbers
[CurrentInputIndex
] = 1;
718 if (FileNames
[CurrentInputIndex
])
719 delete[] FileNames
[CurrentInputIndex
];
720 FileNames
[CurrentInputIndex
] = copystring(actualFile
);
722 if (!Inputs
[CurrentInputIndex
])
725 errBuf
.Printf("Could not open include file %s", (const char*) actualFile
);
726 CurrentInputIndex
--;
727 OnError((char *)errBuf
.c_str());
730 bool succ
= read_a_line(buf
);
733 if (strncmp(buf
, "\\begin{verbatim}", 16) == 0 ||
734 strncmp(buf
, "\\begin{toocomplex}", 18) == 0)
735 readInVerbatim
= TRUE
;
736 else if (strncmp(buf
, "\\end{verbatim}", 14) == 0 ||
737 strncmp(buf
, "\\end{toocomplex}", 16) == 0)
738 readInVerbatim
= FALSE
;
741 if (ch
== EOF
&& leftCurly
!= rightCurly
)
744 errBuf
.Printf("Curly braces do not match inside file %s\n%lu opens, %lu closes", (const char*) currentFileName
.c_str(),leftCurly
,rightCurly
);
745 OnError((char *)errBuf
.c_str());
757 bool ParseNewCommand(char *buffer
, int *pos
)
759 if ((strncmp((buffer
+(*pos
)), "newcommand", 10) == 0) ||
760 (strncmp((buffer
+(*pos
)), "renewcommand", 12) == 0))
762 if (strncmp((buffer
+(*pos
)), "newcommand", 10) == 0)
767 char commandName
[100];
768 char commandValue
[1000];
771 while (buffer
[*pos
] != '}' && (buffer
[*pos
] != 0))
773 commandName
[i
] = buffer
[*pos
];
780 if (buffer
[*pos
] == '[')
783 noArgs
= (int)(buffer
[*pos
]) - 48;
784 *pos
+= 2; // read past argument and '['
790 char ch
= buffer
[*pos
];
801 if (!read_a_line(buffer
))
806 commandValue
[i
] = ch
;
812 CustomMacro
*macro
= new CustomMacro(commandName
, noArgs
, NULL
);
813 if (strlen(commandValue
) > 0)
814 macro
->macroBody
= copystring(commandValue
);
815 if (!CustomMacroList
.Find(commandName
))
817 CustomMacroList
.Append(commandName
, macro
);
818 AddMacroDef(ltCUSTOM_MACRO
, commandName
, noArgs
);
825 void MacroError(char *buffer
)
832 while (((ch
= buffer
[i
-1]) != '\n') && (ch
!= 0))
841 errBuf
.Printf("Could not find macro: %s at line %d, file %s",
842 macroBuf
, (int)(LineNumbers
[CurrentInputIndex
]-1), FileNames
[CurrentInputIndex
]);
843 OnError((char *)errBuf
.c_str());
848 * 'environment' specifies the name of the macro IFF if we're looking for the end
849 * of an environment, e.g. \end{itemize}. Otherwise it's NULL.
850 * 'parseToBrace' is TRUE if the argument should extend to the next right brace,
851 * e.g. in {\bf an argument} as opposed to \vskip 30pt
854 int ParseArg(TexChunk
*thisArg
, wxList
& children
, char *buffer
, int pos
, char *environment
, bool parseToBrace
, TexChunk
*customMacroArgs
)
857 if (stopRunning
) return pos
;
866 // Consume leading brace or square bracket, but ONLY if not following
867 // a space, because this could be e.g. {\large {\bf thing}} where {\bf thing}
868 // is the argument of \large AS WELL as being a block in its
872 if ((pos > 0) && (buffer[pos-1] != ' ') && buffer[pos] == '{')
876 if ((pos > 0) && (buffer[pos-1] != ' ') && (buffer[pos] == '[' || buffer[pos] == '('))
881 else if ((pos > 1) && (buffer[pos-1] != ' ') && (buffer[pos+1] == '[' || buffer[pos+1] == '('))
889 // If not parsing to brace, just read the next word
890 // (e.g. \vskip 20pt)
893 int ch
= buffer
[pos
];
894 while (!eof
&& ch
!= 13 && ch
!= 32 && ch
!= 10 &&
895 ch
!= 0 && ch
!= '{')
897 BigBuffer
[buf_ptr
] = ch
;
904 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_STRING
);
905 BigBuffer
[buf_ptr
] = 0;
907 chunk
->value
= copystring(BigBuffer
);
908 children
.Append((wxObject
*)chunk
);
915 len
= strlen(buffer
);
918 if (customMacroArgs
) return 0;
920 eof
= read_a_line(buffer
);
922 len
= strlen(buffer
);
923 // Check for verbatim (or toocomplex, which comes to the same thing)
924 if (strncmp(buffer
, "\\begin{verbatim}", 16) == 0 ||
925 strncmp(buffer
, "\\begin{toocomplex}", 18) == 0)
929 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_STRING
);
930 BigBuffer
[buf_ptr
] = 0;
932 chunk
->value
= copystring(BigBuffer
);
933 children
.Append((wxObject
*)chunk
);
938 eof
= read_a_line(buffer
);
939 while (!eof
&& (strncmp(buffer
, "\\end{verbatim}", 14) != 0) &&
940 (strncmp(buffer
, "\\end{toocomplex}", 16) != 0)
943 strcat(BigBuffer
, buffer
);
944 buf_ptr
+= strlen(buffer
);
945 eof
= read_a_line(buffer
);
947 eof
= read_a_line(buffer
);
950 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_MACRO
, VerbatimMacroDef
);
952 chunk
->macroId
= ltVERBATIM
;
953 TexChunk
*arg
= new TexChunk(CHUNK_TYPE_ARG
, VerbatimMacroDef
);
955 arg
->macroId
= ltVERBATIM
;
956 TexChunk
*str
= new TexChunk(CHUNK_TYPE_STRING
);
957 str
->value
= copystring(BigBuffer
);
959 children
.Append((wxObject
*)chunk
);
960 chunk
->children
.Append((wxObject
*)arg
);
961 arg
->children
.Append((wxObject
*)str
);
963 // Also want to include the following newline (is always a newline
964 // after a verbatim): EXCEPT in HTML
965 if (convertMode
!= TEX_HTML
)
967 TexMacroDef
*parDef
= (TexMacroDef
*)MacroDefs
.Get("\\");
968 TexChunk
*parChunk
= new TexChunk(CHUNK_TYPE_MACRO
, parDef
);
969 parChunk
->no_args
= 0;
970 parChunk
->macroId
= ltBACKSLASHCHAR
;
971 children
.Append((wxObject
*)parChunk
);
976 char ch
= buffer
[pos
];
977 // End of optional argument -- pretend it's right brace for simplicity
978 if (thisArg
->optional
&& (ch
== ']'))
984 case '}': // End of argument
988 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_STRING
);
989 BigBuffer
[buf_ptr
] = 0;
991 chunk
->value
= copystring(BigBuffer
);
992 children
.Append((wxObject
*)chunk
);
994 if (ch
== '}') pos
++;
1000 if (buf_ptr
> 0) // Finish off the string we've read so far
1002 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_STRING
);
1003 BigBuffer
[buf_ptr
] = 0;
1005 chunk
->value
= copystring(BigBuffer
);
1006 children
.Append((wxObject
*)chunk
);
1011 // Try matching \end{environment}
1012 if (environment
&& FindEndEnvironment(buffer
, &pos
, environment
))
1014 // Eliminate newline after an \end{} if possible
1015 if (buffer
[pos
] == 13)
1018 if (buffer
[pos
] == 10)
1024 if (ParseNewCommand(buffer
, &pos
))
1027 if (strncmp(buffer
+pos
, "special", 7) == 0)
1040 int ch
= buffer
[pos
];
1062 else if (ch
== '\\' && buffer
[pos
+1] == '}')
1068 else if (ch
== '\\' && buffer
[pos
+1] == '{')
1083 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_MACRO
);
1085 chunk
->macroId
= ltSPECIAL
;
1086 TexMacroDef
*specialDef
= (TexMacroDef
*)MacroDefs
.Get("special");
1087 chunk
->def
= specialDef
;
1088 TexChunk
*arg
= new TexChunk(CHUNK_TYPE_ARG
, specialDef
);
1089 chunk
->children
.Append((wxObject
*)arg
);
1091 arg
->macroId
= chunk
->macroId
;
1093 // The value in the first argument.
1094 TexChunk
*argValue
= new TexChunk(CHUNK_TYPE_STRING
);
1095 arg
->children
.Append((wxObject
*)argValue
);
1097 argValue
->value
= copystring(wxBuffer
);
1099 children
.Append((wxObject
*)chunk
);
1101 else if (strncmp(buffer
+pos
, "verb", 4) == 0)
1104 if (buffer
[pos
] == '*')
1107 // Find the delimiter character
1108 int ch
= buffer
[pos
];
1110 // Now at start of verbatim text
1112 while ((buffer
[pos
] != ch
) && buffer
[pos
] != 0)
1114 char *val
= new char[pos
- j
+ 1];
1116 for (i
= j
; i
< pos
; i
++)
1118 val
[i
-j
] = buffer
[i
];
1124 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_MACRO
);
1126 chunk
->macroId
= ltVERB
;
1127 TexMacroDef
*verbDef
= (TexMacroDef
*)MacroDefs
.Get("verb");
1128 chunk
->def
= verbDef
;
1129 TexChunk
*arg
= new TexChunk(CHUNK_TYPE_ARG
, verbDef
);
1130 chunk
->children
.Append((wxObject
*)arg
);
1132 arg
->macroId
= chunk
->macroId
;
1134 // The value in the first argument.
1135 TexChunk
*argValue
= new TexChunk(CHUNK_TYPE_STRING
);
1136 arg
->children
.Append((wxObject
*)argValue
);
1138 argValue
->value
= val
;
1140 children
.Append((wxObject
*)chunk
);
1145 bool tmpParseToBrace
= TRUE
;
1146 TexMacroDef
*def
= MatchMacro(buffer
, &pos
, &env
, &tmpParseToBrace
);
1149 CustomMacro
*customMacro
= FindCustomMacro(def
->name
);
1151 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_MACRO
, def
);
1152 chunk
->no_args
= def
->no_args
;
1153 // chunk->name = copystring(def->name);
1154 chunk
->macroId
= def
->macroId
;
1157 children
.Append((wxObject
*)chunk
);
1159 // Eliminate newline after a \begin{} or a \\ if possible
1160 if (env
|| strcmp(def
->name
, "\\") == 0)
1161 if (buffer
[pos
] == 13)
1164 if (buffer
[pos
] == 10)
1168 pos
= ParseMacroBody(def
->name
, chunk
, chunk
->no_args
,
1169 buffer
, pos
, env
, tmpParseToBrace
, customMacroArgs
);
1171 // If custom macro, parse the body substituting the above found args.
1174 if (customMacro
->macroBody
)
1177 // strcpy(macroBuf, "{");
1178 strcpy(macroBuf
, customMacro
->macroBody
);
1179 strcat(macroBuf
, "}");
1180 ParseArg(thisArg
, children
, macroBuf
, 0, NULL
, TRUE
, chunk
);
1183 // delete chunk; // Might delete children
1188 MacroError(buffer
+pos
);
1193 // Parse constructs like {\bf thing} as if they were
1198 if (buffer
[pos
] == '\\')
1202 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_STRING
);
1203 BigBuffer
[buf_ptr
] = 0;
1205 chunk
->value
= copystring(BigBuffer
);
1206 children
.Append((wxObject
*)chunk
);
1211 bool tmpParseToBrace
;
1212 TexMacroDef
*def
= MatchMacro(buffer
, &pos
, &env
, &tmpParseToBrace
);
1215 CustomMacro
*customMacro
= FindCustomMacro(def
->name
);
1217 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_MACRO
, def
);
1218 chunk
->no_args
= def
->no_args
;
1219 // chunk->name = copystring(def->name);
1220 chunk
->macroId
= def
->macroId
;
1222 children
.Append((wxObject
*)chunk
);
1224 pos
= ParseMacroBody(def
->name
, chunk
, chunk
->no_args
,
1225 buffer
, pos
, NULL
, TRUE
, customMacroArgs
);
1227 // If custom macro, parse the body substituting the above found args.
1230 if (customMacro
->macroBody
)
1233 // strcpy(macroBuf, "{");
1234 strcpy(macroBuf
, customMacro
->macroBody
);
1235 strcat(macroBuf
, "}");
1236 ParseArg(thisArg
, children
, macroBuf
, 0, NULL
, TRUE
, chunk
);
1239 // delete chunk; // Might delete children
1244 MacroError(buffer
+pos
);
1250 * If all else fails, we assume that we have
1251 * a pair of braces on their own, so return a `dummy' macro
1252 * definition with just one argument to parse.
1256 SoloBlockDef
= new TexMacroDef(ltSOLO_BLOCK
, "solo block", 1, FALSE
);
1261 TexChunk
*chunk1
= new TexChunk(CHUNK_TYPE_STRING
);
1262 BigBuffer
[buf_ptr
] = 0;
1264 chunk1
->value
= copystring(BigBuffer
);
1265 children
.Append((wxObject
*)chunk1
);
1267 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_MACRO
, SoloBlockDef
);
1268 chunk
->no_args
= SoloBlockDef
->no_args
;
1269 // chunk->name = copystring(SoloBlockDef->name);
1270 chunk
->macroId
= SoloBlockDef
->macroId
;
1271 children
.Append((wxObject
*)chunk
);
1273 TexChunk
*arg
= new TexChunk(CHUNK_TYPE_ARG
, SoloBlockDef
);
1275 chunk
->children
.Append((wxObject
*)arg
);
1276 // arg->name = copystring(SoloBlockDef->name);
1278 arg
->macroId
= chunk
->macroId
;
1280 pos
= ParseArg(arg
, arg
->children
, buffer
, pos
, NULL
, TRUE
, customMacroArgs
);
1288 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_STRING
);
1289 BigBuffer
[buf_ptr
] = 0;
1291 chunk
->value
= copystring(BigBuffer
);
1292 children
.Append((wxObject
*)chunk
);
1297 if (buffer
[pos
] == '$')
1299 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_MACRO
);
1301 // chunk->name = copystring("$$");
1302 chunk
->macroId
= ltSPECIALDOUBLEDOLLAR
;
1303 children
.Append((wxObject
*)chunk
);
1308 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_MACRO
);
1310 // chunk->name = copystring("_$");
1311 chunk
->macroId
= ltSPECIALDOLLAR
;
1312 children
.Append((wxObject
*)chunk
);
1320 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_STRING
);
1321 BigBuffer
[buf_ptr
] = 0;
1323 chunk
->value
= copystring(BigBuffer
);
1324 children
.Append((wxObject
*)chunk
);
1328 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_MACRO
);
1330 // chunk->name = copystring("_~");
1331 chunk
->macroId
= ltSPECIALTILDE
;
1332 children
.Append((wxObject
*)chunk
);
1335 case '#': // Either treat as a special TeX character or as a macro arg
1339 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_STRING
);
1340 BigBuffer
[buf_ptr
] = 0;
1342 chunk
->value
= copystring(BigBuffer
);
1343 children
.Append((wxObject
*)chunk
);
1347 if (!customMacroArgs
)
1349 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_MACRO
);
1351 // chunk->name = copystring("_#");
1352 chunk
->macroId
= ltSPECIALHASH
;
1353 children
.Append((wxObject
*)chunk
);
1357 if (isdigit(buffer
[pos
]))
1359 int n
= buffer
[pos
] - 48;
1361 wxNode
*node
= customMacroArgs
->children
.Nth(n
-1);
1364 TexChunk
*argChunk
= (TexChunk
*)node
->Data();
1365 children
.Append((wxObject
*)new TexChunk(*argChunk
));
1373 // Remove white space before and after the ampersand,
1374 // since this is probably a table column separator with
1375 // some convenient -- but useless -- white space in the text.
1376 while ((buf_ptr
> 0) && ((BigBuffer
[buf_ptr
-1] == ' ') || (BigBuffer
[buf_ptr
-1] == 9)))
1381 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_STRING
);
1382 BigBuffer
[buf_ptr
] = 0;
1384 chunk
->value
= copystring(BigBuffer
);
1385 children
.Append((wxObject
*)chunk
);
1390 while (buffer
[pos
] == ' ' || buffer
[pos
] == 9)
1393 TexChunk
*chunk
= new TexChunk(CHUNK_TYPE_MACRO
);
1395 // chunk->name = copystring("_&");
1396 chunk
->macroId
= ltSPECIALAMPERSAND
;
1397 children
.Append((wxObject
*)chunk
);
1400 // Eliminate end-of-line comment
1404 while (ch
!= 10 && ch
!= 13 && ch
!= 0)
1409 if (buffer
[pos
] == 10 || buffer
[pos
] == 13)
1412 if (buffer
[pos
] == 10) pos
++; // Eliminate newline following DOS line feed
1419 BigBuffer
[buf_ptr
] = ' ';
1420 BigBuffer
[buf_ptr
+1] = 0;
1427 BigBuffer
[buf_ptr
] = ch
;
1428 BigBuffer
[buf_ptr
+1] = 0;
1439 * Consume as many arguments as the macro definition specifies
1443 int ParseMacroBody(char *macro_name
, TexChunk
*parent
,
1444 int no_args
, char *buffer
, int pos
,
1445 char *environment
, bool parseToBrace
,
1446 TexChunk
*customMacroArgs
)
1449 if (stopRunning
) return pos
;
1451 // Check for a first optional argument
1452 if (buffer
[pos
] == ' ' && buffer
[pos
+1] == '[')
1454 // Fool following code into thinking that this is definitely
1455 // an optional first argument. (If a space before a non-first argument,
1456 // [ is interpreted as a [, not an optional argument.)
1462 if (buffer
[pos
] == '[')
1468 for (i
= 0; i
< no_args
; i
++)
1471 TexChunk
*arg
= new TexChunk(CHUNK_TYPE_ARG
, parent
->def
);
1473 parent
->children
.Append((wxObject
*)arg
);
1474 // arg->name = copystring(macro_name);
1475 arg
->argn
= maxArgs
;
1476 arg
->macroId
= parent
->macroId
;
1478 // To parse the first arg of a 2 arg \begin{thing}{arg} ... \end{thing}
1479 // have to fool parser into thinking this is a regular kind of block.
1481 if ((no_args
== 2) && (i
== 0))
1484 actualEnv
= environment
;
1486 bool isOptional
= FALSE
;
1488 // Remove the first { of the argument so it doesn't get recognized as { ... }
1489 // EatWhiteSpace(buffer, &pos);
1492 // The reason for these tests is to not consume braces that don't
1493 // belong to this macro.
1494 // E.g. {\bf {\small thing}}
1495 if ((pos
> 0) && (buffer
[pos
-1] != ' ') && buffer
[pos
] == '{')
1498 if ((pos
> 0) && (buffer
[pos
-1] != ' ') && (buffer
[pos
] == '['))
1503 else if ((pos
> 1) && (buffer
[pos
-1] != ' ') && (buffer
[pos
+1] == '['))
1509 arg
->optional
= isOptional
;
1511 pos
= ParseArg(arg
, arg
->children
, buffer
, pos
, actualEnv
, parseToBrace
, customMacroArgs
);
1513 // If we've encountered an OPTIONAL argument, go another time around
1514 // the loop, because we've got more than we thought.
1515 // Hopefully optional args don't occur at the end of a macro use
1516 // or we might miss it.
1517 // Don't increment no of times round loop if the first optional arg
1518 // -- we already did it before the loop.
1519 if (arg
->optional
&& (i
> 0))
1522 parent
->no_args
= maxArgs
;
1524 // Tell each argument how many args there are (useful when processing an arg)
1525 wxNode
*node
= parent
->children
.First();
1528 TexChunk
*chunk
= (TexChunk
*)node
->Data();
1529 chunk
->no_args
= maxArgs
;
1530 node
= node
->Next();
1535 bool TexLoadFile(char *filename
)
1537 static char *line_buffer
;
1538 stopRunning
= FALSE
;
1539 strcpy(TexFileRoot
, filename
);
1540 StripExtension(TexFileRoot
);
1541 sprintf(TexBibName
, "%s.bb", TexFileRoot
);
1542 sprintf(TexTmpBibName
, "%s.bb1", TexFileRoot
);
1544 TexPathList
.EnsureFileAccessible(filename
);
1549 line_buffer
= new char[MAX_LINE_BUFFER_SIZE
];
1551 Inputs
[0] = fopen(filename
, "r");
1553 FileNames
[0] = copystring(filename
);
1556 read_a_line(line_buffer
);
1557 ParseMacroBody("toplevel", TopLevel
, 1, line_buffer
, 0, NULL
, TRUE
);
1558 if (Inputs
[0]) fclose(Inputs
[0]);
1565 TexMacroDef::TexMacroDef(int the_id
, char *the_name
, int n
, bool ig
, bool forbidLevel
)
1567 name
= copystring(the_name
);
1571 forbidden
= forbidLevel
;
1574 TexMacroDef::~TexMacroDef(void)
1576 if (name
) delete[] name
;
1579 TexChunk::TexChunk(int the_type
, TexMacroDef
*the_def
)
1591 TexChunk::TexChunk(TexChunk
& toCopy
)
1594 no_args
= toCopy
.no_args
;
1596 macroId
= toCopy
.macroId
;
1599 // name = copystring(toCopy.name);
1605 value
= copystring(toCopy
.value
);
1609 optional
= toCopy
.optional
;
1610 wxNode
*node
= toCopy
.children
.First();
1613 TexChunk
*child
= (TexChunk
*)node
->Data();
1614 children
.Append((wxObject
*)new TexChunk(*child
));
1615 node
= node
->Next();
1619 TexChunk::~TexChunk(void)
1621 // if (name) delete[] name;
1622 if (value
) delete[] value
;
1623 wxNode
*node
= children
.First();
1626 TexChunk
*child
= (TexChunk
*)node
->Data();
1628 wxNode
*next
= node
->Next();
1634 bool IsArgOptional(void) // Is this argument an optional argument?
1636 return isArgOptional
;
1639 int GetNoArgs(void) // Number of args for this macro
1644 /* Gets the text of a chunk on request (must be for small arguments
1649 void GetArgData1(TexChunk
*chunk
)
1651 switch (chunk
->type
)
1653 case CHUNK_TYPE_MACRO
:
1655 TexMacroDef
*def
= chunk
->def
;
1656 if (def
&& def
->ignore
)
1659 if (def
&& (strcmp(def
->name
, "solo block") != 0))
1661 strcat(currentArgData
, "\\");
1662 strcat(currentArgData
, def
->name
);
1665 wxNode
*node
= chunk
->children
.First();
1668 TexChunk
*child_chunk
= (TexChunk
*)node
->Data();
1669 strcat(currentArgData
, "{");
1670 GetArgData1(child_chunk
);
1671 strcat(currentArgData
, "}");
1672 node
= node
->Next();
1676 case CHUNK_TYPE_ARG
:
1678 wxNode
*node
= chunk
->children
.First();
1681 TexChunk
*child_chunk
= (TexChunk
*)node
->Data();
1682 GetArgData1(child_chunk
);
1683 node
= node
->Next();
1687 case CHUNK_TYPE_STRING
:
1690 strcat(currentArgData
, chunk
->value
);
1696 char *GetArgData(TexChunk
*chunk
)
1698 currentArgData
[0] = 0;
1699 GetArgData1(currentArgument
);
1700 haveArgData
= FALSE
;
1701 return currentArgData
;
1704 char *GetArgData(void)
1708 currentArgData
[0] = 0;
1709 GetArgData1(currentArgument
);
1711 return currentArgData
;
1714 TexChunk
*GetArgChunk(void)
1716 return currentArgument
;
1719 TexChunk
*GetNextChunk(void) // Look ahead to the next chunk
1724 TexChunk
*GetTopLevelChunk(void)
1729 int GetCurrentColumn(void)
1731 return currentColumn
;
1735 * Traverses document calling functions to allow the client to
1736 * write out the appropriate stuff
1740 void TraverseFromChunk(TexChunk
*chunk
, wxNode
*thisNode
, bool childrenOnly
)
1743 if (stopRunning
) return;
1745 switch (chunk
->type
)
1747 case CHUNK_TYPE_MACRO
:
1749 TexMacroDef
*def
= chunk
->def
;
1750 if (def
&& def
->ignore
)
1754 OnMacro(chunk
->macroId
, chunk
->no_args
, TRUE
);
1756 wxNode
*node
= chunk
->children
.First();
1759 TexChunk
*child_chunk
= (TexChunk
*)node
->Data();
1760 TraverseFromChunk(child_chunk
, node
);
1761 node
= node
->Next();
1764 if (thisNode
&& thisNode
->Next()) nextChunk
= (TexChunk
*)thisNode
->Next()->Data();
1767 OnMacro(chunk
->macroId
, chunk
->no_args
, FALSE
);
1770 case CHUNK_TYPE_ARG
:
1772 currentArgument
= chunk
;
1774 isArgOptional
= chunk
->optional
;
1775 noArgs
= chunk
->no_args
;
1777 // If OnArgument returns FALSE, don't output.
1779 if (childrenOnly
|| OnArgument(chunk
->macroId
, chunk
->argn
, TRUE
))
1781 wxNode
*node
= chunk
->children
.First();
1784 TexChunk
*child_chunk
= (TexChunk
*)node
->Data();
1785 TraverseFromChunk(child_chunk
, node
);
1786 node
= node
->Next();
1790 currentArgument
= chunk
;
1792 if (thisNode
&& thisNode
->Next()) nextChunk
= (TexChunk
*)thisNode
->Next()->Data();
1794 isArgOptional
= chunk
->optional
;
1795 noArgs
= chunk
->no_args
;
1798 (void)OnArgument(chunk
->macroId
, chunk
->argn
, FALSE
);
1801 case CHUNK_TYPE_STRING
:
1803 extern int issuedNewParagraph
;
1804 extern int forbidResetPar
;
1805 if (chunk
->value
&& (forbidResetPar
== 0))
1807 // If non-whitespace text, we no longer have a new paragraph.
1808 if (issuedNewParagraph
&& !((chunk
->value
[0] == 10 || chunk
->value
[0] == 13 || chunk
->value
[0] == 32)
1809 && chunk
->value
[1] == 0))
1810 issuedNewParagraph
= FALSE
;
1811 TexOutput(chunk
->value
, TRUE
);
1818 void TraverseDocument(void)
1820 TraverseFromChunk(TopLevel
, NULL
);
1823 void SetCurrentOutput(FILE *fd
)
1825 CurrentOutput1
= fd
;
1826 CurrentOutput2
= NULL
;
1829 void SetCurrentOutputs(FILE *fd1
, FILE *fd2
)
1831 CurrentOutput1
= fd1
;
1832 CurrentOutput2
= fd2
;
1835 void AddMacroDef(int the_id
, char *name
, int n
, bool ignore
, bool forbid
)
1837 MacroDefs
.Put(name
, new TexMacroDef(the_id
, name
, n
, ignore
, forbid
));
1840 void TexInitialize(int bufSize
)
1842 InitialiseColourTable();
1844 TexPathList
.AddEnvList("TEXINPUT");
1847 TexPathList
.AddEnvList("TEXINPUTS");
1850 for (i
= 0; i
< 15; i
++)
1854 FileNames
[i
] = NULL
;
1857 IgnorableInputFiles
.Add("psbox.tex");
1858 BigBuffer
= new char[(bufSize
*1000)];
1859 currentArgData
= new char[2000];
1860 TexFileRoot
= new char[300];
1861 TexBibName
= new char[300];
1862 TexTmpBibName
= new char[300];
1863 AddMacroDef(ltTOPLEVEL
, "toplevel", 1);
1864 TopLevel
= new TexChunk(CHUNK_TYPE_MACRO
);
1865 // TopLevel->name = copystring("toplevel");
1866 TopLevel
->macroId
= ltTOPLEVEL
;
1867 TopLevel
->no_args
= 1;
1868 VerbatimMacroDef
= (TexMacroDef
*)MacroDefs
.Get("verbatim");
1871 void TexCleanUp(void)
1874 for (i
= 0; i
< 15; i
++)
1880 subsubsectionNo
= 0;
1883 CurrentOutput1
= NULL
;
1884 CurrentOutput2
= NULL
;
1885 CurrentInputIndex
= 0;
1886 haveArgData
= FALSE
;
1891 TopLevel
= new TexChunk(CHUNK_TYPE_MACRO
);
1892 // TopLevel->name = copystring("toplevel");
1893 TopLevel
->macroId
= ltTOPLEVEL
;
1894 TopLevel
->no_args
= 1;
1896 DocumentTitle
= NULL
;
1897 DocumentAuthor
= NULL
;
1898 DocumentDate
= NULL
;
1899 DocumentStyle
= LATEX_REPORT
;
1900 MinorDocumentStyle
= 0;
1901 BibliographyStyleString
= copystring("plain");
1902 DocumentStyleString
= copystring("report");
1903 MinorDocumentStyleString
= NULL
;
1905 // gt - Changed this so if this is the final pass
1906 // then we DO want to remove these macros, so that
1907 // memory is not MASSIVELY leaked if the user
1908 // does not exit the program, but instead runs
1909 // the program again
1910 if ((passNumber
== 1 && !runTwice
) ||
1911 (passNumber
== 2 && runTwice
))
1913 /* Don't want to remove custom macros after each pass.*/
1915 wxNode
*node
= CustomMacroList
.First();
1918 CustomMacro
*macro
= (CustomMacro
*)node
->Data();
1921 node
= CustomMacroList
.First();
1925 TexReferences
.BeginFind();
1926 wxNode
*node
= TexReferences
.Next();
1929 TexRef
*ref
= (TexRef
*)node
->Data();
1931 node
= TexReferences
.Next();
1933 TexReferences
.Clear();
1935 node
= BibList
.First();
1938 BibEntry
*entry
= (BibEntry
*)node
->Data();
1941 node
= BibList
.First();
1943 CitationList
.Clear();
1944 ResetTopicCounter();
1947 // There is likely to be one set of macros used by all utilities.
1948 void DefineDefaultMacros(void)
1950 // Put names which subsume other names at the TOP
1951 // so they get recognized first
1953 AddMacroDef(ltACCENT_GRAVE
, "`", 1);
1954 AddMacroDef(ltACCENT_ACUTE
, "'", 1);
1955 AddMacroDef(ltACCENT_CARET
, "^", 1);
1956 AddMacroDef(ltACCENT_UMLAUT
, "\"", 1);
1957 AddMacroDef(ltACCENT_TILDE
, "~", 1);
1958 AddMacroDef(ltACCENT_DOT
, ".", 1);
1959 AddMacroDef(ltACCENT_CADILLA
, "c", 1);
1960 AddMacroDef(ltSMALLSPACE1
, ",", 0);
1961 AddMacroDef(ltSMALLSPACE2
, ";", 0);
1963 AddMacroDef(ltABSTRACT
, "abstract", 1);
1964 AddMacroDef(ltADDCONTENTSLINE
, "addcontentsline", 3);
1965 AddMacroDef(ltADDTOCOUNTER
, "addtocounter", 2);
1966 AddMacroDef(ltALEPH
, "aleph", 0);
1967 AddMacroDef(ltALPHA
, "alpha", 0);
1968 AddMacroDef(ltALPH1
, "alph", 1);
1969 AddMacroDef(ltALPH2
, "Alph", 1);
1970 AddMacroDef(ltANGLE
, "angle", 0);
1971 AddMacroDef(ltAPPENDIX
, "appendix", 0);
1972 AddMacroDef(ltAPPROX
, "approx", 0);
1973 AddMacroDef(ltARABIC
, "arabic", 1);
1974 AddMacroDef(ltARRAY
, "array", 1);
1975 AddMacroDef(ltAST
, "ast", 0);
1976 AddMacroDef(ltASYMP
, "asymp", 0);
1977 AddMacroDef(ltAUTHOR
, "author", 1);
1979 AddMacroDef(ltBACKGROUNDCOLOUR
, "backgroundcolour", 1);
1980 AddMacroDef(ltBACKGROUNDIMAGE
, "backgroundimage", 1);
1981 AddMacroDef(ltBACKGROUND
, "background", 1);
1982 AddMacroDef(ltBACKSLASHRAW
, "backslashraw", 0);
1983 AddMacroDef(ltBACKSLASH
, "backslash", 0);
1984 AddMacroDef(ltBASELINESKIP
, "baselineskip", 1);
1985 AddMacroDef(ltBCOL
, "bcol", 2);
1986 AddMacroDef(ltBETA
, "beta", 0);
1987 AddMacroDef(ltBFSERIES
, "bfseries", 1);
1988 AddMacroDef(ltBF
, "bf", 1);
1989 AddMacroDef(ltBIBITEM
, "bibitem", 2); // For convenience, bibitem has 2 args: label and item.
1990 // The Latex syntax permits writing as 2 args.
1991 AddMacroDef(ltBIBLIOGRAPHYSTYLE
, "bibliographystyle", 1);
1992 AddMacroDef(ltBIBLIOGRAPHY
, "bibliography", 1);
1993 AddMacroDef(ltBIGTRIANGLEDOWN
, "bigtriangledown", 0);
1994 AddMacroDef(ltBOT
, "bot", 0);
1995 AddMacroDef(ltBOXIT
, "boxit", 1);
1996 AddMacroDef(ltBOX
, "box", 0);
1997 AddMacroDef(ltBRCLEAR
, "brclear", 0);
1998 AddMacroDef(ltBULLET
, "bullet", 0);
2000 AddMacroDef(ltCAPTIONSTAR
, "caption*", 1);
2001 AddMacroDef(ltCAPTION
, "caption", 1);
2002 AddMacroDef(ltCAP
, "cap", 0);
2003 AddMacroDef(ltCDOTS
, "cdots", 0);
2004 AddMacroDef(ltCDOT
, "cdot", 0);
2005 AddMacroDef(ltCENTERLINE
, "centerline", 1);
2006 AddMacroDef(ltCENTERING
, "centering", 0);
2007 AddMacroDef(ltCENTER
, "center", 1);
2008 AddMacroDef(ltCEXTRACT
, "cextract", 0);
2009 AddMacroDef(ltCHAPTERHEADING
, "chapterheading", 1);
2010 AddMacroDef(ltCHAPTERSTAR
, "chapter*", 1);
2011 AddMacroDef(ltCHAPTER
, "chapter", 1);
2012 AddMacroDef(ltCHI
, "chi", 0);
2013 AddMacroDef(ltCINSERT
, "cinsert", 0);
2014 AddMacroDef(ltCIRC
, "circ", 0);
2015 AddMacroDef(ltCITE
, "cite", 1);
2016 AddMacroDef(ltCLASS
, "class", 1);
2017 AddMacroDef(ltCLEARDOUBLEPAGE
, "cleardoublepage", 0);
2018 AddMacroDef(ltCLEARPAGE
, "clearpage", 0);
2019 AddMacroDef(ltCLINE
, "cline", 1);
2020 AddMacroDef(ltCLIPSFUNC
, "clipsfunc", 3);
2021 AddMacroDef(ltCLUBSUIT
, "clubsuit", 0);
2022 AddMacroDef(ltCOLUMNSEP
, "columnsep", 1);
2023 AddMacroDef(ltCOMMENT
, "comment", 1, TRUE
);
2024 AddMacroDef(ltCONG
, "cong", 0);
2025 AddMacroDef(ltCOPYRIGHT
, "copyright", 0);
2026 AddMacroDef(ltCPARAM
, "cparam", 2);
2027 AddMacroDef(ltCHEAD
, "chead", 1);
2028 AddMacroDef(ltCFOOT
, "cfoot", 1);
2029 AddMacroDef(ltCUP
, "cup", 0);
2031 AddMacroDef(ltDASHV
, "dashv", 0);
2032 AddMacroDef(ltDATE
, "date", 1);
2033 AddMacroDef(ltDELTA
, "delta", 0);
2034 AddMacroDef(ltCAP_DELTA
, "Delta", 0);
2035 AddMacroDef(ltDEFINECOLOUR
, "definecolour", 4);
2036 AddMacroDef(ltDEFINECOLOR
, "definecolor", 4);
2037 AddMacroDef(ltDESCRIPTION
, "description", 1);
2038 AddMacroDef(ltDESTRUCT
, "destruct", 1);
2039 AddMacroDef(ltDIAMOND2
, "diamond2", 0);
2040 AddMacroDef(ltDIAMOND
, "diamond", 0);
2041 AddMacroDef(ltDIV
, "div", 0);
2042 AddMacroDef(ltDOCUMENTCLASS
, "documentclass", 1);
2043 AddMacroDef(ltDOCUMENTSTYLE
, "documentstyle", 1);
2044 AddMacroDef(ltDOCUMENT
, "document", 1);
2045 AddMacroDef(ltDOUBLESPACE
, "doublespace", 1);
2046 AddMacroDef(ltDOTEQ
, "doteq", 0);
2047 AddMacroDef(ltDOWNARROW
, "downarrow", 0);
2048 AddMacroDef(ltDOWNARROW2
, "Downarrow", 0);
2050 AddMacroDef(ltEMPTYSET
, "emptyset", 0);
2051 AddMacroDef(ltEMPH
, "emph", 1);
2052 AddMacroDef(ltEM
, "em", 1);
2053 AddMacroDef(ltENUMERATE
, "enumerate", 1);
2054 AddMacroDef(ltEPSILON
, "epsilon", 0);
2055 AddMacroDef(ltEQUATION
, "equation", 1);
2056 AddMacroDef(ltEQUIV
, "equiv", 0);
2057 AddMacroDef(ltETA
, "eta", 0);
2058 AddMacroDef(ltEVENSIDEMARGIN
, "evensidemargin", 1);
2059 AddMacroDef(ltEXISTS
, "exists", 0);
2061 AddMacroDef(ltFBOX
, "fbox", 1);
2062 AddMacroDef(ltFCOL
, "fcol", 2);
2063 AddMacroDef(ltFIGURE
, "figure", 1);
2064 AddMacroDef(ltFIGURESTAR
, "figure*", 1);
2065 AddMacroDef(ltFLUSHLEFT
, "flushleft", 1);
2066 AddMacroDef(ltFLUSHRIGHT
, "flushright", 1);
2067 AddMacroDef(ltFOLLOWEDLINKCOLOUR
, "followedlinkcolour", 1);
2068 AddMacroDef(ltFOOTHEIGHT
, "footheight", 1);
2069 AddMacroDef(ltFOOTNOTEPOPUP
, "footnotepopup", 2);
2070 AddMacroDef(ltFOOTNOTE
, "footnote", 1);
2071 AddMacroDef(ltFOOTSKIP
, "footskip", 1);
2072 AddMacroDef(ltFORALL
, "forall", 0);
2073 AddMacroDef(ltFRAMEBOX
, "framebox", 1);
2074 AddMacroDef(ltFROWN
, "frown", 0);
2075 AddMacroDef(ltFUNCTIONSECTION
, "functionsection", 1);
2076 AddMacroDef(ltFUNC
, "func", 3);
2077 AddMacroDef(ltFOOTNOTESIZE
, "footnotesize", 0);
2078 AddMacroDef(ltFANCYPLAIN
, "fancyplain", 2);
2080 AddMacroDef(ltGAMMA
, "gamma", 0);
2081 AddMacroDef(ltCAP_GAMMA
, "Gamma", 0);
2082 AddMacroDef(ltGEQ
, "geq", 0);
2083 AddMacroDef(ltGE
, "ge", 0);
2084 AddMacroDef(ltGG
, "gg", 0);
2085 AddMacroDef(ltGLOSSARY
, "glossary", 1);
2086 AddMacroDef(ltGLOSS
, "gloss", 1);
2088 AddMacroDef(ltHEADHEIGHT
, "headheight", 1);
2089 AddMacroDef(ltHEARTSUIT
, "heartsuit", 0);
2090 AddMacroDef(ltHELPGLOSSARY
, "helpglossary", 1);
2091 AddMacroDef(ltHELPIGNORE
, "helpignore", 1, TRUE
);
2092 AddMacroDef(ltHELPONLY
, "helponly", 1);
2093 AddMacroDef(ltHELPINPUT
, "helpinput", 1);
2094 AddMacroDef(ltHELPFONTFAMILY
, "helpfontfamily", 1);
2095 AddMacroDef(ltHELPFONTSIZE
, "helpfontsize", 1);
2096 AddMacroDef(ltHELPREFN
, "helprefn", 2);
2097 AddMacroDef(ltHELPREF
, "helpref", 2);
2098 AddMacroDef(ltHFILL
, "hfill", 0);
2099 AddMacroDef(ltHLINE
, "hline", 0);
2100 AddMacroDef(ltHRULE
, "hrule", 0);
2101 AddMacroDef(ltHSPACESTAR
, "hspace*", 1);
2102 AddMacroDef(ltHSPACE
, "hspace", 1);
2103 AddMacroDef(ltHSKIPSTAR
, "hskip*", 1);
2104 AddMacroDef(ltHSKIP
, "hskip", 1);
2105 AddMacroDef(lthuge
, "huge", 1);
2106 AddMacroDef(ltHuge
, "Huge", 1);
2107 AddMacroDef(ltHUGE
, "HUGE", 1);
2108 AddMacroDef(ltHTMLIGNORE
, "htmlignore", 1);
2109 AddMacroDef(ltHTMLONLY
, "htmlonly", 1);
2111 AddMacroDef(ltIM
, "im", 0);
2112 AddMacroDef(ltINCLUDEONLY
, "includeonly", 1);
2113 AddMacroDef(ltINCLUDE
, "include", 1);
2114 AddMacroDef(ltINDENTED
, "indented", 2);
2115 AddMacroDef(ltINDEX
, "index", 1);
2116 AddMacroDef(ltINPUT
, "input", 1, TRUE
);
2117 AddMacroDef(ltIOTA
, "iota", 0);
2118 AddMacroDef(ltITEMIZE
, "itemize", 1);
2119 AddMacroDef(ltITEM
, "item", 0);
2120 AddMacroDef(ltIMAGEMAP
, "imagemap", 3);
2121 AddMacroDef(ltIMAGEL
, "imagel", 2);
2122 AddMacroDef(ltIMAGER
, "imager", 2);
2123 AddMacroDef(ltIMAGE
, "image", 2);
2124 AddMacroDef(ltIN
, "in", 0);
2125 AddMacroDef(ltINFTY
, "infty", 0);
2126 AddMacroDef(ltITSHAPE
, "itshape", 1);
2127 AddMacroDef(ltIT
, "it", 1);
2128 AddMacroDef(ltITEMSEP
, "itemsep", 1);
2129 AddMacroDef(ltINSERTATLEVEL
, "insertatlevel", 2);
2131 AddMacroDef(ltKAPPA
, "kappa", 0);
2132 AddMacroDef(ltKILL
, "kill", 0);
2134 AddMacroDef(ltLABEL
, "label", 1);
2135 AddMacroDef(ltLAMBDA
, "lambda", 0);
2136 AddMacroDef(ltCAP_LAMBDA
, "Lambda", 0);
2137 AddMacroDef(ltlarge
, "large", 1);
2138 AddMacroDef(ltLarge
, "Large", 1);
2139 AddMacroDef(ltLARGE
, "LARGE", 1);
2140 AddMacroDef(ltLATEXIGNORE
, "latexignore", 1);
2141 AddMacroDef(ltLATEXONLY
, "latexonly", 1);
2142 AddMacroDef(ltLATEX
, "LaTeX", 0);
2143 AddMacroDef(ltLBOX
, "lbox", 1);
2144 AddMacroDef(ltLBRACERAW
, "lbraceraw", 0);
2145 AddMacroDef(ltLDOTS
, "ldots", 0);
2146 AddMacroDef(ltLEQ
, "leq", 0);
2147 AddMacroDef(ltLE
, "le", 0);
2148 AddMacroDef(ltLEFTARROW
, "leftarrow", 0);
2149 AddMacroDef(ltLEFTRIGHTARROW
, "leftrightarrow", 0);
2150 AddMacroDef(ltLEFTARROW2
, "Leftarrow", 0);
2151 AddMacroDef(ltLEFTRIGHTARROW2
, "Leftrightarrow", 0);
2152 AddMacroDef(ltLINEBREAK
, "linebreak", 0);
2153 AddMacroDef(ltLINKCOLOUR
, "linkcolour", 1);
2154 AddMacroDef(ltLISTOFFIGURES
, "listoffigures", 0);
2155 AddMacroDef(ltLISTOFTABLES
, "listoftables", 0);
2156 AddMacroDef(ltLHEAD
, "lhead", 1);
2157 AddMacroDef(ltLFOOT
, "lfoot", 1);
2158 AddMacroDef(ltLOWERCASE
, "lowercase", 1);
2159 AddMacroDef(ltLL
, "ll", 0);
2161 AddMacroDef(ltMAKEGLOSSARY
, "makeglossary", 0);
2162 AddMacroDef(ltMAKEINDEX
, "makeindex", 0);
2163 AddMacroDef(ltMAKETITLE
, "maketitle", 0);
2164 AddMacroDef(ltMARKRIGHT
, "markright", 1);
2165 AddMacroDef(ltMARKBOTH
, "markboth", 2);
2166 AddMacroDef(ltMARGINPARWIDTH
, "marginparwidth", 1);
2167 AddMacroDef(ltMARGINPARSEP
, "marginparsep", 1);
2168 AddMacroDef(ltMARGINPARODD
, "marginparodd", 1);
2169 AddMacroDef(ltMARGINPAREVEN
, "marginpareven", 1);
2170 AddMacroDef(ltMARGINPAR
, "marginpar", 1);
2171 AddMacroDef(ltMBOX
, "mbox", 1);
2172 AddMacroDef(ltMDSERIES
, "mdseries", 1);
2173 AddMacroDef(ltMEMBERSECTION
, "membersection", 1);
2174 AddMacroDef(ltMEMBER
, "member", 2);
2175 AddMacroDef(ltMID
, "mid", 0);
2176 AddMacroDef(ltMODELS
, "models", 0);
2177 AddMacroDef(ltMP
, "mp", 0);
2178 AddMacroDef(ltMULTICOLUMN
, "multicolumn", 3);
2179 AddMacroDef(ltMU
, "mu", 0);
2181 AddMacroDef(ltNABLA
, "nabla", 0);
2182 AddMacroDef(ltNEG
, "neg", 0);
2183 AddMacroDef(ltNEQ
, "neq", 0);
2184 AddMacroDef(ltNEWCOUNTER
, "newcounter", 1, FALSE
, (bool)FORBID_ABSOLUTELY
);
2185 AddMacroDef(ltNEWLINE
, "newline", 0);
2186 AddMacroDef(ltNEWPAGE
, "newpage", 0);
2187 AddMacroDef(ltNI
, "ni", 0);
2188 AddMacroDef(ltNOCITE
, "nocite", 1);
2189 AddMacroDef(ltNOINDENT
, "noindent", 0);
2190 AddMacroDef(ltNOLINEBREAK
, "nolinebreak", 0);
2191 AddMacroDef(ltNOPAGEBREAK
, "nopagebreak", 0);
2192 AddMacroDef(ltNORMALSIZE
, "normalsize", 1);
2193 AddMacroDef(ltNORMALBOX
, "normalbox", 1);
2194 AddMacroDef(ltNORMALBOXD
, "normalboxd", 1);
2195 AddMacroDef(ltNOTEQ
, "noteq", 0);
2196 AddMacroDef(ltNOTIN
, "notin", 0);
2197 AddMacroDef(ltNOTSUBSET
, "notsubset", 0);
2198 AddMacroDef(ltNU
, "nu", 0);
2200 AddMacroDef(ltODDSIDEMARGIN
, "oddsidemargin", 1);
2201 AddMacroDef(ltOMEGA
, "omega", 0);
2202 AddMacroDef(ltCAP_OMEGA
, "Omega", 0);
2203 AddMacroDef(ltONECOLUMN
, "onecolumn", 0);
2204 AddMacroDef(ltOPLUS
, "oplus", 0);
2205 AddMacroDef(ltOSLASH
, "oslash", 0);
2206 AddMacroDef(ltOTIMES
, "otimes", 0);
2208 AddMacroDef(ltPAGEBREAK
, "pagebreak", 0);
2209 AddMacroDef(ltPAGEREF
, "pageref", 1);
2210 AddMacroDef(ltPAGESTYLE
, "pagestyle", 1);
2211 AddMacroDef(ltPAGENUMBERING
, "pagenumbering", 1);
2212 AddMacroDef(ltPARAGRAPHSTAR
, "paragraph*", 1);
2213 AddMacroDef(ltPARAGRAPH
, "paragraph", 1);
2214 AddMacroDef(ltPARALLEL
, "parallel", 0);
2215 AddMacroDef(ltPARAM
, "param", 2);
2216 AddMacroDef(ltPARINDENT
, "parindent", 1);
2217 AddMacroDef(ltPARSKIP
, "parskip", 1);
2218 AddMacroDef(ltPARTIAL
, "partial", 0);
2219 AddMacroDef(ltPARTSTAR
, "part*", 1);
2220 AddMacroDef(ltPART
, "part", 1);
2221 AddMacroDef(ltPAR
, "par", 0);
2222 AddMacroDef(ltPERP
, "perp", 0);
2223 AddMacroDef(ltPHI
, "phi", 0);
2224 AddMacroDef(ltCAP_PHI
, "Phi", 0);
2225 AddMacroDef(ltPFUNC
, "pfunc", 3);
2226 AddMacroDef(ltPICTURE
, "picture", 1);
2227 AddMacroDef(ltPI
, "pi", 0);
2228 AddMacroDef(ltCAP_PI
, "Pi", 0);
2229 AddMacroDef(ltPM
, "pm", 0);
2230 AddMacroDef(ltPOPREFONLY
, "poprefonly", 1);
2231 AddMacroDef(ltPOPREF
, "popref", 2);
2232 AddMacroDef(ltPOUNDS
, "pounds", 0);
2233 AddMacroDef(ltPREC
, "prec", 0);
2234 AddMacroDef(ltPRECEQ
, "preceq", 0);
2235 AddMacroDef(ltPRINTINDEX
, "printindex", 0);
2236 AddMacroDef(ltPROPTO
, "propto", 0);
2237 AddMacroDef(ltPSBOXTO
, "psboxto", 1, FALSE
, (bool)FORBID_ABSOLUTELY
);
2238 AddMacroDef(ltPSBOX
, "psbox", 1, FALSE
, (bool)FORBID_ABSOLUTELY
);
2239 AddMacroDef(ltPSI
, "psi", 0);
2240 AddMacroDef(ltCAP_PSI
, "Psi", 0);
2242 AddMacroDef(ltQUOTE
, "quote", 1);
2243 AddMacroDef(ltQUOTATION
, "quotation", 1);
2245 AddMacroDef(ltRAGGEDBOTTOM
, "raggedbottom", 0);
2246 AddMacroDef(ltRAGGEDLEFT
, "raggedleft", 0);
2247 AddMacroDef(ltRAGGEDRIGHT
, "raggedright", 0);
2248 AddMacroDef(ltRBRACERAW
, "rbraceraw", 0);
2249 AddMacroDef(ltREF
, "ref", 1);
2250 AddMacroDef(ltREGISTERED
, "registered", 0);
2251 AddMacroDef(ltRE
, "we", 0);
2252 AddMacroDef(ltRHO
, "rho", 0);
2253 AddMacroDef(ltRIGHTARROW
, "rightarrow", 0);
2254 AddMacroDef(ltRIGHTARROW2
, "rightarrow2", 0);
2255 AddMacroDef(ltRMFAMILY
, "rmfamily", 1);
2256 AddMacroDef(ltRM
, "rm", 1);
2257 AddMacroDef(ltROMAN
, "roman", 1);
2258 AddMacroDef(ltROMAN2
, "Roman", 1);
2259 // AddMacroDef(lt"row", 1);
2260 AddMacroDef(ltRTFSP
, "rtfsp", 0);
2261 AddMacroDef(ltRTFIGNORE
, "rtfignore", 1);
2262 AddMacroDef(ltRTFONLY
, "rtfonly", 1);
2263 AddMacroDef(ltRULEDROW
, "ruledrow", 1);
2264 AddMacroDef(ltDRULED
, "druled", 1);
2265 AddMacroDef(ltRULE
, "rule", 2);
2266 AddMacroDef(ltRHEAD
, "rhead", 1);
2267 AddMacroDef(ltRFOOT
, "rfoot", 1);
2268 AddMacroDef(ltROW
, "row", 1);
2270 AddMacroDef(ltSCSHAPE
, "scshape", 1);
2271 AddMacroDef(ltSC
, "sc", 1);
2272 AddMacroDef(ltSECTIONHEADING
, "sectionheading", 1);
2273 AddMacroDef(ltSECTIONSTAR
, "section*", 1);
2274 AddMacroDef(ltSECTION
, "section", 1);
2275 AddMacroDef(ltSETCOUNTER
, "setcounter", 2);
2276 AddMacroDef(ltSFFAMILY
, "sffamily", 1);
2277 AddMacroDef(ltSF
, "sf", 1);
2278 AddMacroDef(ltSHARP
, "sharp", 0);
2279 AddMacroDef(ltSHORTCITE
, "shortcite", 1);
2280 AddMacroDef(ltSIGMA
, "sigma", 0);
2281 AddMacroDef(ltCAP_SIGMA
, "Sigma", 0);
2282 AddMacroDef(ltSIM
, "sim", 0);
2283 AddMacroDef(ltSIMEQ
, "simeq", 0);
2284 AddMacroDef(ltSINGLESPACE
, "singlespace", 1);
2285 AddMacroDef(ltSIZEDBOX
, "sizedbox", 2);
2286 AddMacroDef(ltSIZEDBOXD
, "sizedboxd", 2);
2287 AddMacroDef(ltSLOPPYPAR
, "sloppypar", 1);
2288 AddMacroDef(ltSLOPPY
, "sloppy", 0);
2289 AddMacroDef(ltSLSHAPE
, "slshape", 1);
2290 AddMacroDef(ltSL
, "sl", 1);
2291 AddMacroDef(ltSMALL
, "small", 1);
2292 AddMacroDef(ltSMILE
, "smile", 0);
2293 AddMacroDef(ltSS
, "ss", 0);
2294 AddMacroDef(ltSTAR
, "star", 0);
2295 AddMacroDef(ltSUBITEM
, "subitem", 0);
2296 AddMacroDef(ltSUBPARAGRAPHSTAR
, "subparagraph*", 1);
2297 AddMacroDef(ltSUBPARAGRAPH
, "subparagraph", 1);
2298 AddMacroDef(ltSPECIAL
, "special", 1);
2299 AddMacroDef(ltSUBSECTIONSTAR
, "subsection*", 1);
2300 AddMacroDef(ltSUBSECTION
, "subsection", 1);
2301 AddMacroDef(ltSUBSETEQ
, "subseteq", 0);
2302 AddMacroDef(ltSUBSET
, "subset", 0);
2303 AddMacroDef(ltSUCC
, "succ", 0);
2304 AddMacroDef(ltSUCCEQ
, "succeq", 0);
2305 AddMacroDef(ltSUPSETEQ
, "supseteq", 0);
2306 AddMacroDef(ltSUPSET
, "supset", 0);
2307 AddMacroDef(ltSUBSUBSECTIONSTAR
,"subsubsection*", 1);
2308 AddMacroDef(ltSUBSUBSECTION
, "subsubsection", 1);
2309 AddMacroDef(ltSUPERTABULAR
, "supertabular", 2, FALSE
);
2310 AddMacroDef(ltSURD
, "surd", 0);
2311 AddMacroDef(ltSCRIPTSIZE
, "scriptsize", 1);
2312 AddMacroDef(ltSETHEADER
, "setheader", 6);
2313 AddMacroDef(ltSETFOOTER
, "setfooter", 6);
2314 AddMacroDef(ltSETHOTSPOTCOLOUR
, "sethotspotcolour", 1);
2315 AddMacroDef(ltSETHOTSPOTCOLOR
, "sethotspotcolor", 1);
2316 AddMacroDef(ltSETHOTSPOTUNDERLINE
, "sethotspotunderline", 1);
2317 AddMacroDef(ltSETTRANSPARENCY
, "settransparency", 1);
2318 AddMacroDef(ltSPADESUIT
, "spadesuit", 0);
2320 AddMacroDef(ltTABBING
, "tabbing", 2);
2321 AddMacroDef(ltTABLEOFCONTENTS
, "tableofcontents", 0);
2322 AddMacroDef(ltTABLE
, "table", 1);
2323 AddMacroDef(ltTABULAR
, "tabular", 2, FALSE
);
2324 AddMacroDef(ltTAB
, "tab", 0);
2325 AddMacroDef(ltTAU
, "tau", 0);
2326 AddMacroDef(ltTEXTRM
, "textrm", 1);
2327 AddMacroDef(ltTEXTSF
, "textsf", 1);
2328 AddMacroDef(ltTEXTTT
, "texttt", 1);
2329 AddMacroDef(ltTEXTBF
, "textbf", 1);
2330 AddMacroDef(ltTEXTIT
, "textit", 1);
2331 AddMacroDef(ltTEXTSL
, "textsl", 1);
2332 AddMacroDef(ltTEXTSC
, "textsc", 1);
2333 AddMacroDef(ltTEXTWIDTH
, "textwidth", 1);
2334 AddMacroDef(ltTEXTHEIGHT
, "textheight", 1);
2335 AddMacroDef(ltTEXTCOLOUR
, "textcolour", 1);
2336 AddMacroDef(ltTEX
, "TeX", 0);
2337 AddMacroDef(ltTHEBIBLIOGRAPHY
, "thebibliography", 2);
2338 AddMacroDef(ltTHETA
, "theta", 0);
2339 AddMacroDef(ltTIMES
, "times", 0);
2340 AddMacroDef(ltCAP_THETA
, "Theta", 0);
2341 AddMacroDef(ltTITLEPAGE
, "titlepage", 1);
2342 AddMacroDef(ltTITLE
, "title", 1);
2343 AddMacroDef(ltTINY
, "tiny", 1);
2344 AddMacroDef(ltTODAY
, "today", 0);
2345 AddMacroDef(ltTOPMARGIN
, "topmargin", 1);
2346 AddMacroDef(ltTOPSKIP
, "topskip", 1);
2347 AddMacroDef(ltTRIANGLE
, "triangle", 0);
2348 AddMacroDef(ltTTFAMILY
, "ttfamily", 1);
2349 AddMacroDef(ltTT
, "tt", 1);
2350 AddMacroDef(ltTYPEIN
, "typein", 1);
2351 AddMacroDef(ltTYPEOUT
, "typeout", 1);
2352 AddMacroDef(ltTWOCOLWIDTHA
, "twocolwidtha", 1);
2353 AddMacroDef(ltTWOCOLWIDTHB
, "twocolwidthb", 1);
2354 AddMacroDef(ltTWOCOLSPACING
, "twocolspacing", 1);
2355 AddMacroDef(ltTWOCOLITEMRULED
, "twocolitemruled", 2);
2356 AddMacroDef(ltTWOCOLITEM
, "twocolitem", 2);
2357 AddMacroDef(ltTWOCOLLIST
, "twocollist", 1);
2358 AddMacroDef(ltTWOCOLUMN
, "twocolumn", 0);
2359 AddMacroDef(ltTHEPAGE
, "thepage", 0);
2360 AddMacroDef(ltTHECHAPTER
, "thechapter", 0);
2361 AddMacroDef(ltTHESECTION
, "thesection", 0);
2362 AddMacroDef(ltTHISPAGESTYLE
, "thispagestyle", 1);
2364 AddMacroDef(ltUNDERLINE
, "underline", 1);
2365 AddMacroDef(ltUPSILON
, "upsilon", 0);
2366 AddMacroDef(ltCAP_UPSILON
, "Upsilon", 0);
2367 AddMacroDef(ltUPARROW
, "uparrow", 0);
2368 AddMacroDef(ltUPARROW2
, "Uparrow", 0);
2369 AddMacroDef(ltUPPERCASE
, "uppercase", 1);
2370 AddMacroDef(ltUPSHAPE
, "upshape", 1);
2371 AddMacroDef(ltURLREF
, "urlref", 2);
2372 AddMacroDef(ltUSEPACKAGE
, "usepackage", 1);
2374 AddMacroDef(ltVAREPSILON
, "varepsilon", 0);
2375 AddMacroDef(ltVARPHI
, "varphi", 0);
2376 AddMacroDef(ltVARPI
, "varpi", 0);
2377 AddMacroDef(ltVARRHO
, "varrho", 0);
2378 AddMacroDef(ltVARSIGMA
, "varsigma", 0);
2379 AddMacroDef(ltVARTHETA
, "vartheta", 0);
2380 AddMacroDef(ltVDOTS
, "vdots", 0);
2381 AddMacroDef(ltVEE
, "vee", 0);
2382 AddMacroDef(ltVERBATIMINPUT
, "verbatiminput", 1);
2383 AddMacroDef(ltVERBATIM
, "verbatim", 1);
2384 AddMacroDef(ltVERBSTAR
, "verb*", 1);
2385 AddMacroDef(ltVERB
, "verb", 1);
2386 AddMacroDef(ltVERSE
, "verse", 1);
2387 AddMacroDef(ltVFILL
, "vfill", 0);
2388 AddMacroDef(ltVLINE
, "vline", 0);
2389 AddMacroDef(ltVOID
, "void", 0);
2390 AddMacroDef(ltVDASH
, "vdash", 0);
2391 AddMacroDef(ltVRULE
, "vrule", 0);
2392 AddMacroDef(ltVSPACESTAR
, "vspace*", 1);
2393 AddMacroDef(ltVSKIPSTAR
, "vskip*", 1);
2394 AddMacroDef(ltVSPACE
, "vspace", 1);
2395 AddMacroDef(ltVSKIP
, "vskip", 1);
2397 AddMacroDef(ltWEDGE
, "wedge", 0);
2398 AddMacroDef(ltWXCLIPS
, "wxclips", 0);
2399 AddMacroDef(ltWINHELPIGNORE
, "winhelpignore", 1);
2400 AddMacroDef(ltWINHELPONLY
, "winhelponly", 1);
2401 AddMacroDef(ltWP
, "wp", 0);
2403 AddMacroDef(ltXI
, "xi", 0);
2404 AddMacroDef(ltCAP_XI
, "Xi", 0);
2405 AddMacroDef(ltXLPIGNORE
, "xlpignore", 1);
2406 AddMacroDef(ltXLPONLY
, "xlponly", 1);
2408 AddMacroDef(ltZETA
, "zeta", 0);
2410 AddMacroDef(ltSPACE
, " ", 0);
2411 AddMacroDef(ltBACKSLASHCHAR
, "\\", 0);
2412 AddMacroDef(ltPIPE
, "|", 0);
2413 AddMacroDef(ltFORWARDSLASH
, "/", 0);
2414 AddMacroDef(ltUNDERSCORE
, "_", 0);
2415 AddMacroDef(ltAMPERSAND
, "&", 0);
2416 AddMacroDef(ltPERCENT
, "%", 0);
2417 AddMacroDef(ltDOLLAR
, "$", 0);
2418 AddMacroDef(ltHASH
, "#", 0);
2419 AddMacroDef(ltLPARENTH
, "(", 0);
2420 AddMacroDef(ltRPARENTH
, ")", 0);
2421 AddMacroDef(ltLBRACE
, "{", 0);
2422 AddMacroDef(ltRBRACE
, "}", 0);
2423 // AddMacroDef(ltEQUALS, "=", 0);
2424 AddMacroDef(ltRANGLEBRA
, ">", 0);
2425 AddMacroDef(ltLANGLEBRA
, "<", 0);
2426 AddMacroDef(ltPLUS
, "+", 0);
2427 AddMacroDef(ltDASH
, "-", 0);
2428 AddMacroDef(ltAT_SYMBOL
, "@", 0);
2429 // AddMacroDef(ltSINGLEQUOTE, "'", 0);
2430 // AddMacroDef(ltBACKQUOTE, "`", 0);
2434 * Default behaviour, should be called by client if can't match locally.
2438 // Called on start/end of macro examination
2439 void DefaultOnMacro(int macroId
, int no_args
, bool start
)
2443 // Default behaviour for abstract
2448 // Write the heading
2449 FakeCurrentSection(AbstractNameString
);
2450 OnMacro(ltPAR
, 0, TRUE
);
2451 OnMacro(ltPAR
, 0, FALSE
);
2455 if (DocumentStyle
== LATEX_ARTICLE
)
2463 // Default behaviour for glossary
2464 case ltHELPGLOSSARY
:
2468 // Write the heading
2469 FakeCurrentSection(GlossaryNameString
);
2470 OnMacro(ltPAR
, 0, TRUE
);
2471 OnMacro(ltPAR
, 0, FALSE
);
2472 if ((convertMode
== TEX_RTF
) && !winHelp
)
2474 OnMacro(ltPAR
, 0, TRUE
);
2475 OnMacro(ltPAR
, 0, FALSE
);
2480 case ltSPECIALAMPERSAND
:
2487 TexOutput("<<", TRUE
);
2491 TexOutput(">>", TRUE
);
2495 TexOutput("~", TRUE
);
2499 TexOutput("~", TRUE
);
2501 case ltSPECIALTILDE
:
2503 TexOutput(" ", TRUE
);
2507 TexOutput("_", TRUE
);
2511 TexOutput("#", TRUE
);
2515 TexOutput("&", TRUE
);
2519 TexOutput(" ", TRUE
);
2523 TexOutput("|", TRUE
);
2527 TexOutput("%", TRUE
);
2531 TexOutput("$", TRUE
);
2535 TexOutput("", TRUE
);
2539 TexOutput("", TRUE
);
2543 TexOutput("{", TRUE
);
2547 TexOutput("}", TRUE
);
2551 TexOutput("(c)", TRUE
);
2555 TexOutput("(r)", TRUE
);
2559 TexOutput("\\", TRUE
);
2564 TexOutput("...", TRUE
);
2568 TexOutput("|", TRUE
);
2572 TexOutput("LaTeX", TRUE
);
2576 TexOutput("TeX", TRUE
);
2580 TexOutput("£", TRUE
);
2582 case ltSPECIALDOUBLEDOLLAR
: // Interpret as center
2583 OnMacro(ltCENTER
, no_args
, start
);
2589 OnMacro(ltIT
, no_args
, start
);
2592 case ltPARAGRAPHSTAR
:
2593 case ltSUBPARAGRAPH
:
2594 case ltSUBPARAGRAPHSTAR
:
2595 OnMacro(ltSUBSUBSECTION
, no_args
, start
);
2603 TexOutput(ctime(&when
), TRUE
);
2614 if (start
) TexOutput("alpha");
2617 if (start
) TexOutput("beta");
2620 if (start
) TexOutput("gamma");
2623 if (start
) TexOutput("delta");
2627 if (start
) TexOutput("epsilon");
2630 if (start
) TexOutput("zeta");
2633 if (start
) TexOutput("eta");
2637 if (start
) TexOutput("theta");
2640 if (start
) TexOutput("iota");
2643 if (start
) TexOutput("kappa");
2646 if (start
) TexOutput("lambda");
2649 if (start
) TexOutput("mu");
2652 if (start
) TexOutput("nu");
2655 if (start
) TexOutput("xi");
2659 if (start
) TexOutput("pi");
2663 if (start
) TexOutput("rho");
2667 if (start
) TexOutput("sigma");
2670 if (start
) TexOutput("tau");
2673 if (start
) TexOutput("upsilon");
2677 if (start
) TexOutput("phi");
2680 if (start
) TexOutput("chi");
2683 if (start
) TexOutput("psi");
2686 if (start
) TexOutput("omega");
2689 if (start
) TexOutput("GAMMA");
2692 if (start
) TexOutput("DELTA");
2695 if (start
) TexOutput("THETA");
2698 if (start
) TexOutput("LAMBDA");
2701 if (start
) TexOutput("XI");
2704 if (start
) TexOutput("PI");
2707 if (start
) TexOutput("SIGMA");
2710 if (start
) TexOutput("UPSILON");
2713 if (start
) TexOutput("PHI");
2716 if (start
) TexOutput("PSI");
2719 if (start
) TexOutput("OMEGA");
2722 // Binary operation symbols
2725 if (start
) TexOutput("<=");
2728 if (start
) TexOutput("<<");
2731 if (start
) TexOutput("SUBSET");
2734 if (start
) TexOutput("SUBSETEQ");
2737 if (start
) TexOutput("IN");
2740 if (start
) TexOutput("VDASH");
2743 if (start
) TexOutput("MODELS");
2747 if (start
) TexOutput(">=");
2750 if (start
) TexOutput(">>");
2753 if (start
) TexOutput("SUPSET");
2756 if (start
) TexOutput("SUPSETEQ");
2759 if (start
) TexOutput("NI");
2762 if (start
) TexOutput("DASHV");
2765 if (start
) TexOutput("PERP");
2768 if (start
) TexOutput("NEQ");
2771 if (start
) TexOutput("DOTEQ");
2774 if (start
) TexOutput("APPROX");
2777 if (start
) TexOutput("CONG");
2780 if (start
) TexOutput("EQUIV");
2783 if (start
) TexOutput("PROPTO");
2786 if (start
) TexOutput("PREC");
2789 if (start
) TexOutput("PRECEQ");
2792 if (start
) TexOutput("|");
2795 if (start
) TexOutput("~");
2798 if (start
) TexOutput("SIMEQ");
2801 if (start
) TexOutput("ASYMP");
2804 if (start
) TexOutput(":-)");
2807 if (start
) TexOutput(":-(");
2810 if (start
) TexOutput("SUCC");
2813 if (start
) TexOutput("SUCCEQ");
2816 if (start
) TexOutput("|");
2819 // Negated relation symbols
2821 if (start
) TexOutput("!=");
2824 if (start
) TexOutput("NOTIN");
2827 if (start
) TexOutput("NOTSUBSET");
2832 if (start
) TexOutput("<--");
2835 if (start
) TexOutput("<==");
2838 if (start
) TexOutput("-->");
2841 if (start
) TexOutput("==>");
2843 case ltLEFTRIGHTARROW
:
2844 if (start
) TexOutput("<-->");
2846 case ltLEFTRIGHTARROW2
:
2847 if (start
) TexOutput("<==>");
2850 if (start
) TexOutput("UPARROW");
2853 if (start
) TexOutput("UPARROW2");
2856 if (start
) TexOutput("DOWNARROW");
2859 if (start
) TexOutput("DOWNARROW2");
2861 // Miscellaneous symbols
2863 if (start
) TexOutput("ALEPH");
2866 if (start
) TexOutput("WP");
2869 if (start
) TexOutput("RE");
2872 if (start
) TexOutput("IM");
2875 if (start
) TexOutput("EMPTYSET");
2878 if (start
) TexOutput("NABLA");
2881 if (start
) TexOutput("SURD");
2884 if (start
) TexOutput("PARTIAL");
2887 if (start
) TexOutput("BOT");
2890 if (start
) TexOutput("FORALL");
2893 if (start
) TexOutput("EXISTS");
2896 if (start
) TexOutput("NEG");
2899 if (start
) TexOutput("SHARP");
2902 if (start
) TexOutput("ANGLE");
2905 if (start
) TexOutput("TRIANGLE");
2908 if (start
) TexOutput("CLUBSUIT");
2911 if (start
) TexOutput("DIAMONDSUIT");
2914 if (start
) TexOutput("HEARTSUIT");
2917 if (start
) TexOutput("SPADESUIT");
2920 if (start
) TexOutput("INFTY");
2923 if (start
) TexOutput("PM");
2926 if (start
) TexOutput("MP");
2929 if (start
) TexOutput("TIMES");
2932 if (start
) TexOutput("DIV");
2935 if (start
) TexOutput("CDOT");
2938 if (start
) TexOutput("AST");
2941 if (start
) TexOutput("STAR");
2944 if (start
) TexOutput("CAP");
2947 if (start
) TexOutput("CUP");
2950 if (start
) TexOutput("VEE");
2953 if (start
) TexOutput("WEDGE");
2956 if (start
) TexOutput("CIRC");
2959 if (start
) TexOutput("BULLET");
2962 if (start
) TexOutput("DIAMOND");
2965 if (start
) TexOutput("OSLASH");
2968 if (start
) TexOutput("BOX");
2971 if (start
) TexOutput("DIAMOND2");
2973 case ltBIGTRIANGLEDOWN
:
2974 if (start
) TexOutput("BIGTRIANGLEDOWN");
2977 if (start
) TexOutput("OPLUS");
2980 if (start
) TexOutput("OTIMES");
2983 if (start
) TexOutput("s");
2985 case ltBACKSLASHRAW
:
2986 if (start
) TexOutput("\\");
2989 if (start
) TexOutput("{");
2992 if (start
) TexOutput("}");
2996 if (start
) TexOutput(" ");
3003 // Called on start/end of argument examination
3004 bool DefaultOnArgument(int macroId
, int arg_no
, bool start
)
3010 if (arg_no
== 1 && start
)
3012 char *refName
= GetArgData();
3015 TexRef
*texRef
= FindReference(refName
);
3018 // Must strip the 'section' or 'chapter' or 'figure' text
3019 // from a normal 'ref' reference
3021 strcpy(buf
, texRef
->sectionNumber
);
3022 int len
= strlen(buf
);
3024 if (strcmp(buf
, "??") != 0)
3036 TexOutput(texRef
->sectionNumber
+ i
, TRUE
);
3041 TexOutput("??", TRUE
);
3042 sprintf(buf
, "Warning: unresolved reference %s.", refName
);
3046 else TexOutput("??", TRUE
);
3058 if (start
&& (arg_no
== 1))
3059 DocumentAuthor
= GetArgChunk();
3065 if (start
&& (arg_no
== 1))
3066 DocumentDate
= GetArgChunk();
3072 if (start
&& (arg_no
== 1))
3073 DocumentTitle
= GetArgChunk();
3077 case ltDOCUMENTCLASS
:
3078 case ltDOCUMENTSTYLE
:
3080 if (start
&& !IsArgOptional())
3082 DocumentStyleString
= copystring(GetArgData());
3083 if (strncmp(DocumentStyleString
, "art", 3) == 0)
3084 DocumentStyle
= LATEX_ARTICLE
;
3085 else if (strncmp(DocumentStyleString
, "rep", 3) == 0)
3086 DocumentStyle
= LATEX_REPORT
;
3087 else if (strncmp(DocumentStyleString
, "book", 4) == 0 ||
3088 strncmp(DocumentStyleString
, "thesis", 6) == 0)
3089 DocumentStyle
= LATEX_BOOK
;
3090 else if (strncmp(DocumentStyleString
, "letter", 6) == 0)
3091 DocumentStyle
= LATEX_LETTER
;
3092 else if (strncmp(DocumentStyleString
, "slides", 6) == 0)
3093 DocumentStyle
= LATEX_SLIDES
;
3095 if (StringMatch("10", DocumentStyleString
))
3097 else if (StringMatch("11", DocumentStyleString
))
3099 else if (StringMatch("12", DocumentStyleString
))
3102 OnMacro(ltHELPFONTSIZE
, 1, TRUE
);
3103 sprintf(currentArgData
, "%d", normalFont
);
3105 OnArgument(ltHELPFONTSIZE
, 1, TRUE
);
3106 OnArgument(ltHELPFONTSIZE
, 1, FALSE
);
3107 haveArgData
= FALSE
;
3108 OnMacro(ltHELPFONTSIZE
, 1, FALSE
);
3110 else if (start
&& IsArgOptional())
3112 MinorDocumentStyleString
= copystring(GetArgData());
3114 if (StringMatch("10", MinorDocumentStyleString
))
3116 else if (StringMatch("11", MinorDocumentStyleString
))
3118 else if (StringMatch("12", MinorDocumentStyleString
))
3124 case ltBIBLIOGRAPHYSTYLE
:
3126 if (start
&& !IsArgOptional())
3127 BibliographyStyleString
= copystring(GetArgData());
3133 if (start
&& !IsArgOptional())
3135 if (PageStyle
) delete[] PageStyle
;
3136 PageStyle
= copystring(GetArgData());
3144 if (start && !IsArgOptional())
3145 LeftHeader = GetArgChunk();
3151 if (start && !IsArgOptional())
3152 LeftFooter = GetArgChunk();
3158 if (start && !IsArgOptional())
3159 CentreHeader = GetArgChunk();
3165 if (start && !IsArgOptional())
3166 CentreFooter = GetArgChunk();
3172 if (start && !IsArgOptional())
3173 RightHeader = GetArgChunk();
3179 if (start && !IsArgOptional())
3180 RightFooter = GetArgChunk();
3188 if (start
&& !IsArgOptional())
3190 char *citeKeys
= GetArgData();
3192 char *citeKey
= ParseMultifieldString(citeKeys
, &pos
);
3195 AddCitation(citeKey
);
3196 TexRef
*ref
= FindReference(citeKey
);
3199 TexOutput(ref
->sectionNumber
, TRUE
);
3200 if (strcmp(ref
->sectionNumber
, "??") == 0)
3203 sprintf(buf
, "Warning: unresolved citation %s.", citeKey
);
3207 citeKey
= ParseMultifieldString(citeKeys
, &pos
);
3210 TexOutput(", ", TRUE
);
3219 if (start
&& !IsArgOptional())
3221 char *citeKey
= GetArgData();
3222 AddCitation(citeKey
);
3227 case ltHELPFONTSIZE
:
3231 char *data
= GetArgData();
3232 if (strcmp(data
, "10") == 0)
3234 else if (strcmp(data
, "11") == 0)
3236 else if (strcmp(data
, "12") == 0)
3246 TexOutput(" ??", TRUE
);
3253 if (start
&& arg_no
== 1)
3255 char *data
= GetArgData();
3256 ParSkip
= ParseUnitArgument(data
);
3263 if (start
&& arg_no
== 1)
3265 char *data
= GetArgData();
3266 ParIndent
= ParseUnitArgument(data
);
3273 return OnArgument(ltIT
, arg_no
, start
);
3276 case ltSPECIALDOUBLEDOLLAR
:
3278 return OnArgument(ltCENTER
, arg_no
, start
);
3282 case ltPARAGRAPHSTAR
:
3283 case ltSUBPARAGRAPH
:
3284 case ltSUBPARAGRAPHSTAR
:
3286 return OnArgument(ltSUBSUBSECTION
, arg_no
, start
);
3292 OnInform(GetArgData());
3298 TexOutput(" (", TRUE
);
3300 TexOutput(")", TRUE
);
3303 case ltBIBLIOGRAPHY
:
3311 if ((fd
= fopen(TexBibName
, "r")))
3317 TexOutput(smallBuf
);
3325 OnInform("Run Tex2RTF again to include bibliography.");
3328 // Read in the .bib file, resolve all known references, write out the RTF.
3329 char *allFiles
= GetArgData();
3331 char *bibFile
= ParseMultifieldString(allFiles
, &pos
);
3335 strcpy(fileBuf
, bibFile
);
3336 wxString actualFile
= TexPathList
.FindValidPath(fileBuf
);
3337 if (actualFile
== "")
3339 strcat(fileBuf
, ".bib");
3340 actualFile
= TexPathList
.FindValidPath(fileBuf
);
3342 if (actualFile
!= "")
3344 if (!ReadBib((char*) (const char*) actualFile
))
3347 errBuf
.Printf(".bib file %s not found or malformed", (const char*) actualFile
);
3348 OnError((char *)errBuf
.c_str());
3354 errBuf
.Printf(".bib file %s not found", fileBuf
);
3355 OnError((char *)errBuf
.c_str());
3357 bibFile
= ParseMultifieldString(allFiles
, &pos
);
3360 ResolveBibReferences();
3362 // Write it a new bib section in the appropriate format.
3363 FILE *save1
= CurrentOutput1
;
3364 FILE *save2
= CurrentOutput2
;
3365 FILE *Biblio
= fopen(TexTmpBibName
, "w");
3366 SetCurrentOutput(Biblio
);
3369 if (wxFileExists(TexTmpBibName
))
3371 if (wxFileExists(TexBibName
)) wxRemoveFile(TexBibName
);
3372 wxRenameFile(TexTmpBibName
, TexBibName
);
3374 SetCurrentOutputs(save1
, save2
);
3381 if (start
&& (arg_no
== 3))
3391 if (start
&& (arg_no
== 1))
3393 char *s
= GetArgData();
3396 char *s1
= copystring(s
);
3398 for (i
= 0; i
< (int)strlen(s
); i
++)
3399 s1
[i
] = toupper(s
[i
]);
3412 if (start
&& (arg_no
== 1))
3414 char *s
= GetArgData();
3417 char *s1
= copystring(s
);
3419 for (i
= 0; i
< (int)strlen(s
); i
++)
3420 s1
[i
] = tolower(s
[i
]);
3433 if (start
&& (arg_no
== 1))
3435 char *s
= GetArgData();
3438 char *s1
= copystring(s
);
3440 for (i
= 0; i
< (int)strlen(s
); i
++)
3441 s1
[i
] = toupper(s
[i
]);
3452 case ltPOPREF
: // Ignore second argument by default
3454 if (start
&& (arg_no
== 1))
3464 return ((convertMode
== TEX_XLP
) ? FALSE
: TRUE
);
3467 return ((convertMode
!= TEX_XLP
) ? FALSE
: TRUE
);
3470 return ((convertMode
== TEX_HTML
) ? FALSE
: TRUE
);
3473 return ((convertMode
!= TEX_HTML
) ? FALSE
: TRUE
);
3476 return (((convertMode
== TEX_RTF
) && !winHelp
) ? FALSE
: TRUE
);
3479 return (!((convertMode
== TEX_RTF
) && !winHelp
) ? FALSE
: TRUE
);
3481 case ltWINHELPIGNORE
:
3482 return (winHelp
? FALSE
: TRUE
);
3485 return (!winHelp
? FALSE
: TRUE
);
3500 case ltADDTOCOUNTER
:
3501 case ltADDCONTENTSLINE
:
3505 case ltBASELINESKIP
:
3514 case ltPAGENUMBERING
:
3526 case ltTHISPAGESTYLE
:
3529 case ltEVENSIDEMARGIN
:
3530 case ltODDSIDEMARGIN
:
3532 case ltMARGINPARWIDTH
:
3533 case ltMARGINPARSEP
:
3534 case ltMARGINPAREVEN
:
3535 case ltMARGINPARODD
:
3536 case ltTWOCOLWIDTHA
:
3537 case ltTWOCOLWIDTHB
:
3538 case ltTWOCOLSPACING
:
3545 case ltSETHOTSPOTCOLOUR
:
3546 case ltSETHOTSPOTCOLOR
:
3547 case ltSETHOTSPOTUNDERLINE
:
3548 case ltSETTRANSPARENCY
:
3551 case ltBACKGROUNDCOLOUR
:
3552 case ltBACKGROUNDIMAGE
:
3554 case ltFOLLOWEDLINKCOLOUR
:
3561 case ltINSERTATLEVEL
:
3565 case ltSUPERTABULAR
:
3574 if (arg_no
== 2) return TRUE
;
3581 if (arg_no
== 2) return TRUE
;
3585 case ltDEFINECOLOUR
:
3588 static int redVal
= 0;
3589 static int greenVal
= 0;
3590 static int blueVal
= 0;
3591 static char *colourName
= NULL
;
3598 if (colourName
) delete[] colourName
;
3599 colourName
= copystring(GetArgData());
3604 redVal
= atoi(GetArgData());
3609 greenVal
= atoi(GetArgData());
3614 blueVal
= atoi(GetArgData());
3615 AddColour(colourName
, redVal
, greenVal
, blueVal
);
3631 if (IsArgOptional())