source: trunk/SRC/Textoidl/textable.pro @ 297

Last change on this file since 297 was 297, checked in by pinsard, 17 years ago

typo

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