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