Changeset 226 for trunk/SRC/Textoidl/translate_sub_super.pro
- Timestamp:
- 03/16/07 10:22:26 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/Textoidl/translate_sub_super.pro
r163 r226 2 2 ; @file_comments 3 3 ; Return the proper IDL font positioning command for TeX 4 ; sub/superscripts. 4 ; sub/superscripts. 5 5 ; 6 6 ; @categories … … 25 25 ; function. So even if sub_sup_idl was declared with 26 26 ; FORWARD_FUNCTION in translate_sub_super, it would not properly 27 ; compile. 27 ; compile. 28 28 ; 29 29 ; The file translate_sub_super.pro contains two functions, … … 36 36 ; Used only by translate_sub_super. Should be kept in same 37 37 ; file. 38 ; 38 ; 39 39 ; @examples 40 40 ; … … 86 86 print, offset+offset+" or '!D' or '!I' for subscripts." 87 87 return, -1 88 ENDIF 89 90 IF keyword_set(force_ud) THEN BEGIN 91 IF (token EQ '^') THEN return, '!U' 88 ENDIF 89 90 IF keyword_set(force_ud) THEN BEGIN 91 IF (token EQ '^') THEN return, '!U' 92 92 IF (token EQ '_') THEN return, '!D' 93 93 return, '' 94 94 ENDIF ELSE BEGIN 95 IF (token EQ '^') THEN return, '!E' 95 IF (token EQ '^') THEN return, '!E' 96 96 IF (token EQ '_') THEN return, '!I' 97 97 return, '' 98 98 ENDELSE 99 99 100 100 END 101 101 … … 113 113 ; old -- string to be translated from TeX to IDL. in 114 114 ; KEYWORD PARAMETERS: 115 ; /RECURSED -- set if this function is being called 116 ; recursively. 115 ; /RECURSED -- set if this function is being called 116 ; recursively. 117 117 ; /HELP -- Set to print useful message and exit. 118 118 ; OUTPUTS: … … 130 130 ; out = translate_sub_super( 'N^2_{big}' ) 131 131 ; Then out='N!U2!N!Dbig!N' which looks like it should on the 132 ; display. 132 ; display. 133 133 ; LIBRARY FUNCTIONS CALLED: 134 134 ; str_token -- Text/string (mcraig) … … 195 195 print, offset+offset+"- Sub/superscripts may be nested (e.g. 'N^{N_1^N}')." 196 196 return, -1 197 ENDIF 197 ENDIF 198 198 199 199 ; To allow for nested scripts, use !E/!I instead of !U/!D for scripts … … 233 233 EndOfScript = 0 ;Position of end of this script. 234 234 IF (Script EQ '{') THEN BEGIN ; Scripts of more than 1 char. 235 EndOfScript = matchdelim(strn) 235 EndOfScript = matchdelim(strn) 236 236 Script = translate_sub_super(strmid(strn, 1, EndOfScript-1), $ 237 237 /recursed ) 238 ENDIF 239 ; Grab rest of string _after_ the end of the script. 238 ENDIF 239 ; Grab rest of string _after_ the end of the script. 240 240 strn = strmid(strn, EndOfScript+1, $ 241 241 strlen(strn)-EndOfScript-1) … … 265 265 StorePos = '' 266 266 RecallPos = '' 267 ; calculate the difference in length between this script and the 267 ; calculate the difference in length between this script and the 268 268 ; previous stacked one, removing font change commands (crudely by 269 269 ; guessing that the number of characters this takes is twice the … … 276 276 ENDIF ELSE BEGIN 277 277 IF (Token NE OldToken) AND (pos EQ 0) THEN BEGIN 278 ; The next script immediately fol ows this one. Arrange to278 ; The next script immediately follows this one. Arrange to 279 279 ; save the position of the current script so that both begin 280 280 ; with the same horizontal position. … … 283 283 LenLastScript = strlen(Script) - 2*strcnt(Script,'!') 284 284 ENDIF 285 ENDELSE 285 ENDELSE 286 286 287 287 ; Continue building the IDL string, adding on our just processed script. … … 289 289 + FontRestore 290 290 291 IF ( pos NE -1 ) THEN BEGIN ; more left to process 291 IF ( pos NE -1 ) THEN BEGIN ; more left to process 292 292 NewString = NewString $ 293 + str_token(strn, Token) 293 + str_token(strn, Token) 294 294 ENDIF ELSE BEGIN ; we are done 295 295 NewString = NewString + strn 296 296 strn = '' 297 297 ENDELSE 298 ENDWHILE 299 298 ENDWHILE 299 300 300 return, NewString 301 301 END
Note: See TracChangeset
for help on using the changeset viewer.