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); |
if isempty(myFile)&myStep==2; |
18 |
|
myText=varargin{1}; |
19 |
|
myText=[myText{:}]; |
20 |
|
gcmfaces_caption(myText); |
21 |
|
return; |
22 |
|
elseif isempty(myFile); |
23 |
%if no file name, then do nothing |
%if no file name, then do nothing |
24 |
return; |
return; |
25 |
end; |
end; |
114 |
if myStep==2; |
if myStep==2; |
115 |
figure(myFig); |
figure(myFig); |
116 |
drawnow; |
drawnow; |
117 |
|
%add (but hide) caption directly in figure |
118 |
|
captionHandle=gcmfaces_caption([myText{:}]); |
119 |
|
set(captionHandle,'Visible','off'); |
120 |
|
set(get(captionHandle,'Children'),'Visible','off'); |
121 |
|
%set file names |
122 |
myFigNumTex=myFigNumTex+1; |
myFigNumTex=myFigNumTex+1; |
123 |
[dirTex,fileTex,EXT] = fileparts(myFile) |
[dirTex,fileTex,EXT] = fileparts(myFile); |
124 |
%print the very figure |
%print figure |
125 |
if strcmp(frmt,'eps'); |
if strcmp(frmt,'eps'); |
126 |
print(myFig,'-depsc',[dirTex fileTex '_fig' num2str(myFigNumTex) '.eps']); |
print(myFig,'-depsc',[dirTex fileTex '_fig' num2str(myFigNumTex) '.eps']); |
127 |
elseif strcmp(frmt,'jpg'); |
elseif strcmp(frmt,'jpg'); |
128 |
print(myFig,'-djpeg90',[dirTex fileTex '_fig' num2str(myFigNumTex) '.jpg']); |
print(myFig,'-djpeg90',[dirTex fileTex '_fig' num2str(myFigNumTex) '.jpg']); |
129 |
elseif strcmp(frmt,'eps'); |
elseif strcmp(frmt,'png'); |
130 |
print(myFig,'-dpng',[dirTex fileTex '_fig' num2str(myFigNumTex) '.png']); |
print(myFig,'-dpng',[dirTex fileTex '_fig' num2str(myFigNumTex) '.png']); |
131 |
end |
end |
132 |
|
%save figure (with visible caption) |
133 |
|
set(captionHandle,'Visible','on'); |
134 |
|
set(get(captionHandle,'Children'),'Visible','on'); |
135 |
|
saveas(myFig,[dirTex fileTex '_fig' num2str(myFigNumTex)],'fig'); |
136 |
|
%close figure |
137 |
close; |
close; |
138 |
%add figure to text file |
%add figure to text file |
139 |
fprintf(fid,'\\frame{ \n'); |
fprintf(fid,'\\frame{ \n'); |
141 |
fprintf(fid,'\\begin{figure}[tbh] \\centering \n'); |
fprintf(fid,'\\begin{figure}[tbh] \\centering \n'); |
142 |
% fprintf(fid,'\\includegraphics[width=\\textwidth,height=0.9\\textheight]'); |
% fprintf(fid,'\\includegraphics[width=\\textwidth,height=0.9\\textheight]'); |
143 |
fprintf(fid,'\\includegraphics[width=0.75\\textwidth]'); |
fprintf(fid,'\\includegraphics[width=0.75\\textwidth]'); |
144 |
fprintf(fid,['{' fileTex '.fig' num2str(myFigNumTex) '}\n']); |
fprintf(fid,['{' fileTex '_fig' num2str(myFigNumTex) '.' frmt '}\n']); |
145 |
fprintf(fid,'\\caption{'); |
fprintf(fid,'\\caption{'); |
146 |
for ii=1:length(myText); fprintf(fid,[myText{ii} '\n']); end; |
for ii=1:length(myText); fprintf(fid,[myText{ii} '\n']); end; |
147 |
fprintf(fid,'} \\end{figure} \n'); |
fprintf(fid,'} \\end{figure} \n'); |
165 |
|
|
166 |
%compile |
%compile |
167 |
if myStep==5; |
if myStep==5; |
168 |
dirOrig=pwd; |
fprintf('\nNow we can attempt to compile the tex file from within Matlab. \n'); |
169 |
[PATHSTR,fileTex,EXT] = fileparts(myFile) |
fprintf('If the latex implementation is incomplete then this may fail, and \n'); |
170 |
cd(PATHSTR); |
fprintf('user should then abort and compile the tex file from outside Matlab. \n'); |
171 |
system(['latex ' fileTex]); |
fprintf('The beamer class is required by in particular. In Matlab, if prompted \n'); |
172 |
system(['latex ' fileTex]); |
fprintf(' with a question mark then typing ''quit'' will abort compilation. \n'); |
173 |
system(['dvipdf ' fileTex]); |
test0=input('\n type 1 to proceed or 0 to skip this attempt\n'); |
174 |
cd(dirOrig); |
if test0; |
175 |
|
dirOrig=pwd; |
176 |
|
[PATHSTR,fileTex,EXT] = fileparts(myFile); |
177 |
|
cd(PATHSTR); |
178 |
|
system(['latex ' fileTex]); |
179 |
|
system(['latex ' fileTex]); |
180 |
|
system(['dvipdf ' fileTex]); |
181 |
|
cd(dirOrig); |
182 |
|
end; |
183 |
end; |
end; |
184 |
|
|
185 |
|
|
196 |
else; |
else; |
197 |
fileTex=myFile(1:end-4); |
fileTex=myFile(1:end-4); |
198 |
end; |
end; |
199 |
delete([fileTex '.fig*']); |
delete([fileTex '_fig*']); |
200 |
delete([fileTex '.aux']); |
delete([fileTex '.aux']); |
201 |
delete([fileTex '.log']); |
delete([fileTex '.log']); |
202 |
delete([fileTex '.out']); |
delete([fileTex '.out']); |