w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

funct1.c
Go to the documentation of this file.
1 /* funct1.c - interpret various LaTeX commands and produce RTF
2 
3 Copyright (C) 1995-2002 The Free Software Foundation
4 
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 
19 This file is available from http://sourceforge.net/projects/latex2rtf/
20 
21 Authors:
22  1995 Fernando Dorner, Andreas Granzer, Freidrich Polzer, Gerhard Trisko
23  1995-1997 Ralf Schlatterbeck
24  1998-2000 Georg Lehner
25  2001-2002 Scott Prahl
26 */
27 
28 #include <stdlib.h>
29 #include <string.h>
30 #include <ctype.h>
31 #include "main.h"
32 #include "convert.h"
33 #include "funct1.h"
34 #include "commands.h"
35 #include "stack.h"
36 #include "l2r_fonts.h"
37 #include "cfg.h"
38 #include "ignore.h"
39 #include "util.h"
40 #include "encode.h"
41 #include "parser.h"
42 #include "counters.h"
43 #include "lengths.h"
44 #include "definitions.h"
45 #include "preamble.h"
46 #include "xref.h"
47 #include "equation.h"
48 #include "direct.h"
49 #include "style.h"
50 
51 extern bool twocolumn; /* true if twocolumn-mode is enabled */
54 
55 void CmdPagestyle( /* @unused@ */ int code);
56 void CmdHeader(int code);
57 char *roman_item(int n, bool upper);
58 
61 static int g_vertical_space_to_add = 0;
63 
64 void
66 /******************************************************************************
67  purpose : RTF codes to create a new paragraph. If the paragraph should
68  not be indented then emit \fi0 otherwise use the current value
69  of \parindent as the indentation of the first line.
70 
71  Sometimes it is necessary to know what the next paragraph will
72  be before it has been parsed. For example, a section command
73  should create a paragraph for the section title and then the
74  next paragraph encountered should be handled like as a first
75  paragraph. So status is set to 2 and decremented to 1 when the
76  section title paragraph is started.
77 
78  If the status is 1, then it is the first paragraph in a section.
79  Usually the first paragraph is not indented. However, when the
80  document is being typeset in french it should have normal indentation.
81  Another special case occurs when the paragraph being typeset is
82  in a list environment. In this case, we need to indent according
83  to the current parindent to obtain the proper hanging indentation
84 
85  If the status is 0, then use the default is to indent according to
86  the current parindent. However, if the g_paragraph_inhibit_indent
87  flag or the g_paragraph_no_indent flag is TRUE, then do not indent
88  the next line. Typically these flags are set just after a figure
89  or equation or table.
90 
91  Note that when the code is ANY_PAR, the status flag is not touched.
92  ******************************************************************************/
93 {
94  static int status;
95  int parindent;
96 
97  if (code == TITLE_PAR) status=2;
98  if (code == FIRST_PAR) status=1;
99 
100  parindent = getLength("parindent");
101 
102  diagnostics(5,"CmdStartParagraph mode = %s", TexModeName[GetTexMode()]);
103  diagnostics(5,"Noindent is %s", (g_paragraph_no_indent) ? "TRUE" : "FALSE");
104  diagnostics(5,"Inhibit is %s", (g_paragraph_inhibit_indent) ? "TRUE" : "FALSE");
105  diagnostics(5,"indent is %d", g_left_margin_indent);
106  diagnostics(5,"right indent is %d", g_right_margin_indent);
107  diagnostics(5,"paragraph indent is %d", getLength("parindent"));
108 
109  fprintRTF("\\q%c", alignment);
110 
114 
115  if (g_left_margin_indent!=0)
116  fprintRTF("\\li%d", g_left_margin_indent);
117 
118  if (g_right_margin_indent!=0)
119  fprintRTF("\\ri%d", g_right_margin_indent);
120 
121  /*titles are never indented */
122  if (status==2)
123  parindent=0;
124 
125  /* French indents the first paragraph */
127  parindent=0;
128 
129  /* use indent flags for ANY_PAR */
131  parindent = 0;
132 
133  fprintRTF("\\fi%d ", parindent);
134 
135  SetTexMode(-MODE_HORIZONTAL); /* negative value avoids calling CmdStartParagraph! */
136 
140  }
141 
142  status--;
143 }
144 
145 void
147 /******************************************************************************
148  purpose : ends the current paragraph and return to MODE_VERTICAL.
149  ******************************************************************************/
150 {
151  int mode = GetTexMode();
152 
153  diagnostics(5,"CmdEndParagraph mode = %d", GetTexMode());
154  if (mode != MODE_VERTICAL) {
155  fprintRTF("\\par\n");
156  SetTexMode(-MODE_VERTICAL); /* negative value avoids calling CmdEndParagraph! */
157  }
158 
160 }
161 
162 static void
163 DirectVspace(int vspace)
164 {
165  g_vertical_space_to_add = vspace;
166 }
167 
168 void
170 /******************************************************************************
171  purpose : vspace, vspace*, and vskip
172  code == 0 if vspace or vspace*
173  code == -1 if vskip
174  code == 1 if \smallskip
175  code == 2 if \medskip
176  code == 3 if \bigskip
177  ******************************************************************************/
178 {
179  int vspace;
180  char c;
181 
182  switch (code) {
183  case VSPACE_VSPACE :
184  vspace = getDimension();
185  break;
186 
187  case VSPACE_VSKIP :
188  while ((c = getTexChar()) && c != '{'){}
189  vspace = getDimension();
190  parseBrace();
191  break;
192 
193  case VSPACE_SMALL_SKIP:
194  vspace = getLength("smallskipamount");
195  break;
196 
197  case VSPACE_MEDIUM_SKIP:
198  vspace = getLength("medskipamount");
199  break;
200 
201  case VSPACE_BIG_SKIP:
202  vspace = getLength("bigskipamount");
203  break;
204  }
205 
206  DirectVspace(vspace);
207 }
208 
209 void
210 CmdNewDef(int code)
211 /******************************************************************************
212  purpose : handles \def \newcommand \renewcommand
213  ******************************************************************************/
214 {
215  char * name, *opt_param, *def, cThis;
216  char * params=NULL;
217  int param=0;
218 
219  if (code == DEF_DEF){
220 
222  if (name == NULL) {
223  diagnostics(WARNING__,"Definition does not start with '\\' skipping");
224  return;
225  }
226 
227  /* handle simple parameters (discard delimiters) e.g., #1#2#3*/
228  while ( (cThis=getTexChar()) && cThis != '{' ){
229  if (isdigit((int)cThis)) param++;
230  }
231  ungetTexChar('{');
232 
233  opt_param = NULL;
234  def = getBraceParam();
237  }
238 
239  if (code == DEF_NEW || code == DEF_RENEW) {
240  name = getBraceParam();
243  def = getBraceParam();
248  param = 0;
249  if (params) {
250  if ('0' <= *params && *params <= '9')
251  param = *params - '0';
252  else
253  diagnostics(ERROR, "non-numeric number of parameters in newcommand");
254  }
255 
256 
257  if (code == DEF_NEW)
259  else
261 
262  }
263 
264  diagnostics(3,"CmdNewDef name=<%s> param=%d opt_param=<%s> def=<%s>", name,param, (opt_param) ? opt_param : "", def);
265  free(name);
266  free(def);
267  if (params) free(params);
268  if (opt_param) free(opt_param);
269 }
270 
271 void
273 {
274  char * name, *opt_param, *begdef, *enddef, *params;
275  int param;
276 
277  name = getBraceParam();
280  begdef = getBraceParam();
281  enddef = getBraceParam();
287  param = 0;
288  if (params) {
289  if ('0' <= *params && *params <= '9')
290  param = *params - '0';
291  else
292  diagnostics(ERROR, "non-numeric number of parameters in newcommand");
293  }
294 
295  diagnostics(3,"CmdNewEnvironment name=<%s> param=%d", name,param);
296  diagnostics(3,"CmdNewEnvironment begdef=<%s>", begdef);
297  diagnostics(3,"CmdNewEnvironment enddef=<%s>", enddef);
298 
299  if (code == DEF_NEW)
301  else
303 
304  if (opt_param) free(opt_param);
305  free(name);
306  free(begdef);
307  free(enddef);
308  if (params) free(params);
309 
310 }
311 
312 void
314 {
315  char * name, *caption, *numbered_like, *within;
316 
317  name = getBraceParam();
321 
326 
327  diagnostics(3,"CmdNewTheorem name=<%s>", name);
328  diagnostics(3,"CmdNewTheorem caption=<%s>", caption);
329  diagnostics(3,"CmdNewTheorem like=<%s>", (numbered_like) ? numbered_like : "");
331 
332  free(name);
333  free(caption);
335  if (within) free(within);
336 }
337 
338 void
340 /******************************************************************************
341  purpose : set flags so that CmdStartParagraph() does the right thing
342 
343  INDENT_INHIBIT allows the next paragraph to be indented if
344  a paragraph break occurs before CmdStartParagraph() is called
345 
346  INDENT_NONE tells CmdStartParagraph() to not indent the next paragraph
347 
348  INDENT_USUAL has CmdStartParagraph() use the value of \parindent
349  ******************************************************************************/
350 {
351  diagnostics(5,"CmdIndent mode = %d", GetTexMode());
352  if (code == INDENT_NONE)
354 
355  else if (code == INDENT_INHIBIT)
357 
358  else if (code == INDENT_USUAL) {
361  }
362  diagnostics(5,"Noindent is %d", (int) g_paragraph_no_indent);
363  diagnostics(5,"Inhibit is %d", (int) g_paragraph_inhibit_indent);
364 }
365 
366 void
368 /***************************************************************************
369  purpose: handle \\, \\[1pt], \\*[1pt]
370  ***************************************************************************/
371 {
372  char cThis, *vertical_space;
373 
374  if (g_processing_arrays) { /* array */
375  cThis=getNonBlank();
376  ungetTexChar(cThis);
378  return;
379  }
380 
381  cThis = getTexChar();
382  if (cThis != '*')
383  ungetTexChar(cThis);
384 
385  vertical_space = getBracketParam();
386  if (vertical_space) /* ignore for now */
387  free(vertical_space);
388 
389  if (g_processing_eqnarray) { /* eqnarray */
391  fprintRTF("}}{\\fldrslt }}");
393  char number[20];
394 
395  for (; g_equation_column < 3; g_equation_column++)
396  fprintRTF("\\tab ");
397  incrementCounter("equation");
398 
399  fprintRTF("\\tab{\\b0 (");
400  snprintf(number,20,"%d",getCounter("equation"));
402  if (g_equation_label) {
405  }
406  fprintRTF(")}");
407  }
408 
409  fprintRTF("\\par\n\\tab ");
411  fprintRTF("{\\field{\\*\\fldinst{ EQ ");
412 
414  g_equation_column = 1;
415  return;
416  }
417 
418 /* this should only happen for an array environment */
419  if (g_processing_tabular) { /* tabular or array environment */
420  if (GetTexMode() == MODE_MATH || GetTexMode() == MODE_DISPLAYMATH) { /* array */
421  fprintRTF("\\par\n\\tab ");
422  return;
423  }
424  for (; actCol < colCount; actCol++) {
425  fprintRTF("\\cell\\pard\\intbl");
426  }
427  actCol = 0;
428  fprintRTF("\\row\n\\pard\\intbl\\q%c ", colFmt[actCol]);
429  return;
430  }
431 
432 /* I don't think this should happen anymore either! */
434  PopBrace();
435  PushBrace();
436  }
437 
438  /* simple end of line ... */
439  CmdEndParagraph(0);
441 
442  tabcounter = 0;
443 }
444 
445 void
447 /***************************************************************************
448  purpose: reads the parameter after the \begin or \end-command; ( see also getBraceParam )
449  after reading the parameter the CallParamFunc-function calls the
450  handling-routine for that special environment
451  parameter: code: CMD_BEGIN: start of environment
452  CMD_END: end of environment
453  ***************************************************************************/
454 {
455  int i;
456  char *str,*option;
457  char *s = getBraceParam();
458 
459  if (code==CMD_BEGIN)
460  diagnostics(5, "\\begin{%s}", s);
461  else
462  diagnostics(5, "\\end{%s}", s);
463 
464 /* hack to avoid problems with multicols */
465  if (strcmp(s,"multicols")==0) {free(s); return;}
466 
467 /* user defined environments */
469  if (i>-1) {
472  free(str);
473  free(s);
474  return;
475  }
476 
477 /* theorem environment */
478  i=existsTheorem(s);
479  if (i>-1) {
480  if (code == CMD_BEGIN) {
483  CmdEndParagraph(0);
486  fprintRTF("{\\b %s} {\\i ", str);
487  PushBrace();
488  if (option) free(option);
489  free(str);
490  } else {
491  PopBrace();
492  fprintRTF("}");
493  CmdEndParagraph(0);
496  }
497  free(s);
498  return;
499  }
500 
501 /* usual environments */
502  if (code==CMD_BEGIN) {
503  diagnostics(4, "\\begin{%s}", s);
504  (void) CallParamFunc(s, ON);
505  } else {
506  diagnostics(4, "\\end{%s}", s);
507  (void) CallParamFunc(s, OFF);
509  }
510  free(s);
511 }
512 
513 void
515 /*****************************************************************************
516  purpose : sets the alignment for a paragraph
517  parameter : code: alignment centered, justified, left or right
518  globals: alignment: alignment of paragraphs
519  ********************************************************************************/
520 {
521  char * s;
522  static char old_alignment_before_center = JUSTIFIED;
523  static char old_alignment_before_right = JUSTIFIED;
524  static char old_alignment_before_left = JUSTIFIED;
525  static char old_alignment_before_centerline = JUSTIFIED;
526 
527  if (code == PAR_VCENTER){
528  s = getBraceParam();
529  free(s);
530  return;
531  }
532 
533  CmdEndParagraph(0);
534  switch (code) {
535  case (PAR_CENTERLINE):
536  old_alignment_before_centerline = alignment;
538  fprintRTF("{");
539  diagnostics(4,"Entering Convert from CmdAlign (centerline)");
540  Convert();
541  diagnostics(4,"Exiting Convert from CmdAlign (centerline)");
542  alignment = old_alignment_before_centerline;
543  CmdEndParagraph(0);
544  fprintRTF("}");
545  break;
546 
547  case (PAR_RAGGEDRIGHT):
548  old_alignment_before_centerline = alignment;
549  alignment = LEFT;
550 // fprintRTF("{");
551  diagnostics(4,"Entering Convert from CmdAlign (centerline)");
552  Convert();
553  diagnostics(4,"Exiting Convert from CmdAlign (centerline)");
554  alignment = old_alignment_before_centerline;
555  CmdEndParagraph(0);
556 // fprintRTF("}");
557  break;
558 
559  case (PAR_CENTER | ON):
561  old_alignment_before_center = alignment;
563  break;
564  case (PAR_CENTER | OFF):
565  alignment = old_alignment_before_center;
566  CmdEndParagraph(0);
568  break;
569 
570  case (PAR_RIGHT | ON):
571  old_alignment_before_right = alignment;
572  alignment = RIGHT;
574  break;
575  case (PAR_RIGHT | OFF):
576  alignment = old_alignment_before_right;
578  break;
579 
580  case (PAR_LEFT | ON):
581  old_alignment_before_left = alignment;
582  alignment = LEFT;
584  break;
585  case (PAR_LEFT | OFF):
586  alignment = old_alignment_before_left;
588  break;
589  }
590 }
591 
592 void
594 /******************************************************************************
595  purpose: converts LaTeX \today into RTF \chdate
596  ******************************************************************************/
597 {
599  fprintRTF("\\chdate ");
600 }
601 
602 
603 void
605 /******************************************************************************
606  purpose: allows handling of constructs that do not require changes to RTF
607  ******************************************************************************/
608 {
609 }
610 
611 void
612 CmdLdots( /* @unused@ */ int code)
613 /******************************************************************************
614  purpose: converts the LaTeX-\ldots-command into "..." in Rtf
615  ******************************************************************************/
616 {
619 
620  fprintRTF("...");
621 }
622 
623 void
625 /******************************************************************************
626  purpose: pushes/pops the new environment-commands on/from the stack
627 parameter: code includes the type of the environment
628  ******************************************************************************/
629 {
630  if (code & ON) {
631  code &= ~(ON); /* mask MSB */
632  diagnostics(4,"Entering Environment (%d)", code);
634  } else { /* off switch */
635  CmdEndParagraph(0);
636  diagnostics(4,"Exiting Environment (%d)", code);
637  PopEnvironment();
638  }
639 }
640 
641 char *
643 /******************************************************************************
644  purpose: returns the x.x.x number for the specified sectional unit.
645  ******************************************************************************/
646 {
647  char label[20];
648 
649  label[0]='\0';
650  if (strcmp(name,"part")==0) {
651  char *s = roman_item(getCounter(name),TRUE);
652  snprintf(label, 20, "%s", s);
653  free(s);
654  }
655 
656  else if (strcmp(name,"chapter")==0) {
657  snprintf(label, 20, "%d", getCounter(name));
658  }
659 
660  else if (strcmp(name,"section")==0) {
662  snprintf(label, 20, "%d", getCounter("section"));
663  else
664  snprintf(label, 20, "%d.%d", getCounter("chapter"),getCounter("section"));
665  }
666 
667  else if (strcmp(name,"subsection")==0) {
669  snprintf(label, 20, "%d.%d", getCounter("section"),
670  getCounter("subsection"));
671  else
672  snprintf(label, 20, "%d.%d.%d", getCounter("chapter"),
673  getCounter("section"), getCounter("subsection"));
674  }
675 
676  else if (strcmp(name,"subsubsection")==0) {
678  snprintf(label, 20, "%d.%d.%d", getCounter("section"),
679  getCounter("subsection"), getCounter("subsubsection"));
680  else
681  snprintf(label, 20, "%d.%d.%d.%d", getCounter("chapter"),
682  getCounter("section"), getCounter("subsection"), getCounter("subsubsection"));
683  }
684 
685  else if (strcmp(name,"paragraph")==0) {
687  snprintf(label, 20, "%d.%d.%d.%d", getCounter("section"),
688  getCounter("subsection"), getCounter("subsubsection"),
689  getCounter("paragraph"));
690  else
691  snprintf(label, 20, "%d.%d.%d.%d.%d", getCounter("chapter"),
692  getCounter("section"), getCounter("subsection"),
693  getCounter("subsubsection"),getCounter("paragraph"));
694  }
695 
696  else if (strcmp(name,"subparagraph")==0) {
698  snprintf(label, 20, "%d.%d.%d.%d.%d", getCounter("section"),
699  getCounter("subsection"), getCounter("subsubsection"),
700  getCounter("paragraph"), getCounter("subparagraph"));
701  else
702  snprintf(label, 20, "%d.%d.%d.%d.%d.%d", getCounter("chapter"),
703  getCounter("section"), getCounter("subsection"),
704  getCounter("subsubsection"), getCounter("paragraph"),
705  getCounter("subparagraph"));
706  }
707 
708  return strdup(label);
709 }
710 
711 void
713 /******************************************************************************
714  purpose: converts the LaTeX-section-commands into similar Rtf-styles
715 parameter: code: type of section-recursion-level
716  ******************************************************************************/
717 {
718  char *toc_entry;
719  char *heading;
720  char *unit_label;
721 
722  toc_entry = getBracketParam();
723  heading = getBraceParam();
724 
725  if (toc_entry) {
726  diagnostics(4,"entering CmdSection [%s]{%s}",toc_entry,heading);
727  free(toc_entry);
728  } else
729  diagnostics(4,"entering CmdSection {%s}",heading);
730 
731  CmdEndParagraph(0);
732 
733  switch (code) {
734  case SECT_PART:
735  case SECT_PART_STAR:
736  fprintRTF("\\page");
738  fprintRTF("{");
739  InsertStyle("part");
740  fprintRTF(" ");
741  ConvertBabelName("PARTNAME");
742  if (code == SECT_PART) {
743  incrementCounter("part");
744  unit_label = FormatUnitNumber("part");
745  fprintRTF(" %s\\par ", unit_label);
746  free(unit_label);
747  }
748  ConvertString(heading);
749  CmdEndParagraph(0);
750  fprintRTF("}\n\\page");
751  break;
752 
753  case SECT_CHAPTER:
754  case SECT_CHAPTER_STAR:
755  fprintRTF("\\page");
757  fprintRTF("{");
758  InsertStyle("chapter");
759  fprintRTF(" ");
760  ConvertBabelName("CHAPTERNAME");
761  if (code == SECT_CHAPTER && getCounter("secnumdepth")>=-1) {
762  incrementCounter("chapter");
763  setCounter("section",0);
764  setCounter("subsection",0);
765  setCounter("subsubsection",0);
766  setCounter("paragraph",0);
767  setCounter("subparagraph",0);
768  resetTheoremCounter("chapter");
769  unit_label = FormatUnitNumber("chapter");
770  fprintRTF(" ");
771  InsertBookmark(g_section_label, unit_label);
772  free(unit_label);
773  }
774  fprintRTF("\\par\\par\n");
775  ConvertString(heading);
776  CmdEndParagraph(0);
777  fprintRTF("}");
779  break;
780 
781  case SECT_NORM:
782  case SECT_NORM_STAR:
785  fprintRTF("{");
786  InsertStyle("section");
787  fprintRTF(" ");
788  if(code == SECT_NORM && getCounter("secnumdepth")>=0) {
789  incrementCounter("section");
790  setCounter("subsection",0);
791  setCounter("subsubsection",0);
792  setCounter("paragraph",0);
793  setCounter("subparagraph",0);
794  resetTheoremCounter("section");
795  unit_label = FormatUnitNumber("section");
796  InsertBookmark(g_section_label, unit_label);
797  fprintRTF(" ");
798  free(unit_label);
799  }
800  ConvertString(heading);
801  CmdEndParagraph(0);
802  fprintRTF("}");
804  break;
805 
806  case SECT_SUB:
807  case SECT_SUB_STAR:
810  fprintRTF("{");
811  InsertStyle("subsection");
812  fprintRTF(" ");
813  if (code == SECT_SUB && getCounter("secnumdepth")>=1) {
814  incrementCounter("subsection");
815  setCounter("subsubsection",0);
816  setCounter("paragraph",0);
817  setCounter("subparagraph",0);
818  resetTheoremCounter("subsection");
819  unit_label = FormatUnitNumber("subsection");
820  InsertBookmark(g_section_label, unit_label);
821  fprintRTF(" ");
822  free(unit_label);
823  }
824  ConvertString(heading);
825  CmdEndParagraph(0);
826  fprintRTF("}");
828  break;
829 
830  case SECT_SUBSUB:
831  case SECT_SUBSUB_STAR:
834  fprintRTF("{");
835  InsertStyle("subsubsection");
836  fprintRTF(" ");
837  if (code == SECT_SUBSUB && ( getCounter("secnumdepth")>2 ||
838  (g_document_type == FORMAT_ARTICLE && getCounter("secnumdepth")==2))) {
839  incrementCounter("subsubsection");
840  setCounter("paragraph",0);
841  setCounter("subparagraph",0);
842  resetTheoremCounter("subsubsection");
843  unit_label = FormatUnitNumber("subsubsection");
844  InsertBookmark(g_section_label, unit_label);
845  fprintRTF(" ");
846  free(unit_label);
847  }
848  ConvertString(heading);
849  CmdEndParagraph(0);
850  fprintRTF("}");
852  break;
853 
854  case SECT_SUBSUBSUB:
855  case SECT_SUBSUBSUB_STAR:
858  fprintRTF("{");
859  InsertStyle("paragraph");
860  fprintRTF(" ");
861  if (code == SECT_SUBSUBSUB && getCounter("secnumdepth")>=3) {
862  incrementCounter("paragraph");
863  resetTheoremCounter("paragraph");
864  unit_label = FormatUnitNumber("paragraph");
865  setCounter("subparagraph",0);
866  InsertBookmark(g_section_label, unit_label);
867  fprintRTF(" ");
868  free(unit_label);
869  }
870  ConvertString(heading);
871  CmdEndParagraph(0);
872  fprintRTF("} ");
874  break;
875 
876  case SECT_SUBSUBSUBSUB:
880  fprintRTF("{");
881  InsertStyle("subparagraph");
882  fprintRTF(" ");
883  if (code == SECT_SUBSUBSUBSUB && getCounter("secnumdepth")>=4) {
884  incrementCounter("subparagraph");
885  resetTheoremCounter("subparagraph");
886  unit_label = FormatUnitNumber("subparagraph");
887  InsertBookmark(g_section_label, unit_label);
888  fprintRTF(" ");
889  free(unit_label);
890  }
891  ConvertString(heading);
892  CmdEndParagraph(0);
893  fprintRTF("} ");
895  break;
896  }
897 
898  if (heading) free(heading);
899  if (g_section_label) {
902  }
903 }
904 
905 
906 void
908 /******************************************************************************
909  purpose: converts \caption from LaTeX to Rtf
910  ******************************************************************************/
911 {
912  char *thecaption;
913  char *lst_entry;
914  int n,vspace;
915  char old_align;
916  char number[20];
917 
918  old_align = alignment;
920 
921  lst_entry = getBracketParam();
922 
923  if (lst_entry) {
924  diagnostics(4, "entering CmdCaption [%s]", lst_entry);
925  free(lst_entry);
926  } else
927  diagnostics(4, "entering CmdCaption");
928 
929  if (GetTexMode()!=MODE_VERTICAL)
930  CmdEndParagraph(0);
931  vspace = getLength("abovecaptionskip");
932  DirectVspace(vspace);
934  fprintRTF("{");
935 
936  if (g_processing_figure) {
937  incrementCounter("figure");
938  ConvertBabelName("FIGURENAME");
939  n = getCounter("figure");
940  } else {
941  incrementCounter("table");
942  ConvertBabelName("TABLENAME");
943  n = getCounter("table");
944  }
945 
946  fprintRTF(" ");
948  snprintf(number, 20, "%d.%d", getCounter("chapter"), n);
949  else
950  snprintf(number, 20, "%d", n);
951 
954 
955  else if (g_processing_table && g_table_label)
957 
958  else
959  fprintRTF("%s", number);
960 
961  fprintRTF(": ");
962  thecaption = getBraceParam();
963  diagnostics(4, "in CmdCaption [%s]", thecaption);
964  ConvertString(thecaption);
965  free(thecaption);
966  fprintRTF("}");
967  CmdEndParagraph(0);
968  vspace = getLength("belowcaptionskip")+getLength("textfloatsep");
969  DirectVspace(vspace);
970  alignment = old_align;
971  diagnostics(4, "exiting CmdCaption");
972 }
973 
974 void
976 /******************************************************************************
977  purpose: handles \newcounter, \setcounter, \addtocounter, \value
978  ******************************************************************************/
979 {
980  char *s, *s2, *s3, *s4;
981  int num;
982 
983  s = getBraceParam();
984 
985  diagnostics(4,"Entering CmdCounter(), <%s>", s);
986 
987  if (code == COUNTER_ADD || code == COUNTER_SET) {
988 
989  s2 = getBraceParam();
990 
991  if ((s3 = strchr(s2,'{')) && (s4 = strchr(s2,'}')) ) {
992  s3++;
993  *s4 = '\0';
994  diagnostics(4,"CmdCounter() processing \\value{%s}", s3);
995  num = getCounter(s3);
996 
997  } else if (sscanf(s2, "%d", &num) != 1) {
998 
999  fprintf(stderr, "\nBad parameter in set/addcounter{%s}{%s}\n", s,s2);
1000  free(s2);
1001  free(s);
1002  return;
1003  }
1004 
1005  free(s2);
1006  if (code == COUNTER_ADD)
1008  else
1009  setCounter(s, num);
1010 
1011  } else if (code == COUNTER_NEW)
1012  setCounter(s,0);
1013 
1014  free(s);
1015 }
1016 
1017 void
1019 /******************************************************************************
1020  purpose: handles \newlength, \setlength, \addtolength
1021  purpose: handle \textwidth=0.8in or \moveright0.1\textwidth
1022  ******************************************************************************/
1023 {
1024  char *s, *s1;
1025  char cThis;
1026  int num;
1027 
1028 
1029  if (code == LENGTH_ADD || code == LENGTH_SET || code == LENGTH_NEW) {
1030  s = getBraceParam();
1031  if (strlen(s)<=1) {
1032  free(s);
1033  fprintf(stderr,"missing argument in \\newlength \\addtolength or \\setlength");
1034  return;
1035  }
1036  s1 = s + 1; /* skip initial '//' */
1037  diagnostics(4,"Entering CmdLength(), <%s>", s1);
1038  if (code == LENGTH_ADD || code == LENGTH_SET) {
1039 
1040  cThis = getNonSpace();
1041 
1042  if (cThis=='{') {
1043  num = getDimension();
1044  while ((cThis=getTexChar()) != '}'){}
1045 
1046  if (code == LENGTH_ADD)
1048  else
1049  setLength(s1, num);
1050  } else
1051  fprintf(stderr,"bad parameter to \\addtolength or \\setlength");
1052 
1053  } else
1054  setLength(s1,0);
1055 
1056  free(s);
1057 
1058  } else {
1059  skipSpaces();
1060  cThis = getTexChar();
1061 
1062  if (cThis == '=') /* optional '=' */
1063  skipSpaces();
1064  else
1065  ungetTexChar(cThis);
1066 
1067  num = getDimension(); /* discard for now */
1068  }
1069 }
1070 
1071 void
1073 /******************************************************************************
1074  purpose: handles \begin{quote} ... \end{quote}
1075  \begin{quotation} ... \end{quotation}
1076  globals: indent which is the left-indent-position
1077  ******************************************************************************/
1078 {
1079  CmdEndParagraph(0);
1080 
1081  switch (code) {
1082  case (QUOTATION | ON):
1084  diagnostics(4,"Entering \\begin{quotation}");
1086  g_left_margin_indent += 512;
1087  g_right_margin_indent += 512;
1089  break;
1090 
1091  case (QUOTE | ON):
1093  diagnostics(4,"Entering \\begin{quote}");
1095  g_left_margin_indent += 512;
1096  g_right_margin_indent += 512;
1097  setLength("parindent",0);
1099  break;
1100 
1101  case (QUOTATION | OFF):
1102  case (QUOTE | OFF):
1103  PopEnvironment();
1104  diagnostics(4,"Exiting \\end{quote} or \\end{quotation}");
1107  }
1108 }
1109 
1110 void
1112 /******************************************************************************
1113  purpose : set indentation and counters for itemize, description and enumerate
1114  globals : indent
1115  ******************************************************************************/
1116 {
1117  int vspace;
1118  int amount = 300;
1119 
1120  vspace = getLength("topsep")+getLength("parskip");
1121 
1122  if (GetTexMode()==MODE_VERTICAL)
1123  vspace += getLength("partopsep");
1124  else
1125  CmdEndParagraph(0);
1126 
1127  switch (code) {
1128  case (ITEMIZE | ON):
1129  DirectVspace(vspace);
1131  setLength("parindent", -amount);
1132  g_left_margin_indent += 2*amount;
1134  break;
1135 
1136  case (ENUMERATE | ON):
1137  DirectVspace(vspace);
1141  setLength("parindent", -amount);
1142  g_left_margin_indent += 2*amount;
1144  break;
1145 
1146  case (DESCRIPTION | ON):
1147  DirectVspace(vspace);
1149  setLength("parindent", -amount);
1150  g_left_margin_indent += amount;
1152  break;
1153 
1154  case (ENUMERATE | OFF): g_enumerate_depth--; /* fall through */
1155  case (ITEMIZE | OFF):
1156  case (DESCRIPTION | OFF):
1157  PopEnvironment();
1158  CmdIndent(INDENT_USUAL); /* need to reset INDENT_NONE from CmdItem */
1160  DirectVspace(vspace);
1161  break;
1162  }
1163 }
1164 
1165 void
1167 /******************************************************************************
1168  purpose : handles \item command. Since the \item command is delimited by
1169  a later \item command or the ending of an environment (\end{itemize})
1170  this routine will get called recursively.
1171  ******************************************************************************/
1172 {
1173  char *itemlabel, thechar;
1174  static int item_number[4];
1175  int vspace;
1176 
1177  if (code == RESET_ITEM_COUNTER) {
1178  item_number[g_enumerate_depth] = 1;
1179  return;
1180  }
1181 
1182  diagnostics(4, "Entering CmdItem depth=%d item=%d",g_enumerate_depth,item_number[g_enumerate_depth]);
1183 
1185  CmdEndParagraph(0);
1186  vspace = getLength("itemsep")+getLength("parsep");
1187  DirectVspace(vspace);
1188 
1191 
1192  itemlabel = getBracketParam();
1193  if (itemlabel) { /* \item[label] */
1194  fprintRTF("{");
1195  if (code == DESCRIPTION)
1196  fprintRTF("\\b ");
1197  diagnostics(5,"Entering ConvertString from CmdItem");
1198  ConvertString(itemlabel);
1199  diagnostics(5,"Exiting ConvertString from CmdItem");
1200  fprintRTF("}");
1201  if (code != DESCRIPTION)
1202  fprintRTF("\\tab ");
1203  }
1204 
1205  switch (code) {
1206  case ITEMIZE:
1207  if (!itemlabel) {
1208  if (FrenchMode)
1209  fprintRTF("\\endash\\tab ");
1210  else
1211  fprintRTF("\\bullet\\tab ");
1212  }
1213  break;
1214 
1215  case ENUMERATE:
1216  if (itemlabel) break;
1217  switch (g_enumerate_depth) {
1218  case 1:
1219  fprintRTF("%d.", item_number[g_enumerate_depth]);
1220  break;
1221 
1222  case 2:
1223  fprintRTF("(%c)", 'a' + item_number[g_enumerate_depth] - 1);
1224  break;
1225 
1226  case 3:
1227  fprintRTF("%s.", roman_item(item_number[g_enumerate_depth],FALSE));
1228  break;
1229 
1230  case 4:
1231  fprintRTF("%c.", 'A' + item_number[g_enumerate_depth] - 1);
1232  break;
1233  }
1234  fprintRTF("\\tab ");
1235  item_number[g_enumerate_depth]++;
1236  break;
1237 
1238  case DESCRIPTION:
1239  fprintRTF(" ");
1240  break;
1241  }
1242 
1243  if (itemlabel) free(itemlabel);
1244  thechar=getNonBlank();
1245  ungetTexChar(thechar);
1247 }
1248 
1249 void
1251 /******************************************************************************
1252  purpose: converts the LaTeX \box-commands into an similar Rtf-style
1253  ******************************************************************************/
1254 {
1255  char BoxName[5][10] = {"hbox", "vbox", "mbox", "fbox", "parbox"};
1256  int mode = GetTexMode();
1257 
1258  diagnostics(2, "Entering CmdBox() [%s]", BoxName[code-1]);
1259  if (g_processing_fields) g_processing_fields++; /* hack to stop fields within fields */
1260 
1262 
1263  if (code==BOX_PARBOX) {
1264  char *position, *width;
1266  width = getBraceParam();
1267  if (position) free(position);
1268  free(width);
1269  }
1270 
1271  diagnostics(4, "Entering Convert() from CmdBox");
1272  Convert();
1273  diagnostics(4, "Exiting Convert() from CmdBox");
1274 
1276 
1277  if (code==BOX_VBOX) {
1278  CmdEndParagraph(0);
1280 
1281  } else {
1282  SetTexMode(mode);
1283  }
1284 
1285  diagnostics(2, "Exited CmdBox() [%s]", BoxName[code-1]);
1286 }
1287 
1288 void
1290 /******************************************************************************
1291  purpose: converts the LaTeX-verb-environment to a similar Rtf-style
1292  \url probably does not handle line feeds properly
1293  ******************************************************************************/
1294 {
1295  char cThis, *text, *s;
1296  char markingchar;
1297  int num;
1298 
1300  num = TexFontNumber("Typewriter");
1301  fprintRTF("{\\b0\\i0\\scaps0\\f%d ", num);
1302 
1303  if (code == VERB_URL) {
1304  cThis = getNonSpace();
1305  if (cThis == '{') { /* \url{http://} */
1306  text = getDelimitedText('{','}',TRUE);
1307  s = text;
1308  diagnostics(4, "CmdVerbatim \\url{%s}",text);
1309  while (*s) {
1310  putRtfChar(*s);
1311  s++;
1312  }
1313  fprintRTF("}");
1314  free(text);
1315  return;
1316  } else
1317  markingchar = cThis; /* \url|http://| */
1318 
1319  }
1320 
1321  if (code == VERB_STAR || code == VERB_VERB) {
1322 
1323  while ((cThis = getRawTexChar())) {
1324  if ((cThis != ' ') && (cThis != '*') && !isalpha((int)cThis)) {
1325  markingchar = cThis;
1326  break;
1327  }
1328  }
1329  }
1330 
1331 
1332  while ((cThis = getRawTexChar()) && cThis != markingchar)
1333  putRtfChar(cThis);
1334 
1335  fprintRTF("}");
1336 }
1337 
1338 void
1340 /******************************************************************************
1341  convert characters 1:1 until \end{verbatim} or \end{Verbatim} is reached
1342  VERBATIM_1 for \begin{verbatim} ... \end{verbatim}
1343  VERBATIM_2 for \begin{Verbatim} ... \end{Verbatim}
1344 ******************************************************************************/
1345 {
1346  char *verbatim_text, *vptr,*endtag;
1347  int num;
1348  int true_code = code & ~~ON;
1349 
1350  if (code & ON) {
1351 
1352  diagnostics(4, "Entering CmdVerbatim");
1353 
1354  if (true_code != VERBATIM_4) {
1355 
1356  CmdEndParagraph(0);
1359  num = TexFontNumber("Typewriter");
1360  fprintRTF("\\pard\\ql\\b0\\i0\\scaps0\\f%d ", num);
1361  }
1362 
1363  switch (true_code) {
1364  case VERBATIM_1 :
1365  endtag = strdup("\\end{verbatim}");
1366  break;
1367  case VERBATIM_2 :
1368  endtag = strdup("\\end{Verbatim}");
1369  break;
1370  case VERBATIM_3 :
1371  endtag = strdup("\\end{alltt}");
1372  break;
1373  case VERBATIM_4 :
1374  endtag = strdup("\\end{comment}");
1375  break;
1376  }
1377 
1378  verbatim_text = getTexUntil(endtag, 1);
1379  UpdateLineNumber(verbatim_text);
1380  vptr = verbatim_text;
1381 
1382  if (true_code == VERBATIM_3) /* alltt environment */
1383 
1384  ConvertAllttString(verbatim_text);
1385 
1386  else if (true_code == VERBATIM_1 || true_code == VERBATIM_2) {
1387 
1388  while (*vptr) {
1389  diagnostics(5, "Verbatim character <%c>", *vptr);
1390  putRtfChar(*vptr++);
1391  }
1392  }
1393 
1394  free(verbatim_text);
1395  ConvertString(endtag);
1396  free(endtag);
1397 
1398  } else {
1399  diagnostics(4, "Exiting CmdVerbatim");
1400 
1401  if (true_code != VERBATIM_4) CmdEndParagraph(0);
1402  }
1403 
1404 }
1405 
1406 void
1408 /******************************************************************************
1409  purpose: converts the LaTeX-Verse-environment to a similar Rtf-style
1410  ******************************************************************************/
1411 {
1412  CmdEndParagraph(0);
1413  switch (code) {
1414  case ON:
1417  g_left_margin_indent += 1134;
1418  setLength("parindent",0);
1419  break;
1420  case OFF:
1421  PopEnvironment();
1422  diagnostics(4,"Exiting \\end{verse}");
1425  break;
1426  }
1427 }
1428 
1429 
1430 void
1431 CmdIgnoreDef( /* @unused@ */ int code)
1432 /*****************************************************************************
1433  purpose: newenvironments or newcommands which are defined by the user aren't
1434  converted into Rtf and so they must be ignored
1435  ******************************************************************************/
1436 {
1437  char cThis;
1438 
1439  while ((cThis = getTexChar()) && cThis != '{'){}
1440 
1441  parseBrace();
1442 
1443 }
1444 
1445 void
1447 /***************************************************************************
1448 purpose: called on active german-mode and " character in input file to
1449  handle " as an active (meta-)character.
1450  ***************************************************************************/
1451 {
1452  char cThis;
1453 
1454  cThis = getTexChar();
1455 
1456  switch (cThis) {
1457  case 'a':
1458  fprintRTF("\\'e4");
1459  break;
1460  case 'o':
1461  fprintRTF("\\'f6");
1462  break;
1463  case 'u':
1464  fprintRTF("\\'fc");
1465  break;
1466  case 's':
1467  fprintRTF("\\'df");
1468  break;
1469  case 'A':
1470  fprintRTF("\\'c4");
1471  break;
1472  case 'O':
1473  fprintRTF("\\'d6");
1474  break;
1475  case 'U':
1476  fprintRTF("\\'dc");
1477  break;
1478  case '|':
1479  break; /* ignore */
1480  case '-':
1481  break; /* ignore */
1482  case '"':
1483  break; /* ignore */
1484  case '\'':
1485  fprintRTF("\\ldblquote ");
1486  break;
1487  case '`':
1488  fprintRTF("{\\'84}");
1489  break;
1490  case '<':
1491  break;
1492  case '>':
1493  break;
1494  default:
1495  fprintRTF("%c", cThis);
1496  }
1497 }
1498 
1499 void
1501 {
1502  switch (code) {
1503  case GP_CK:fprintRTF("ck");
1504  break;
1505  case GP_LDBL:
1506  fprintRTF("{\\'84}");
1507  break;
1508  case GP_L:
1509  fprintRTF(",");
1510  break;
1511  case GP_R:
1512  fprintRTF("\\lquote");
1513  break;
1514  case GP_RDBL:
1515  fprintRTF("\\ldblquote");
1516  }
1517 }
1518 
1519 
1520 void
1521 CmdIgnoreLet( /* @unused@ */ int code)
1522 /******************************************************************************
1523  purpose : ignore \let
1524  Format: \let\XXXXX = \YYYYYY or \let\XXXXX\YYYYYY
1525  ******************************************************************************/
1526 {
1527  char cThis;
1528 
1529  while ((cThis = getTexChar()) && cThis != ' ' && cThis != '\\'){}
1530 
1531  if (cThis == ' ')
1532  {
1533  skipSpaces();
1534  while ((cThis = getTexChar()) && cThis != ' '){}
1535  skipSpaces();
1536  }
1537 }
1538 
1539 void CmdQuad(int kk)
1540 /******************************************************************************
1541  purpose: inserts kk quad spaces (D. Taupin)
1542  ******************************************************************************/
1543 {
1544  int z;
1545  fprintRTF("{\\emspace ");
1546  for (z=0; z<kk; z++) fprintRTF(" ");
1547  fprintRTF("}");
1548 }
1549 
1550 void CmdSpace(float kk)
1551 /******************************************************************************
1552  purpose: inserts a space of width kk*space
1553  ******************************************************************************/
1554 {
1555  int size = CurrentFontSize()*kk;
1556  fprintRTF("{\\fs%d }", size);
1557 }
1558 
1559 void
1561 /******************************************************************************
1562  purpose: Process \begin{figure} ... \end{figure} environment
1563  This is only complicated because we need to know what to
1564  label the caption before the caption is processed. So
1565  we just slurp the figure environment, extract the tag, and
1566  then process the environment as usual.
1567  ******************************************************************************/
1568 {
1569  char *loc, *figure_contents;
1570  char *endfigure = ((code & ~~ON) == FIGURE) ? "\\end{figure}" : "\\end{figure*}";
1571 
1572  if (code & ON) {
1573  loc = getBracketParam();
1574  diagnostics(4, "entering CmdFigure [%s]", (loc) ? loc : "");
1576  if (loc) free(loc);
1577  figure_contents = getTexUntil(endfigure, TRUE);
1578  g_figure_label = ExtractLabelTag(figure_contents);
1579  if (g_latex_figures) {
1580  char *caption, *label;
1581  caption=ExtractAndRemoveTag("\\caption",figure_contents);
1582  label=ExtractAndRemoveTag("\\label",figure_contents);
1583  CmdEndParagraph(0);
1586  WriteLatexAsBitmap("\\begin{figure}",figure_contents,"\\end{figure}");
1588  if (label) free(label);
1589  if (caption) free(caption);
1590  } else
1591  ConvertString(figure_contents);
1592  ConvertString(endfigure);
1593  free(figure_contents);
1594  } else {
1597  diagnostics(4, "exiting CmdFigure");
1598  }
1599 }
1600 
1601 void
1603 /******************************************************************************
1604  purpose: function to ignore \begin{environ} ... \end{environ}
1605  ******************************************************************************/
1606 {
1607  char *endtag=NULL;
1608  char *s = NULL;
1609 
1610  if (code & ON) {
1611 
1612  switch (code & ~(ON)) {
1613 
1614  case IGNORE_MINIPAGE:
1615  endtag = strdup("\\end{minipage}");
1616  break;
1617 
1618  case IGNORE_HTMLONLY:
1619  endtag = strdup("\\end{htmlonly}");
1620  break;
1621 
1622  case IGNORE_RAWHTML:
1623  endtag = strdup("\\end{rawhtml}");
1624  break;
1625  }
1626 
1627  if (endtag) {
1628  s=getTexUntil(endtag,0);
1629  ConvertString(endtag);
1630  if (s) free(s);
1631  free(endtag);
1632  }
1633  }
1634 }
1635 
1636 void
1637 FixTildes(char *s)
1638 {
1639  char *p,*p3;
1640  while ( (p=strstr(s,"\\~{}")) != NULL ) {
1641  *p = '~';
1642  p++;
1643  p3 = p+3;
1644  while (*p3) {*p++=*p3++;}
1645  *p = '\0';
1646  }
1647 }
1648 
1649 void
1651 /******************************************************************************
1652  purpose: hyperlatex support for \textcolor{color}{words to be in color}
1653 ******************************************************************************/
1654 {
1655  char *color,*text,*color1,*text1;
1656  int n;
1657 
1658  diagnostics(4, "Entering CmdTextColor");
1659  color1 = getBraceParam();
1660  text1 = getBraceParam();
1661  color = strdup_noendblanks(color1);
1662  text = strdup_noendblanks(text1);
1663  free(color1);
1664  free(text1);
1665 
1666  n=-1;
1667  if (strcmp(color,"black")==0)
1668  n=1;
1669  else if (strcmp(color,"blue")==0)
1670  n=2;
1671  else if (strcmp(color,"cyan")==0)
1672  n=3;
1673  else if (strcmp(color,"green")==0)
1674  n=4;
1675  else if (strcmp(color,"magenta")==0)
1676  n=5;
1677  else if (strcmp(color,"red")==0)
1678  n=6;
1679  else if (strcmp(color,"yellow")==0)
1680  n=7;
1681  else if (strcmp(color,"white")==0)
1682  n=8;
1683  else if (strcmp(color,"gray")==0)
1684  n=16;
1685 
1686  if (n>0) {
1687  fprintRTF("{\\cf%d ",n);
1689  fprintRTF("}");
1690  }
1691 
1692  free(text);
1693  free(color);
1694 }
1695 
1696 void
1698 /******************************************************************************
1699  purpose: hyperlatex support for \link{anchor}[ltx]{label}
1700  and \xlink{anchor}[printed reference]{URL}
1701 ******************************************************************************/
1702 {
1703  char *anchor,*latex,*url;
1704 
1705  diagnostics(4, "Entering hyperlatex \\link command");
1706  anchor = getBraceParam();
1707  latex = getBracketParam();
1708  url = getBraceParam();
1709 
1710  FixTildes(url);
1711  fprintRTF("{\\field\\fldedit{\\*\\fldinst { HYPERLINK \"%s\" \\\\* MERGEFORMAT }}",url);
1712  fprintRTF("{\\fldrslt {\\cs15\\ul\\cf2 ");
1713  ConvertString(anchor);
1714  fprintRTF("}}}");
1715 
1716  if (latex) free(latex);
1717  free(anchor);
1718  free(url);
1719 }
1720 
1721 void
1723 /******************************************************************************
1724  purpose: chooses between one/two-columns
1725 parameter: number of columns
1726  globals: twocolumn: true if twocolumn-mode is set
1727  ******************************************************************************/
1728 {
1729  switch (code) {
1730  case One_Column:fprintRTF("\\page \\colsx709\\endnhere "); /* new page & one column */
1731  twocolumn = FALSE;
1732  break;
1733  case Two_Column:
1734  fprintRTF("\\page \\cols2\\colsx709\\endnhere "); /* new page & two
1735  * columns */
1736  twocolumn = TRUE;
1737  break;
1738  } /* switch */
1739 }
1740 
1741 void
1743 /******************************************************************************
1744  purpose: starts a new page
1745 parameter: code: newpage or newcolumn-option
1746  globals: twocolumn: true if twocolumn-mode is set
1747  ******************************************************************************/
1748 {
1749  CmdEndParagraph(0);
1750  switch (code) {
1751  case NewPage:
1752  fprintRTF("\\page "); /* causes new page */
1753  break;
1754 
1755  case NewColumn:
1756  if (twocolumn)
1757  fprintRTF("\\column "); /* new column */
1758  else
1759  fprintRTF("\\page "); /* causes new page */
1760  break;
1761  } /* switch */
1762 }
1763 
1764 void
1765 Cmd_OptParam_Without_braces( /* @unused@ */ int code)
1766 /******************************************************************************
1767  purpose: gets an optional parameter which isn't surrounded by braces but by spaces
1768  ******************************************************************************/
1769 {
1770  char cNext = ' ';
1771  char cLast = ' ';
1772 
1773  do {
1774  cLast = cNext;
1775  cNext = getTexChar();
1776  } while ((cNext != ' ') &&
1777  (cNext != '\\') &&
1778  (cNext != '{') &&
1779  (cNext != '\n') &&
1780  (cNext != ',') &&
1781  ((cNext != '.') || (isdigit((int) cLast))) &&
1782  /*
1783  * . doesn't mean the end of an command inside an number of the type
1784  * real
1785  */
1786  (cNext != '}') &&
1787  (cNext != '\"') &&
1788  (cNext != '[') &&
1789  (cNext != '$'));
1790 
1791  ungetTexChar(cNext);
1792 }
1793 
1794 void
1796 /******************************************************************************
1797  purpose: ignore raggedbottom command
1798  ******************************************************************************/
1799 {
1800 }
1801 
1802 /******************************************************************************
1803 parameter: code: on/off-option
1804  globals : article and titlepage from the documentstyle
1805  ******************************************************************************/
1806 void
1808 {
1809  static char oldalignment;
1810 
1811  CmdEndParagraph(0);
1812 
1813  if (code == ON) {
1815  fprintRTF("\\page ");
1816 
1818  fprintRTF("\\qc{\\b ");
1819  ConvertBabelName("ABSTRACTNAME");
1820  fprintRTF("}");
1821  CmdEndParagraph(0);
1822  g_left_margin_indent += 1024;
1823  g_right_margin_indent +=1024;
1824  oldalignment = alignment;
1825  alignment = JUSTIFIED;
1826 
1827  } else {
1828  g_left_margin_indent -= 1024;
1829  g_right_margin_indent -=1024;
1830  alignment = oldalignment;
1831  CmdVspace(VSPACE_MEDIUM_SKIP); /* put \medskip after abstract */
1832  }
1833 }
1834 
1835 void
1837 /******************************************************************************
1838  purpose: \begin{titlepage} ... \end{titlepage}
1839  add pagebreaks before and after this environment
1840  ******************************************************************************/
1841 {
1842  switch (code) {
1843  case ON:
1844  fprintRTF("\n\\par\\pard \\page "); /* new page */
1845  fprintRTF("\n\\par\\q%c ", alignment);
1846  break;
1847  case OFF:
1848  fprintRTF("\\pard ");
1849  fprintRTF("\n\\par\\q%c \\page ", alignment);
1850  break;
1851  }
1852 }
1853 
1854 void
1856 /******************************************************************************
1857  purpose: recognize and parse Minipage parameters
1858  currently this does nothing
1859  ******************************************************************************/
1860 {
1861  char * v_align, *width;
1862  switch (code) {
1863  case ON:
1864  v_align = getBracketParam();
1865  width = getBraceParam();
1866  if (v_align) free(v_align);
1867  free(width);
1868  break;
1869  case OFF:
1870  break;
1871  }
1872 }
1873 
1874 void
1876 /***************************************************************************
1877  * purpose: hyperlatex support, handles '&' as in Convert() in convert.c
1878  only called by \S
1879  ***************************************************************************/
1880 {
1881  if (!g_processing_tabular) {
1882  fprintRTF("{\\'a7}");
1883  return;
1884  }
1885  actCol++;
1886 
1887  if (GetTexMode() == MODE_DISPLAYMATH) { /* in an eqnarray or array environment */
1888  fprintRTF("\\tab ");
1889  } else {
1890  fprintRTF("\\cell\\pard\\intbl ");
1891  if (colFmt == NULL)
1892  diagnostics(WARNING__, "Fatal, Fatal! CmdColsep called whith colFmt == NULL.");
1893  else
1894  fprintRTF("\\q%c ", colFmt[actCol]);
1895  }
1896 }
1897 
1898 void
1900 /***************************************************************************
1901  * purpose: insert \verbositylevel{5} in the tex file to set the verbosity
1902  in the LaTeX file!
1903  ***************************************************************************/
1904 {
1905  char * s = getBraceParam();
1907  free(s);
1908 
1909 }
1910 
1911 
1912 /* convert integer to roman number --- only works up correctly up to 39 */
1913 
1914 char *
1915 roman_item(int n, bool upper)
1916 {
1917  char s[50];
1918  int i = 0;
1919 
1920  while (n >= 10) {
1921  n -= 10;
1922  s[i] = (upper) ? 'X' : 'x';
1923  i++;
1924  }
1925 
1926  if (n == 9) {
1927  s[i] = (upper) ? 'I' : 'i';
1928  i++;
1929  s[i] = (upper) ? 'X' : 'x';
1930  i++;
1931  s[i] = '\0';
1932  return strdup(s);
1933  }
1934  if (n >= 5) {
1935  n -= 5;
1936  s[i] = (upper) ? 'V' : 'v';
1937  i++;
1938  }
1939  if (n == 4) {
1940  s[i] = (upper) ? 'I' : 'i';
1941  i++;
1942  s[i] = (upper) ? 'V' : 'v';
1943  i++;
1944  s[i] = '\0';
1945  return strdup(s);
1946  }
1947  while (n >= 1) {
1948  n -= 1;
1949  s[i] = (upper) ? 'I' : 'i';
1950  i++;
1951  }
1952 
1953  s[i] = '\0';
1954  return strdup(s);
1955 }
1956 
1958 {
1959  char cThis=getNonSpace();
1960  ungetTexChar(cThis);
1961  fprintRTF("\\~");
1962 }
1963 
1964 void
1966 /******************************************************************************
1967  purpose: handles \input file, \input{file}, \include{file}
1968  ******************************************************************************/
1969 {
1970  char name[50], *s, *t, cNext;
1971  int i;
1972 
1973  cNext = getNonSpace();
1974 
1975  if (cNext == '{') { /* \input{gnu} or \include{gnu} */
1976  ungetTexChar(cNext);
1977  s = getBraceParam();
1978 
1979  } else { /* \input gnu */
1980  name[0] = cNext;
1981  for (i=1; i<50; i++){
1982  name[i] = getTexChar();
1983  if (isspace((int)name[i])) {name[i]='\0';break;}
1984  }
1985  s = strdup(name);
1986  }
1987 
1988  if (strstr(s, ".tex") == NULL) { /* append .tex if missing*/
1989  t = strdup_together(s, ".tex");
1990  free(s);
1991  s = t;
1992  }
1993 
1994  if (PushSource(s,NULL)==0)
1995  diagnostics(WARNING__, "Including file <%s>",t);
1996  free(s);
1997 }
1998 
1999 void
2001 /******************************************************************************
2002  purpose: handles \ifx by skippint to next \fi
2003  ******************************************************************************/
2004 {
2005  char *s=getTexUntil("\\fi", FALSE);
2006  if (s) free(s);
2007 }
2008 
2009 void
2011 /******************************************************************************
2012  purpose: handles \endinput
2013  ******************************************************************************/
2014 {
2015  PopSource();
2016 }
#define QUOTE
Definition: Resource.h:34
#define strdup
Definition: Utility.h:167
#define width(a)
Definition: aptex-macros.h:198
#define loc
Definition: aptex-macros.h:65
#define name
#define text(a)
Definition: aptex-macros.h:925
#define param(a, b)
#define mode
Definition: aptex-macros.h:510
void ConvertBabelName(char *name)
Definition: cfg.c:429
#define n
Definition: t4ht.c:1290
#define MODE_HORIZONTAL
Definition: convert.h:2
#define MODE_MATH
Definition: convert.h:4
#define MODE_RESTRICTED_HORIZONTAL
Definition: convert.h:3
#define MODE_VERTICAL
Definition: convert.h:6
#define MODE_DISPLAYMATH
Definition: convert.h:5
void incrementCounter(char *s)
Definition: counters.c:78
void setCounter(char *s, int n)
Definition: counters.c:93
int getCounter(char *s)
Definition: counters.c:108
@ FALSE
Definition: dd.h:101
@ TRUE
Definition: dd.h:102
#define free(a)
Definition: decNumber.cpp:310
int params
Definition: definitions.c:42
void renewEnvironment(char *name, char *opt_param, char *begdef, char *enddef, int params)
Definition: definitions.c:420
void newTheorem(char *name, char *caption, char *numbered_like, char *within)
Definition: definitions.c:482
char * caption
Definition: definitions.c:58
char * enddef
Definition: definitions.c:51
char * def
Definition: definitions.c:41
char * opt_param
Definition: definitions.c:40
void newEnvironment(char *name, char *opt_param, char *begdef, char *enddef, int params)
Definition: definitions.c:378
char * expandTheorem(int i, char *option)
Definition: definitions.c:532
void resetTheoremCounter(char *unit)
Definition: definitions.c:564
int existsTheorem(char *s)
Definition: definitions.c:512
char * numbered_like
Definition: definitions.c:57
void renewDefinition(char *name, char *opt_param, char *def, int params)
Definition: definitions.c:276
char * expandEnvironment(int thedef, int code)
Definition: definitions.c:457
void newDefinition(char *name, char *opt_param, char *def, int params)
Definition: definitions.c:225
int existsEnvironment(char *s)
Definition: definitions.c:332
char * begdef
Definition: definitions.c:50
char * within
Definition: definitions.c:59
int z
Definition: dviconv.c:26
int strcmp()
Definition: coll.cpp:143
int sscanf()
void WriteLatexAsBitmap(char *pre, char *eq, char *post)
Definition: equation.c:277
int g_equation_column
Definition: equation.c:46
static void
Definition: fpif.c:118
int g_left_margin_indent
Definition: funct1.c:53
void CmdIgnore(int code)
Definition: funct1.c:604
void CmdColsep(int code)
Definition: funct1.c:1875
void CmdBottom(int code)
Definition: funct1.c:1795
void CmdIndent(int code)
Definition: funct1.c:339
void CmdLength(int code)
Definition: funct1.c:1018
void CmdColumn(int code)
Definition: funct1.c:1722
void CmdFigure(int code)
Definition: funct1.c:1560
char * roman_item(int n, bool upper)
Definition: funct1.c:1915
void CmdQuote(int code)
Definition: funct1.c:1072
void CmdVerbosityLevel(int code)
Definition: funct1.c:1899
void CmdIf(int code)
Definition: funct1.c:2000
char * FormatUnitNumber(char *name)
Definition: funct1.c:642
int g_right_margin_indent
Definition: funct1.c:52
void CmdVspace(int code)
Definition: funct1.c:169
void CmdNonBreakSpace(int code)
Definition: funct1.c:1957
void GermanPrint(int code)
Definition: funct1.c:1500
void CmdIgnoreLet(int code)
Definition: funct1.c:1521
void Environment(int code)
Definition: funct1.c:624
void CmdSlashSlash(int code)
Definition: funct1.c:367
static bool g_paragraph_no_indent
Definition: funct1.c:59
void CmdInclude(int code)
Definition: funct1.c:1965
void CmdSection(int code)
Definition: funct1.c:712
void CmdAlign(int code)
Definition: funct1.c:514
void CmdCounter(int code)
Definition: funct1.c:975
void CmdSpace(float kk)
Definition: funct1.c:1550
void CmdEndInput(int code)
Definition: funct1.c:2010
void CmdBox(int code)
Definition: funct1.c:1250
void CmdVerb(int code)
Definition: funct1.c:1289
bool twocolumn
Definition: main.c:121
void CmdTitlepage(int code)
Definition: funct1.c:1836
void CmdList(int code)
Definition: funct1.c:1111
void CmdNewPage(int code)
Definition: funct1.c:1742
void CmdHeader(int code)
Definition: preamble.c:735
void CmdVerbatim(int code)
Definition: funct1.c:1339
static int g_vertical_space_to_add
Definition: funct1.c:61
void CmdBeginEnd(int code)
Definition: funct1.c:446
void CmdLdots(int code)
Definition: funct1.c:612
void CmdEndParagraph(int code)
Definition: funct1.c:146
void CmdAbstract(int code)
Definition: funct1.c:1807
bool g_processing_list_environment
Definition: funct1.c:62
void CmdPagestyle(int code)
Definition: preamble.c:696
void CmdStartParagraph(int code)
Definition: funct1.c:65
void CmdMinipage(int code)
Definition: funct1.c:1855
void CmdNewEnvironment(int code)
Definition: funct1.c:272
void CmdVerse(int code)
Definition: funct1.c:1407
void CmdQuad(int kk)
Definition: funct1.c:1539
void CmdIgnoreDef(int code)
Definition: funct1.c:1431
void CmdItem(int code)
Definition: funct1.c:1166
void CmdNewTheorem(int code)
Definition: funct1.c:313
static void DirectVspace(int vspace)
Definition: funct1.c:163
static bool g_paragraph_inhibit_indent
Definition: funct1.c:60
void CmdToday(int code)
Definition: funct1.c:593
void TranslateGerman(void)
Definition: funct1.c:1446
void CmdTextColor(int code)
Definition: funct1.c:1650
void CmdCaption(int code)
Definition: funct1.c:907
void CmdLink(int code)
Definition: funct1.c:1697
void FixTildes(char *s)
Definition: funct1.c:1637
void CmdIgnoreEnviron(int code)
Definition: funct1.c:1602
void Cmd_OptParam_Without_braces(int code)
Definition: funct1.c:1765
#define SECT_SUBSUB
Definition: funct1.h:87
#define SECT_NORM_STAR
Definition: funct1.h:93
#define SECT_CHAPTER
Definition: funct1.h:84
#define INDENT_INHIBIT
Definition: funct1.h:45
#define COUNTER_NEW
Definition: funct1.h:110
#define FIGURE
Definition: funct1.h:141
#define VERB_VERB
Definition: funct1.h:53
#define PAR_LEFT
Definition: funct1.h:29
#define SECT_SUB
Definition: funct1.h:86
#define LENGTH_SET
Definition: funct1.h:118
#define NewPage
Definition: funct1.h:164
#define VERBATIM_1
Definition: funct1.h:48
#define VSPACE_VSPACE
Definition: funct1.h:57
#define SECT_SUBSUBSUBSUB
Definition: funct1.h:89
#define SECT_SUBSUBSUBSUB_STAR
Definition: funct1.h:97
#define IGNORE_RAWHTML
Definition: funct1.h:147
#define SECT_SUBSUBSUB
Definition: funct1.h:88
#define SECT_PART_STAR
Definition: funct1.h:91
#define IGNORE_HTMLONLY
Definition: funct1.h:144
#define SECT_NORM
Definition: funct1.h:85
#define SECT_PART
Definition: funct1.h:83
#define One_Column
Definition: funct1.h:161
#define QUOTATION
Definition: funct1.h:103
#define GP_LDBL
Definition: funct1.h:131
#define SECT_SUB_STAR
Definition: funct1.h:94
#define PAR_VCENTER
Definition: funct1.h:31
#define COUNTER_SET
Definition: funct1.h:111
#define SECT_SUBSUBSUB_STAR
Definition: funct1.h:96
#define VERB_URL
Definition: funct1.h:55
#define BOX_VBOX
Definition: funct1.h:35
#define FIRST_PAR
Definition: funct1.h:40
#define GP_CK
Definition: funct1.h:130
#define VERBATIM_4
Definition: funct1.h:51
#define VSPACE_VSKIP
Definition: funct1.h:58
#define IGNORE_MINIPAGE
Definition: funct1.h:146
#define SECT_SUBSUB_STAR
Definition: funct1.h:95
#define VSPACE_SMALL_SKIP
Definition: funct1.h:59
#define VERB_STAR
Definition: funct1.h:54
#define DEF_RENEW
Definition: funct1.h:71
#define BOX_HBOX
Definition: funct1.h:34
#define VERBATIM_2
Definition: funct1.h:49
#define INDENT_NONE
Definition: funct1.h:44
#define NewColumn
Definition: funct1.h:165
#define VSPACE_BIG_SKIP
Definition: funct1.h:61
#define VSPACE_MEDIUM_SKIP
Definition: funct1.h:60
#define CMD_BEGIN
Definition: funct1.h:24
#define SECT_CHAPTER_STAR
Definition: funct1.h:92
#define PAR_RAGGEDRIGHT
Definition: funct1.h:32
#define GP_RDBL
Definition: funct1.h:134
#define DEF_NEW
Definition: funct1.h:70
#define PAR_CENTERLINE
Definition: funct1.h:30
#define GP_R
Definition: funct1.h:133
#define BOX_PARBOX
Definition: funct1.h:38
#define LENGTH_ADD
Definition: funct1.h:119
#define DEF_DEF
Definition: funct1.h:72
#define VERBATIM_3
Definition: funct1.h:50
#define TITLE_PAR
Definition: funct1.h:42
#define LENGTH_NEW
Definition: funct1.h:117
#define PAR_CENTER
Definition: funct1.h:27
#define GP_L
Definition: funct1.h:132
#define RESET_ITEM_COUNTER
Definition: funct1.h:106
#define INDENT_USUAL
Definition: funct1.h:46
void CmdNewDef(int code)
#define Two_Column
Definition: funct1.h:162
#define COUNTER_ADD
Definition: funct1.h:112
#define PAR_RIGHT
Definition: funct1.h:28
#define BOX_MBOX
Definition: funct1.h:36
#define s
Definition: afcover.h:80
#define t
Definition: afcover.h:96
#define c(n)
Definition: gpos-common.c:150
#define strchr
Definition: gsftopk.c:59
JCOPY_OPTION option
Definition: transupp.h:131
#define NULL
Definition: ftobjs.h:61
small capitals from c petite p
Definition: afcover.h:72
small capitals from c petite p scientific i
Definition: afcover.h:80
int atoi(const char *)
int num
Definition: disdvi.c:621
#define ERROR(string)
Definition: error.h:36
char * strstr()
void CallParamFunc(char *cCommand, int AddParam)
Definition: commands.c:773
void PushEnvironment(int code)
Definition: commands.c:812
void PopEnvironment()
Definition: commands.c:903
#define ITEMIZE
Definition: commands.h:5
#define OFF
Definition: commands.h:20
#define ENUMERATE
Definition: commands.h:6
#define GENERIC_ENV
Definition: commands.h:15
#define DESCRIPTION
Definition: commands.h:7
void ConvertString(char *string)
Definition: convert.c:103
char TexModeName[7][25]
Definition: convert.c:75
void Convert()
Definition: convert.c:182
int GetTexMode(void)
Definition: convert.c:97
void ConvertAllttString(char *s)
Definition: convert.c:133
void SetTexMode(int mode)
Definition: convert.c:78
bool g_suppress_equation_number
Definition: main.c:89
void diagnostics(int level, char *format,...)
Definition: main.c:469
bool g_show_equation_number
Definition: main.c:87
void fprintRTF(char *format,...)
Definition: main.c:722
bool g_processing_figure
Definition: main.c:82
int g_processing_fields
Definition: main.c:85
char g_field_separator
Definition: main.c:105
char alignment
Definition: main.c:119
bool FrenchMode
Definition: main.c:66
int g_verbosity_level
Definition: main.c:74
bool g_latex_figures
Definition: main.c:116
bool g_document_type
Definition: main.c:92
bool g_processing_eqnarray
Definition: main.c:83
int g_enumerate_depth
Definition: main.c:88
int g_processing_arrays
Definition: main.c:84
bool titlepage
Definition: main.c:122
void putRtfChar(char cThis)
Definition: main.c:703
char * colFmt
Definition: tables.c:62
int actCol
Definition: tables.c:61
#define WARNING__
Definition: main.h:32
char * g_equation_label
Definition: xref.c:41
int colCount
Definition: tables.c:60
#define CENTERED
Definition: main.h:39
char * g_table_label
Definition: xref.c:40
char * g_figure_label
Definition: xref.c:39
bool g_processing_tabular
Definition: tables.c:57
bool g_processing_table
Definition: tables.c:58
#define JUSTIFIED
Definition: main.h:40
bool g_processing_tabbing
Definition: tables.c:56
char * g_section_label
Definition: xref.c:42
int tabcounter
Definition: main.h:81
void UpdateLineNumber(char *s)
Definition: parser.c:107
int PushSource(char *filename, char *string)
Definition: parser.c:139
void PopSource(void)
Definition: parser.c:243
#define fprintf
Definition: mendex.h:64
#define isdigit(c)
Definition: snprintf.c:177
#define snprintf
Definition: snprintf.c:41
int CurrentFontSize(void)
Definition: l2r_fonts.c:665
int TexFontNumber(char *Fname)
Definition: l2r_fonts.c:123
void skipSpaces(void)
void parseBrace(void)
char getRawTexChar(void)
char getTexChar(void)
char * getSimpleCommand(void)
char getNonSpace(void)
void ungetTexChar(char c)
char * getTexUntil(char *target, int raw)
char * getBraceParam(void)
char * getBracketParam(void)
char * getDelimitedText(char left, char right, bool raw)
int getDimension(void)
char getNonBlank(void)
int getLength(char *s)
Definition: lengths.c:99
void setLength(char *s, int d)
Definition: lengths.c:84
boolean upper(voice_index voice)
Definition: mtxline.c:760
@ LEFT
Definition: pl-parser.h:48
@ RIGHT
Definition: pl-parser.h:49
static int size
Definition: ppmlabel.c:24
#define status
#define isspace(ch)
Definition: utype.h:87
#define isalpha(ch)
Definition: utype.h:82
#define str(s)
Definition: sh6.c:399
Definition: inftrees.h:24
Definition: pdfdev.c:706
Definition: getopt.h:95
Definition: dvips.h:235
void InsertStyle(char *command)
Definition: style.c:97
struct def_label label[1024]
Definition: t1part.c:286
s1
Definition: t4ht.c:1059
char * s2
Definition: t4ht.c:1062
*job_name strlen((char *) job_name) - 4)
#define FORMAT_ARTICLE
Definition: preamble.h:1
#define FORMAT_REPORT
Definition: preamble.h:2
int PopBrace(void)
Definition: stack.c:191
void PushBrace(void)
Definition: stack.c:179
char * strdup_noendblanks(char *s)
Definition: util.c:190
char * ExtractLabelTag(char *text)
Definition: util.c:211
char * ExtractAndRemoveTag(char *tag, char *text)
Definition: util.c:235
char * strdup_together(char *s, char *t)
Definition: util.c:95
#define s4
Definition: tokst.h:125
#define s3
Definition: tokst.h:105
@ ON
Definition: ubidiimp.h:55
int latex
Definition: vlna.c:45
#define position
Definition: xmlparse.c:605
void InsertBookmark(char *name, char *text)
Definition: xref.c:372