[163] | 1 | ;+ |
---|
| 2 | ; @file_comments |
---|
| 3 | ; Returns a translation table from TeX to IDL. |
---|
[2] | 4 | ; |
---|
[163] | 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 |
---|
[7] | 27 | ; $Log: textable.pro,v $ |
---|
[47] | 28 | ; Revision 1.8 2004/06/15 17:25:54 mcraig |
---|
| 29 | ; Fixed bug in regular expression, changed array notation to square brackets |
---|
| 30 | ; |
---|
[2] | 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. |
---|
[163] | 58 | ; |
---|
| 59 | ; @version |
---|
| 60 | ; $Id$ |
---|
[2] | 61 | ;- |
---|
| 62 | FUNCTION textable, POSTSCRIPT=ps, VECTOR=vec, HELP=Help |
---|
[114] | 63 | ; |
---|
| 64 | compile_opt idl2, strictarrsubs |
---|
| 65 | ; |
---|
[2] | 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) |
---|
[47] | 96 | GreekFont[VECFONT] = '!7' |
---|
| 97 | GreekFont[PSFONT] = '!M' |
---|
[2] | 98 | |
---|
| 99 | ; Set IDL font sequence needed to switch to special symbol font. |
---|
| 100 | SymbolFont = strarr(3) |
---|
[47] | 101 | SymbolFont[VECFONT] = '!M' |
---|
| 102 | SymbolFont[PSFONT] = '!M' |
---|
[2] | 103 | |
---|
| 104 | ; Set IDL font sequence needed to switch back to initial font. |
---|
| 105 | PreviousFont = strarr(3) |
---|
[47] | 106 | PreviousFont[VECFONT] = '!X' |
---|
| 107 | PreviousFont[PSFONT] = '!X' |
---|
[2] | 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', $ |
---|
[114] | 145 | SymbolFont[VECFONT]+'P'+PreviousFont[VECFONT] $ |
---|
[2] | 146 | , 'j' ],$ |
---|
| 147 | [ '\vartheta', $ |
---|
[114] | 148 | SymbolFont[VECFONT]+'t'+PreviousFont[VECFONT] $ |
---|
[2] | 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 -- |
---|
[297] | 167 | ; NOTES -- You must leave \infty before \in in the translation |
---|
[2] | 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 | ] |
---|
[47] | 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] |
---|
[2] | 219 | |
---|
| 220 | TranslationTable = [[LowercaseGreek],[UppercaseGreek],[Symbols]] |
---|
[47] | 221 | return,TranslationTable[0:1,*] |
---|
[2] | 222 | |
---|
| 223 | END |
---|
| 224 | |
---|