source: trunk/TEXT2IDL/textable.pro @ 7

Last change on this file since 7 was 7, checked in by pinsard, 18 years ago

1st commit according to cerbere.lodyc.jussieu.fr:/usr/home/smasson/IDL_RD/

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 8.3 KB
Line 
1;
2;+
3; NAME:
4;       TEXTABLE
5; PURPOSE:
6;       Returns a translation table from TeX to IDL.
7; CATEGORY:
8;       text/strings
9; CALLING SEQUENCE:
10;       table = textable()
11; INPUTS:
12;       None
13; KEYWORD PARAMETERS:
14;       /POSTSCRIPT -- If set, return postscript translation
15;                      table rather than vector fonts table.
16;                      Default is translations for vector
17;                      fonts.
18;       /HELP       -- Print help and exit.
19; OUTPUTS:
20;       table -- a 2D text array.  table(0,*) contains          out
21;                the words to be translated away, table(1,*)
22;                contains the words to translate them to.   
23; COMMON BLOCKS:
24; SIDE EFFECTS:
25; NOTES:
26;       To find out what TeX sequences are available, look at
27;       table(0,*).
28; EXAMPLE:
29; MODIFICATION HISTORY:
30;       $Id$
31;       $Log: textable.pro,v $
32;       Revision 1.7  1996/07/22 23:56:08  mcraig
33;       Added \vartheta.
34;
35;       Revision 1.6  1996/07/12 21:31:42  mcraig
36;       Fixed \varphi in vector font, added \circ.
37;
38;       Revision 1.5  1996/06/14 20:00:27  mcraig
39;       Updated Copyright info.
40;
41;       Revision 1.4  1996/05/09 00:22:17  mcraig
42;       Added command to return to previous font after switching to Greek or
43;       symbol font.
44;
45;       Revision 1.3  1996/02/08 19:49:35  mcraig
46;       Removed control sequence \perp because the postscript code for it is '^'.
47;
48;       Revision 1.2  1996/02/08 18:53:38  mcraig
49;       Added translations for PostScript fonts, and added several new TeX
50;       control sequences.
51;
52;       Revision 1.1  1996/01/31 18:47:37  mcraig
53;       Initial revision
54;
55; RELEASE:
56;       $Name: Rel_1_2 $
57;
58; COPYRIGHT:
59;  Copyright (C) 1996 The Regents of the University of California, All
60;  Rights Reserved.  Written by Matthew W. Craig.
61;  See the file COPYRIGHT for restrictions on distrubting this code.
62;  This code comes with absolutely NO warranty; see DISCLAIMER for details.
63;-
64;
65FUNCTION textable, POSTSCRIPT=ps, VECTOR=vec,  HELP=Help
66
67; Return to caller if error.
68    On_error, 2
69
70; Print help if necessary.
71    IF keyword_set(Help)  THEN BEGIN
72        offset = '   '
73        print, offset+'Returns a translation table from TeX to IDL.'
74        print, offset+'table = textable()'
75        print, offset+'Keywords:'
76        print, offset+offset+'/POSTSCRIPT -- If set, return postscript translation'
77        print, offset+offset+'               table rather than vector fonts table.'
78        print, offset+offset+'               Default is translations for vector'
79        print, offset+offset+'               fonts.'
80        print, offset+offset+'/HELP       -- Print help and exit.'
81        print, offset+'Outputs:'
82        print, offset+offset+'table -- a 2D text array.  table(0,*) contains          out'
83        print, offset+offset+'         the words to be translated away, table(1,*)'
84        print, offset+offset+'         contains the words to translate them to.'
85        print, offset+'Notes:'
86        print, offset+offset+'To find out what TeX sequences are available, look at'
87        print, offset+offset+'table(0,*).'
88    ENDIF
89
90    VECFONT=1                   ; index of vector font in translation table
91    PSFONT=2                    ; index of postscript font in trans table
92    IF keyword_set(ps) THEN FontSelection=PSFONT ELSE FontSelection=VECFONT
93
94;  Set IDL font sequence needed to switch to Greek letters.
95    GreekFont = strarr(3)
96    GreekFont(VECFONT) = '!7'
97    GreekFont(PSFONT) = '!M'
98
99;  Set IDL font sequence needed to switch to special symbol font.
100    SymbolFont = strarr(3)
101    SymbolFont(VECFONT) = '!M'
102    SymbolFont(PSFONT) = '!M'
103
104;  Set IDL font sequence needed to switch back to initial font.
105    PreviousFont = strarr(3)
106    PreviousFont(VECFONT) = '!X'
107    PreviousFont(PSFONT) = '!X'
108
109;lowercase Greek --
110;    Note there is some trickery involved in getting \varphi
111;    to work in the vector fonts, because it is actually
112;    a member of the symbol font set, not the Greek font
113;    set.  Go figure.  Solution is just to make the vector
114;    character a switch to symbol, the proper character from
115;    that font, and a switch back out of symbol.  Same comment holds
116;    for \vartheta.
117;;        TeX SEQUENCE       VECTOR       POSTSCRIPT
118    LowercaseGreek = [$
119        [ '\alpha',             'a'     ,     'a'     ],$
120        [ '\beta',              'b'     ,     'b'     ],$
121        [ '\gamma',             'c'     ,     'g'     ],$
122        [ '\delta',             'd'     ,     'd'     ],$
123        [ '\epsilon',           'e'     ,     'e'     ],$
124        [ '\zeta',              'f'     ,     'z'     ],$
125        [ '\eta',               'g'     ,     'h'     ],$
126        [ '\theta',             'h'     ,     'q'     ],$
127        [ '\iota',              'i'     ,     'i'     ],$
128        [ '\kappa',             'j'     ,     'k'     ],$
129        [ '\lambda',            'k'     ,     'l'     ],$
130        [ '\mu',                'l'     ,     'm'     ],$
131        [ '\nu',                'm'     ,     'n'     ],$
132        [ '\xi',                'n'     ,  '!S !Rx'   ],$
133        [ '\pi',                'p'     ,     'p'     ],$
134        [ '\rho',               'q'     ,     'r'     ],$
135        [ '\sigma',             'r'     ,     's'     ],$
136        [ '\tau',               's'     ,     't'     ],$
137        [ '\upsilon',           't'     ,     'u'     ],$
138        [ '\phi',               'u'     ,     'f'     ],$
139        [ '\chi',               'v'     ,     'c'     ],$
140        [ '\psi',               'w'     ,     'y'     ],$
141        [ '\omega',             'x'     ,     'w'     ],$
142        [ '\varpi',             'p'     ,     'v'     ],$
143        [ '\varepsilon',        'e'     ,     'e'     ],$
144        [ '\varphi',    $
145            SymbolFont(VECFONT)+'P'+PreviousFont(VECFONT) $
146                                        ,     'j'     ],$
147        [ '\vartheta',  $
148            SymbolFont(VECFONT)+'t'+PreviousFont(VECFONT) $
149                                        ,     'J'     ]$
150                             ]
151;Uppercase Greek --
152;;        TeX SEQUENCE        VECTOR          POSTSCRIPT
153    UppercaseGreek = [$
154        [ '\Gamma',             'C'   ,         'G'         ],$
155        [ '\Delta',             'D'   ,         'D'         ],$
156        [ '\Theta',             'H'   ,         'Q'         ],$
157        [ '\Lambda',            'K'   ,         'L'         ],$
158        [ '\Xi',                'N'   ,      '!S !RX'       ],$
159        [ '\Pi',                'P'   ,         'P'         ],$
160        [ '\Sigma',             'R'   ,         'S'         ],$
161        [ '\Upsilon',           'T'   ,  string(byte(161))  ],$
162        [ '\Phi',               'U'   ,         'F'         ],$
163        [ '\Psi',               'W'   ,         'Y'         ],$
164        [ '\Omega',             'X'   ,         'W'         ]$
165                           ]
166;Special symbols --
167;  NOTES -- You must leave \infty before \in in the translatation
168;           table to avoid having the \in part of \infty translated
169;           away.
170;           
171;           DO NOT blindly add the control sequence \perp.  Its
172;           PostScript code is '^', which leads to thing being
173;           interpreted as superscripts which shouldn't be.
174;
175;;        TeX SEQUENCE        VECTOR          POSTSCRIPT
176    Symbols = [$
177        [ '\aleph',             '@'   ,  string(byte(192))  ],$
178        [ '\ast',               '*'   ,         '*'         ],$
179        [ '\cap',               '3'   ,  string(byte(199))  ],$
180        [ '\cdot',              '.'   ,  string(byte(215))  ],$
181        [ '\cup',               '1'   ,  string(byte(200))  ],$
182        [ '\exists',            'E'   ,         '$'         ],$
183        [ '\infty',             '$'   ,  string(byte(165))  ],$
184        [ '\in',                'e'   ,  string(byte(206))  ],$
185        [ '\equiv',             ':'   ,  string(byte(186))  ],$
186        [ '\pm',                '+'   ,  string(byte(177))  ],$
187        [ '\div',               '/'   ,  string(byte(184))  ],$
188        [ '\subset',            '0'   ,  string(byte(204))  ],$
189        [ '\superset',          '2'   ,  string(byte(201))  ],$
190        [ '\leftarrow',         '4'   ,  string(byte(172))  ],$
191        [ '\downarrow',         '5'   ,  string(byte(175))  ],$
192        [ '\rightarrow',        '6'   ,  string(byte(174))  ],$
193        [ '\uparrow',           '7'   ,  string(byte(173))  ],$
194        [ '\neq',               '='   ,  string(byte(185))  ],$
195        [ '\propto',            '?'   ,  string(byte(181))  ],$
196        [ '\sim',               'A'   ,  string(byte(126))  ],$
197        [ '\partial',           'D'   ,  string(byte(182))  ],$
198        [ '\nabla',             'G'   ,  string(byte(209))  ],$
199        [ '\angle',             'a'   ,  string(byte(208))  ],$
200        [ '\times',             'X'   ,  string(byte(180))  ],$
201        [ '\geq',               'b'   ,  string(byte(179))  ],$
202        [ '\leq',               'l'   ,  string(byte(163))  ],$
203        [ "\'",                 "'"   ,  string(byte(162))  ],$
204        [ '\prime',             "'"   ,  string(byte(162))  ],$
205        [ '\circ',              "%"   ,  string(byte(176))  ]$
206                          ]
207    LowercaseGreek(1,*) = $
208      GreekFont(FontSelection) $
209      + LowercaseGreek(FontSelection,*) $
210      + PreviousFont(FontSelection)
211    UppercaseGreek(1,*) = $
212      GreekFont(FontSelection) +$
213      UppercaseGreek(FontSelection,*) $
214      + PreviousFont(FontSelection)
215    Symbols(1,*) = $
216      SymbolFont(FontSelection) $
217      + Symbols(FontSelection,*) $
218      + PreviousFont(FontSelection)
219
220    TranslationTable = [[LowercaseGreek],[UppercaseGreek],[Symbols]]
221    return,TranslationTable(0:1,*)
222
223END
224
Note: See TracBrowser for help on using the repository browser.