/[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.9 by gforget, Mon Jul 28 20:54:14 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  myText=[]; myLev=[]; myFig=[];  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=[]; myRdm=[];
29  if myStep<4; myText=varargin{1}; end;  if myStep<4; myText=varargin{1}; end;
30  if myStep==1; myLev=varargin{2};  if myStep==0; myRdm=varargin{2};
31    elseif myStep==1; myLev=varargin{2};
32  elseif myStep==2; myFig=varargin{2};  elseif myStep==2; myFig=varargin{2};
33  end;  end;
34    
# Line 36  if myStep==0; Line 48  if myStep==0;
48          fprintf(fid,'\\documentclass[12pt]{beamer}\n');          fprintf(fid,'\\documentclass[12pt]{beamer}\n');
49          fprintf(fid,'%%a nice series of examples for the beamer class:\n');          fprintf(fid,'%%a nice series of examples for the beamer class:\n');
50          fprintf(fid,'%%http://www.informatik.uni-freiburg.de/~frank/ENG/beamer/example/beamer-class-example-en-5.html\n');          fprintf(fid,'%%http://www.informatik.uni-freiburg.de/~frank/ENG/beamer/example/beamer-class-example-en-5.html\n');
51            fprintf(fid,'\\usepackage{multicol}\n');
52    
53            fprintf(fid,'\n');
54            fprintf(fid,'\\newcommand\\Fontvi{\\fontsize{6}{7.2}\\selectfont}\n');
55            fprintf(fid,'\n');
56    
57          fprintf(fid,'\\begin{document} \n\n');          fprintf(fid,'\\begin{document} \n\n');
58    
59          fprintf(fid,'\\title{\n');          fprintf(fid,'\\title{\n');
# Line 44  if myStep==0; Line 62  if myStep==0;
62          fprintf(fid,'\\date{\\today}\n\n');          fprintf(fid,'\\date{\\today}\n\n');
63          fprintf(fid,'\\frame{\\titlepage}\n\n');          fprintf(fid,'\\frame{\\titlepage}\n\n');
64    
65          fprintf(fid,'\\frame{');          fprintf(fid,'\\frame{\n');
66          fprintf(fid,'\\frametitle{Table of contents}');          fprintf(fid,'\\frametitle{Table of contents}\n');
67          fprintf(fid,'\\tableofcontents');          fprintf(fid,'\\begin{multicols}{2}\n');
68            fprintf(fid,'\\Fontvi\n');
69            fprintf(fid,'\\tableofcontents\n');
70            fprintf(fid,'\\end{multicols}\n');
71          fprintf(fid,'} \n\n');          fprintf(fid,'} \n\n');
72    
73            if ~isempty(myRdm);
74              fprintf(fid,'\\frame{\n');
75              fprintf(fid,'\\section{README}\n');
76              fprintf(fid,'\\Fontvi\n');
77              for pp=1:length(myRdm);
78                fprintf(fid,[myRdm{pp} '\n\n']);
79              end;
80              fprintf(fid,'} \n\n');
81            end;
82    
83          fclose(fid);          fclose(fid);
84      end;      end;
85      myFigNumTex=0;      myFigNumTex=0;
# Line 63  eval(['load ' myFile(1:end-4) '.mat;']); Line 94  eval(['load ' myFile(1:end-4) '.mat;']);
94  %add title or section page (see myLev)  %add title or section page (see myLev)
95  if myStep==1;  if myStep==1;
96      mySection=myText;      mySection=myText;
97      fprintf(fid,'\\section{\n');      if myLev==1; fprintf(fid,'\\section{\n');
98        else; fprintf(fid,'\\subsection{\n');
99        end;
100      fprintf(fid,mySection);      fprintf(fid,mySection);
101      fprintf(fid,'} \n\n');      fprintf(fid,'} \n\n');
102  end;  end;
# Line 73  if myStep==2; Line 106  if myStep==2;
106      figure(myFig);      figure(myFig);
107      drawnow;      drawnow;
108      myFigNumTex=myFigNumTex+1;      myFigNumTex=myFigNumTex+1;
109      nn=strfind(myFile,'/');      nn=strfind(myFile,filesep);
110      if ~isempty(nn);      if ~isempty(nn);
111          dirTex=myFile(1:nn(end)); fileTex=myFile(nn(end)+1:end-4);          dirTex=myFile(1:nn(end)); fileTex=myFile(nn(end)+1:end-4);
112      else;      else;
# Line 111  fclose(fid); Line 144  fclose(fid);
144  eval(['save ' myFile(1:end-4) '.mat myFigNumTex mySection;']);  eval(['save ' myFile(1:end-4) '.mat myFigNumTex mySection;']);
145    
146  %compile  %compile
147  if myStep==5|myStep==-5;  if myStep==5;
148      dirOrig=pwd;      dirOrig=pwd;
149      nn=strfind(myFile,'/');      nn=strfind(myFile,filesep);
150      if ~isempty(nn);      if ~isempty(nn);
151          cd(myFile(1:nn)); fileTex=myFile(nn+1:end-4);          cd(myFile(1:nn(end))); fileTex=myFile(nn(end)+1:end-4);
152      else;      else;
153          fileTex=myFile(1:end-4);          fileTex=myFile(1:end-4);
154      end;      end;
155      eval(['!latex ' fileTex]);      system(['latex ' fileTex]);
156      eval(['!latex ' fileTex]);      system(['latex ' fileTex]);
157      eval(['!dvipdf ' fileTex]);      system(['dvipdf ' fileTex]);
158      cd(dirOrig);      cd(dirOrig);
159  end;  end;
160    
161    
162  %compile  %compile
163  if myStep==5;  if myStep==6&ispc;
164        fprintf('warning : compiling tex to pdf is bypassed on PCs\n');
165    end;
166    
167    if myStep==6&~ispc;
168      dirOrig=pwd;      dirOrig=pwd;
169      nn=strfind(myFile,'/');      nn=strfind(myFile,filesep);
170      if ~isempty(nn);      if ~isempty(nn);
171          cd(myFile(1:nn)); fileTex=myFile(nn+1:end-4);          cd(myFile(1:nn(end))); fileTex=myFile(nn(end)+1:end-4);
172      else;      else;
173          fileTex=myFile(1:end-4);          fileTex=myFile(1:end-4);
174      end;      end;
175      eval(['!\rm -f ' fileTex '.fig*']);      delete([fileTex '.fig*']);
176      eval(['!\rm -f ' fileTex '.aux']);      delete([fileTex '.aux']);
177      eval(['!\rm -f ' fileTex '.log']);      delete([fileTex '.log']);
178      eval(['!\rm -f ' fileTex '.out']);      delete([fileTex '.out']);
179      eval(['!\rm -f ' fileTex '.dvi']);      delete([fileTex '.dvi']);
180      cd(dirOrig);      cd(dirOrig);
181  end;  end;

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

  ViewVC Help
Powered by ViewVC 1.1.22