PRO ArrayStrPrint,A,Lines=lines ;+ ;PROCEDURE ArrayStrPrint,A produces a Latex array ;from a string array. It inserts & characters between ;intems and terminates each row with \\. The result ;is printed on the screen and can be cut and pasted ;into a Latex document as a TeX field. Can be used wherever ;a tabular field is desired. Use a text editor to add elements ;such as \hline and so on if you need dividing lines. The ;entries are printed as integers. ; ;USAGE ;ArrayStrPrint,A ;Prints results on the screen. ; ;KEYWORDS: ;LINES Set /Lines to have the array printed with row and column lines. ; ;Harvey Rhody April 21, 2001 ;- SIZA=SIZE(A) IF SIZA[0] GT 2 THEN MESSAGE,'Array must be dimension 1 or 2' ;Set things for a Scientific Workplace Table ; Form without lines IF NOT Keyword_Set(lines) THEN BEGIN st=STRARR(SIZA[1]) FOR i=0,SIZA[1]-1 DO st[i]='c' ; Form with lines ENDIF ELSE BEGIN st=STRARR(sizA[1]) st[0]='|c|' For i=1,sizA[1]-1 DO st[i]='c|' ENDELSE header=['\begin{tabular}{',st,'}'] footer='\end{tabular} IF Keyword_Set(lines) THEN line='\hline' ELSE line='' PRINT,header IF Keyword_Set(lines) THEN Print,'\hline' IF SIZA[0] EQ 1 THEN BEGIN For i=0,siza[1]-2 DO PRINT,FORMAT='($,A," & ")',A[i] Print,A[siza[1]-1] IF Keyword_Set(lines) THEN Print,'\hline' Print,footer RETURN ENDIF $ ELSE FOR i=0,SIZA[2]-1 DO BEGIN FOR j=0,SIZA[1]-2 DO $ PRINT,FORMAT='($,"\tiny{",A,"}"," & ")',A[j,i] PRINT,"\tiny{",A[siza[1]-1,i],"}" IF Keyword_Set(lines) THEN Print,'\\ \hline' ELSE PRINT,' \\ ' ENDFOR PRINT,footer END