/[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.9 by gforget, Mon Jul 28 20:54:14 2014 UTC revision 1.13 by gforget, Mon Oct 5 22:00:09 2015 UTC
# Line 32  elseif myStep==1; myLev=varargin{2}; Line 32  elseif myStep==1; myLev=varargin{2};
32  elseif myStep==2; myFig=varargin{2};  elseif myStep==2; myFig=varargin{2};
33  end;  end;
34    
35    %format use for printing out plots :
36    frmt='eps';
37    if ispc; frmt='jpg'; end;
38    
39  %create file starting with write2tex.header  %create file starting with write2tex.header
40  if myStep==0;  if myStep==0;
41      test0=dir(myFile);      test0=dir(myFile);
# Line 106  if myStep==2; Line 110  if myStep==2;
110      figure(myFig);      figure(myFig);
111      drawnow;      drawnow;
112      myFigNumTex=myFigNumTex+1;      myFigNumTex=myFigNumTex+1;
113      nn=strfind(myFile,filesep);      [dirTex,fileTex,EXT] = fileparts(myFile);
     if ~isempty(nn);  
         dirTex=myFile(1:nn(end)); fileTex=myFile(nn(end)+1:end-4);  
     else;  
         dirTex='./'; fileTex=myFile(1:end-4)  
     end;  
114      %print the very figure      %print the very figure
115      print(myFig,'-depsc',[dirTex fileTex '.fig' num2str(myFigNumTex)]);      if strcmp(frmt,'eps');
116          print(myFig,'-depsc',[dirTex fileTex '_fig' num2str(myFigNumTex) '.eps']);
117        elseif strcmp(frmt,'jpg');
118          print(myFig,'-djpeg90',[dirTex fileTex '_fig' num2str(myFigNumTex) '.jpg']);
119        elseif strcmp(frmt,'png');
120          print(myFig,'-dpng',[dirTex fileTex '_fig' num2str(myFigNumTex) '.png']);
121        end
122      close;      close;
123      %add figure to text file      %add figure to text file
124      fprintf(fid,'\\frame{ \n');      fprintf(fid,'\\frame{ \n');
# Line 121  if myStep==2; Line 126  if myStep==2;
126      fprintf(fid,'\\begin{figure}[tbh] \\centering \n');      fprintf(fid,'\\begin{figure}[tbh] \\centering \n');
127  %     fprintf(fid,'\\includegraphics[width=\\textwidth,height=0.9\\textheight]');  %     fprintf(fid,'\\includegraphics[width=\\textwidth,height=0.9\\textheight]');
128      fprintf(fid,'\\includegraphics[width=0.75\\textwidth]');      fprintf(fid,'\\includegraphics[width=0.75\\textwidth]');
129      fprintf(fid,['{' fileTex '.fig' num2str(myFigNumTex) '}\n']);      fprintf(fid,['{' fileTex '_fig' num2str(myFigNumTex) '.' frmt '}\n']);
130      fprintf(fid,'\\caption{');      fprintf(fid,'\\caption{');
131      for ii=1:length(myText); fprintf(fid,[myText{ii} '\n']); end;      for ii=1:length(myText); fprintf(fid,[myText{ii} '\n']); end;
132      fprintf(fid,'} \\end{figure} \n');      fprintf(fid,'} \\end{figure} \n');
# Line 145  eval(['save ' myFile(1:end-4) '.mat myFi Line 150  eval(['save ' myFile(1:end-4) '.mat myFi
150    
151  %compile  %compile
152  if myStep==5;  if myStep==5;
153      dirOrig=pwd;      fprintf('\nNow we can attempt to compile the tex file from within Matlab. \n');
154      nn=strfind(myFile,filesep);      fprintf('If the latex implementation is incomplete then this may fail, and \n');
155      if ~isempty(nn);      fprintf('user should then abort and compile the tex file from outside Matlab. \n');
156          cd(myFile(1:nn(end))); fileTex=myFile(nn(end)+1:end-4);      fprintf('The beamer class is required by in particular. In Matlab, if prompted \n');
157      else;      fprintf(' with a question mark then typing ''quit'' will abort compilation. \n');
158          fileTex=myFile(1:end-4);      test0=input('\n type 1 to proceed or 0 to skip this attempt\n');
159        if test0;
160          dirOrig=pwd;
161          [PATHSTR,fileTex,EXT] = fileparts(myFile);
162          cd(PATHSTR);
163          system(['latex ' fileTex]);
164          system(['latex ' fileTex]);
165          system(['dvipdf ' fileTex]);
166          cd(dirOrig);
167      end;      end;
     system(['latex ' fileTex]);  
     system(['latex ' fileTex]);  
     system(['dvipdf ' fileTex]);  
     cd(dirOrig);  
168  end;  end;
169    
170    
# Line 172  if myStep==6&~ispc; Line 181  if myStep==6&~ispc;
181      else;      else;
182          fileTex=myFile(1:end-4);          fileTex=myFile(1:end-4);
183      end;      end;
184      delete([fileTex '.fig*']);      delete([fileTex '_fig*']);
185      delete([fileTex '.aux']);      delete([fileTex '.aux']);
186      delete([fileTex '.log']);      delete([fileTex '.log']);
187      delete([fileTex '.out']);      delete([fileTex '.out']);

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.13

  ViewVC Help
Powered by ViewVC 1.1.22