/[MITgcm]/MITgcm_contrib/gael/matlab_class/gcmfaces_misc/write2tex.m
ViewVC logotype

Diff of /MITgcm_contrib/gael/matlab_class/gcmfaces_misc/write2tex.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.3 by gforget, Fri Jul 8 12:58:14 2011 UTC revision 1.6 by gforget, Fri Jan 31 19:10:46 2014 UTC
# Line 7  function []=write2tex(myFile,myStep,vara Line 7  function []=write2tex(myFile,myStep,vara
7  %                       2   add a figure plus caption (see myFig)  %                       2   add a figure plus caption (see myFig)
8  %                       3   add a paragraph  %                       3   add a paragraph
9  %                       4   finish file  %                       4   finish file
10  %                       5   compile and remove temporary files (incl. *fig*.ps)  %                       5   compile (latex x 2 then dvipdf)
11  %                       -5  compile solely  %                       6   remove temporary files (incl. *fig*.ps)
12  %optional       myText is a cell array of text lines (for myStep=1 to 2)  %optional       myText is a cell array of text lines (for myStep=1 to 2)
13  %               myLev is the title level (for myStep=1)  %               myLev is the title level (for myStep=1)
14  %                       1=section, 2=subsection (not yet implemented)  %                       1=section, 2=subsection (not yet implemented)
15  %               myFig is a figure handle (for myStep=2)  %               myFig is a figure handle (for myStep=2)
16    
17    if isempty(myFile);
18        %if no file name, then do nothing
19        return;
20    end;
21    if iscell(myFile);
22        %extecute alternative command (myFile{1}) passing rest as arguments  
23        eval([myFile{1} '(myFile{2:end});']);
24        return;
25    end;
26    
27    
28  myText=[]; myLev=[]; myFig=[];  myText=[]; myLev=[]; myFig=[];
29  if myStep<4; myText=varargin{1}; end;  if myStep<4; myText=varargin{1}; end;
30  if myStep==1; myLev=varargin{2};  if myStep==1; myLev=varargin{2};
# Line 63  eval(['load ' myFile(1:end-4) '.mat;']); Line 74  eval(['load ' myFile(1:end-4) '.mat;']);
74  %add title or section page (see myLev)  %add title or section page (see myLev)
75  if myStep==1;  if myStep==1;
76      mySection=myText;      mySection=myText;
77      fprintf(fid,'\\section{\n');      if myLev==1; fprintf(fid,'\\section{\n');
78        else; fprintf(fid,'\\subsection{\n');
79        end;
80      fprintf(fid,mySection);      fprintf(fid,mySection);
81      fprintf(fid,'} \n\n');      fprintf(fid,'} \n\n');
82  end;  end;
# Line 111  fclose(fid); Line 124  fclose(fid);
124  eval(['save ' myFile(1:end-4) '.mat myFigNumTex mySection;']);  eval(['save ' myFile(1:end-4) '.mat myFigNumTex mySection;']);
125    
126  %compile  %compile
127  if myStep==5|myStep==-5;  if myStep==5;
128      dirOrig=pwd;      dirOrig=pwd;
129      nn=strfind(myFile,'/');      nn=strfind(myFile,'/');
130      if ~isempty(nn);      if ~isempty(nn);
131          cd(myFile(1:nn)); fileTex=myFile(nn+1:end-4);          cd(myFile(1:nn(end))); fileTex=myFile(nn(end)+1:end-4);
132      else;      else;
133          fileTex=myFile(1:end-4);          fileTex=myFile(1:end-4);
134      end;      end;
135        keyboard;
136      eval(['!latex ' fileTex]);      eval(['!latex ' fileTex]);
137      eval(['!latex ' fileTex]);      eval(['!latex ' fileTex]);
138      eval(['!dvipdf ' fileTex]);      eval(['!dvipdf ' fileTex]);
# Line 127  end; Line 141  end;
141    
142    
143  %compile  %compile
144  if myStep==5;  if myStep==6;
145      dirOrig=pwd;      dirOrig=pwd;
146      nn=strfind(myFile,'/');      nn=strfind(myFile,'/');
147      if ~isempty(nn);      if ~isempty(nn);
148          cd(myFile(1:nn)); fileTex=myFile(nn+1:end-4);          cd(myFile(1:nn(end))); fileTex=myFile(nn(end)+1:end-4);
149      else;      else;
150          fileTex=myFile(1:end-4);          fileTex=myFile(1:end-4);
151      end;      end;

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.6

  ViewVC Help
Powered by ViewVC 1.1.22