/[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.2 by gforget, Tue Jul 5 18:52:18 2011 UTC revision 1.3 by gforget, Fri Jul 8 12:58:14 2011 UTC
# Line 2  function []=write2tex(myFile,myStep,vara Line 2  function []=write2tex(myFile,myStep,vara
2  %object:        create/increment/complete/compile a tex file from within matlab  %object:        create/increment/complete/compile a tex file from within matlab
3  %input:         myFile is the file name  %input:         myFile is the file name
4  %               myStep is the operation to perform on the tex file  %               myStep is the operation to perform on the tex file
5  %                       0   create file starting with write2tex.header  %                       0   create file starting with title page (see myText)
6  %(not yet)              1   add title or section page (see myLev)  %                       1   add section or subsection (see myLev)
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
# Line 11  function []=write2tex(myFile,myStep,vara Line 11  function []=write2tex(myFile,myStep,vara
11  %                       -5  compile solely  %                       -5  compile solely
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  %                       0=manuscript title, 1=section, 2=subsection  %                       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=[];  myText=[]; myLev=[]; myFig=[];
18  if myStep>0&myStep<4; myText=varargin{1}; end;  if myStep<4; myText=varargin{1}; end;
19  if myStep==1; myLev=varargin{2};  if myStep==1; myLev=varargin{2};
20  elseif myStep==2; myFig=varargin{2};  elseif myStep==2; myFig=varargin{2};
21  end;  end;
# Line 31  if myStep==0; Line 31  if myStep==0;
31      if ~test0;      if ~test0;
32          return;          return;
33      else;      else;
34          tmp1=which('write2tex');          fid=fopen(myFile,'w');
35          eval(['!\cp -f ' tmp1(1:end-2) '.header ' myFile ]);  
36            fprintf(fid,'\\documentclass[12pt]{beamer}\n');
37            fprintf(fid,'%%a nice series of examples for the beamer class:\n');
38            fprintf(fid,'%%http://www.informatik.uni-freiburg.de/~frank/ENG/beamer/example/beamer-class-example-en-5.html\n');
39            fprintf(fid,'\\begin{document} \n\n');
40    
41            fprintf(fid,'\\title{\n');
42            for ii=1:length(myText); fprintf(fid,[myText{ii} '\\\\ \n']); end;
43            fprintf(fid,'}\n\n');
44            fprintf(fid,'\\date{\\today}\n\n');
45            fprintf(fid,'\\frame{\\titlepage}\n\n');
46    
47            fprintf(fid,'\\frame{');
48            fprintf(fid,'\\frametitle{Table of contents}');
49            fprintf(fid,'\\tableofcontents');
50            fprintf(fid,'} \n\n');
51    
52            fclose(fid);
53      end;      end;
54      myFigNumTex=0;      myFigNumTex=0;
55      eval(['save ' myFile(1:end-4) '.mat myFigNumTex;']);      mySection='';
56        eval(['save ' myFile(1:end-4) '.mat myFigNumTex mySection;']);
57  end;  end;
58    
59  %open file and go to last line  %open file and go to last line
60  fid=fopen(myFile,'a+');  fid=fopen(myFile,'a+');
61  eval(['load ' myFile(1:end-4) '.mat myFigNumTex;']);  eval(['load ' myFile(1:end-4) '.mat;']);
62    
63  %add title or section page (see myLev)  %add title or section page (see myLev)
64    if myStep==1;
65        mySection=myText;
66        fprintf(fid,'\\section{\n');
67        fprintf(fid,mySection);
68        fprintf(fid,'} \n\n');
69    end;
70    
71  %add a figure plus caption (see myFig)  %add a figure plus caption (see myFig)
72  if myStep==2;  if myStep==2;
# Line 60  if myStep==2; Line 84  if myStep==2;
84      close;      close;
85      %add figure to text file      %add figure to text file
86      fprintf(fid,'\\frame{ \n');      fprintf(fid,'\\frame{ \n');
87        fprintf(fid,['\\frametitle{' mySection '} \n']);
88      fprintf(fid,'\\begin{figure}[tbh] \\centering \n');      fprintf(fid,'\\begin{figure}[tbh] \\centering \n');
89  %     fprintf(fid,'\\includegraphics[width=\\textwidth,height=0.9\\textheight]');  %     fprintf(fid,'\\includegraphics[width=\\textwidth,height=0.9\\textheight]');
90      fprintf(fid,'\\includegraphics[width=0.85\\textwidth]');      fprintf(fid,'\\includegraphics[width=0.75\\textwidth]');
91      fprintf(fid,['{' fileTex '.fig' num2str(myFigNumTex) '}\n']);      fprintf(fid,['{' fileTex '.fig' num2str(myFigNumTex) '}\n']);
92      fprintf(fid,'\\caption{');      fprintf(fid,'\\caption{');
93      for ii=1:length(myText); fprintf(fid,[myText{ii} '\n']); end;      for ii=1:length(myText); fprintf(fid,[myText{ii} '\n']); end;
# Line 83  if myStep==4; fprintf(fid,'\n\n \\end{do Line 108  if myStep==4; fprintf(fid,'\n\n \\end{do
108  %close file  %close file
109  fprintf(fid,'\n\n');  fprintf(fid,'\n\n');
110  fclose(fid);  fclose(fid);
111  eval(['save ' myFile(1:end-4) '.mat myFigNumTex;']);  eval(['save ' myFile(1:end-4) '.mat myFigNumTex mySection;']);
112    
113  %compile  %compile
114  if myStep==5|myStep==-5;  if myStep==5|myStep==-5;

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

  ViewVC Help
Powered by ViewVC 1.1.22