📄 fm_laprint.m
字号:
% font angle
afangle=cell(na,1);
for i=1:na
afangle{i}=get(hax(i),'fontangle');
end
if strcmp(afangle{1},'normal')
afanglecmd=[ '\\fontshape{n}' ];
elseif strcmp(afangle{1},'italic')
afanglecmd=[ '\\fontshape{it}' ];
elseif strcmp(afangle{1},'oblique')
afanglecmd=[ '\\fontshape{it}' ];
else
disp([ ' LaPrint warning: unknown fontangle:' afangle{1} ])
iswarning=1;
afanglecmd=[ '\\fontshape{n}' ];
end
for i=1:na
if ~strcmp(afangle{i},afangle{1})
disp('LaPrint warning: Different font angles for axes not supported.')
disp([ ' All axes will have font angle ' afanglecmd ] )
iswarning=1;
end
end
end
end
%
% extra picture environment
%
if extrapicture
unitlength=zeros(na,1);
ybound=zeros(na,1);
for i=1:na
if ~is3d(hax(i))
xlim=get(hax(i),'xlim');
ylim=get(hax(i),'ylim');
axes(hax(i));
hori=text(ylim(1),ylim(1),[ 'origin' int2str(i) ]);
set(hori,'VerticalAlignment','bottom');
set(hori,'Fontsize',2);
pos=get(hax(i),'Position');
unitlength(i)=pos(3)*epswidth;
ybound(i)=(pos(4)*epsheight)/(pos(3)*epswidth);
else
if directcall
disp('LaPrint warning: Option ''extrapicture'' for 3D axes not supported.')
end
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%
%%%% PART 3 of advanced usage:
%%%% save eps and tex files
%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% save eps file
%
if ~loose
cmd=[ 'print(''-deps'',''-f' int2str(figno) ''',''' epsfullnameext ''')' ];
else
cmd=[ 'print(''-deps'',''-loose'',''-f' int2str(figno) ...
''',''' epsfullnameext ''')' ];
end
if verbose
disp([ 'executing: '' ' cmd ' ''' ]);
end
eval(cmd);
%
% create latex file
%
if verbose
disp([ 'writing to: '' ' texfullnameext ' ''' ])
end
fid=fopen(texfullnameext,'w');
% head
if ~nohead
fprintf(fid,[ '%% This file is generated by the MATLAB m-file fm_laprint.m.' ...
' It can be included\n']);
fprintf(fid,[ '%% into LaTeX documents using the packages epsfig and ' ...
'psfrag. It is accompanied\n' ]);
fprintf(fid, '%% by a postscript file. A sample LaTeX file is:\n');
fprintf(fid, '%% \\documentclass{article} \\usepackage{epsfig,psfrag}\n');
fprintf(fid,[ '%% \\begin{document}\\begin{figure}\\input{' ...
texbasename '}\\end{figure}\\end{document}\n' ]);
fprintf(fid, [ '%% See http://www.uni-kassel.de/~linne/ for recent ' ...
'versions of fm_laprint.m.\n' ]);
fprintf(fid, '%%\n');
fprintf(fid,[ '%% created by: ' 'LaPrint version ' ...
laprintident '\n' ]);
fprintf(fid,[ '%% created on: ' datestr(now) '\n' ]);
fprintf(fid,[ '%% options used: ' furtheroptions '\n' ]);
fprintf(fid,[ '%% latex width: ' num2str(latexwidth) ' cm\n' ]);
fprintf(fid,[ '%% factor: ' num2str(factor) '\n' ]);
fprintf(fid,[ '%% eps file name: ' epsbasenameext '\n' ]);
fprintf(fid,[ '%% eps bounding box: ' num2str(epswidth) ...
' cm x ' num2str(epsheight) ' cm\n' ]);
fprintf(fid,[ '%% comment: ' commenttext '\n' ]);
fprintf(fid,'%%\n');
else
fprintf(fid,[ '%% generated by fm_laprint.m\n' ]);
fprintf(fid,'%%\n');
end
% go on
fprintf(fid,'\\begin{psfrags}%%\n');
%fprintf(fid,'\\fontsize{10}{12}\\selectfont%%\n');
fprintf(fid,'\\psfragscanon%%\n');
% text strings
numbertext=0;
for i=1:nt
numbertext=numbertext+length(newstr{i});
end
if numbertext>0,
fprintf(fid,'%%\n');
fprintf(fid,'%% text strings:\n');
for i=1:nt
if length(newstr{i})
alig=strrep(align{i},'c','');
fprintf(fid,[ '\\psfrag{' newstr{i} '}[' alig '][' alig ']{' ...
fontsizecmd{i} fontweightcmd{i} fontanglecmd{i} selectfontcmd ...
oldstr{i} '}%%\n' ]);
end
end
end
% labels
if ~keepticklabels
if keepfontprops
fprintf(fid,'%%\n');
fprintf(fid,'%% axes font properties:\n');
fprintf(fid,[ afsizecmd afweightcmd '%%\n' ]);
fprintf(fid,[ afanglecmd '\\selectfont%%\n' ]);
end
nxlabel=zeros(1,na);
nylabel=zeros(1,na);
nzlabel=zeros(1,na);
for i=1:na
nxlabel(i)=length(newxtl{i});
nylabel(i)=length(newytl{i});
nzlabel(i)=length(newztl{i});
end
allxyz={ 'x', 'y', 'z' };
for ixyz=1:3
xyz=allxyz{ixyz};
eval([ 'oldtl=old' xyz 'tl;' ]);
eval([ 'newtl=new' xyz 'tl;' ]);
eval([ 'nlabel=n' xyz 'label;' ]);
if sum(nlabel) > 0
fprintf(fid,'%%\n');
fprintf(fid,[ '%% ' xyz 'ticklabels:\n']);
if xyz=='x'
poss='[t][t]';
else
poss='[r][r]';
end
for i=1:na
if nlabel(i)
if strcmp(get(hax(i),[ xyz 'scale']),'linear')
% lin scale
% all but last
for j=1:nlabel(i)-1
fprintf(fid,[ '\\psfrag{' newtl{i}{j} '}' poss '{' ...
Do oldtl{i}{j} Do '}%%\n' ]);
end
% last
rexpon=powers(i,ixyz);
if rexpon
if xyz=='x'
fprintf(fid,[ '\\psfrag{' newtl{i}{nlabel(i)} ...
'}' poss '{\\shortstack{' ...
Do oldtl{i}{nlabel(i)} Do '\\\\$\\times 10^{'...
int2str(rexpon) '}\\ $}}%%\n' ]);
else
fprintf(fid,[ '\\psfrag{' newtl{i}{nlabel(i)} ...
'}' poss '{' Do oldtl{i}{nlabel(i)} Do ...
'\\setlength{\\unitlength}{1ex}%%\n' ...
'\\begin{picture}(0,0)\\put(0.5,1.5){$\\times 10^{' ...
int2str(rexpon) '}$}\\end{picture}}%%\n' ]);
end
else
fprintf(fid,[ '\\psfrag{' newtl{i}{nlabel(i)} '}' poss '{' ...
Do oldtl{i}{nlabel(i)} Do '}%%\n' ]);
end
else
% log scale
for j=1:nlabel
fprintf(fid,[ '\\psfrag{' newtl{i}{j} '}' poss '{$10^{' ...
oldtl{i}{j} '}$}%%\n' ]);
end
end
end
end
end
end
end
% extra picture
if extrapicture
fprintf(fid,'%%\n');
fprintf(fid,'%% extra picture(s):\n');
for i=1:na
fprintf(fid,[ '\\psfrag{origin' int2str(i) '}[lb][lb]{' ...
'\\setlength{\\unitlength}{' ...
num2str(unitlength(i),'%5.5f') 'cm}%%\n' ]);
fprintf(fid,[ '\\begin{picture}(1,' ...
num2str(ybound(i),'%5.5f') ')%%\n' ]);
%fprintf(fid,'\\put(0,0){}%% lower left corner\n');
%fprintf(fid,[ '\\put(1,' num2str(ybound(i),'%5.5f') ...
% '){}%% upper right corner\n' ]);
fprintf(fid,'\\end{picture}%%\n');
fprintf(fid,'}%%\n');
end
end
% figure
fprintf(fid,'%%\n');
fprintf(fid,'%% Figure:\n');
if caption
fprintf(fid,[ '\\parbox{' num2str(latexwidth) 'cm}{\\centering%%\n' ]);
end
if noscalefonts
fprintf(fid,[ '\\epsfig{file=' epsbasenameext ',width=' ...
num2str(latexwidth) 'cm}}%%\n' ]);
else
fprintf(fid,[ '\\resizebox{' num2str(latexwidth) 'cm}{!}' ...
'{\\epsfig{file=' epsbasenameext '}}%%\n' ]);
end
if caption
if isempty(captiontext)
captiontext=[ texbasenameext ', ' epsbasenameext ];
end
fprintf(fid,[ '\\caption{' captiontext '}%%\n' ]);
fprintf(fid,[ '\\label{fig:' texbasename '}%%\n' ]);
fprintf(fid,[ '}%%\n' ]);
end
fprintf(fid,'\\end{psfrags}%%\n');
fprintf(fid,'%%\n');
fprintf(fid,[ '%% End ' texbasenameext '\n' ]);
fclose(fid);
set(figno,'Name','Printed by LaPrint')
if ~nofigcopy
if verbose
disp('Strike any key to continue.');
pause
end
close(figno)
end
%
% create view file
%
if viewfile
if verbose
disp([ 'writing to: '' ' viewfullnameext ' ''' ])
end
fid=fopen(viewfullnameext,'w');
if ~nohead
fprintf(fid,[ '%% This file is generated by fm_laprint.m.\n' ]);
fprintf(fid,[ '%% It calls ' texbasenameext ...
', which in turn calls ' epsbasenameext '.\n' ]);
fprintf(fid,[ '%% Process this file using\n' ]);
fprintf(fid,[ '%% latex ' viewbasenameext '\n' ]);
fprintf(fid,[ '%% dvips -o' viewbasename '.ps ' viewbasename '.dvi' ...
'\n']);
fprintf(fid,[ '%% ghostview ' viewbasename '.ps&\n' ]);
else
fprintf(fid,[ '%% generated by fm_laprint.m\n' ]);
end
fprintf(fid,[ '\\documentclass{article}\n' ]);
fprintf(fid,[ '\\usepackage{epsfig,psfrag,a4}\n' ]);
fprintf(fid,[ '\\usepackage[latin1]{inputenc}\n' ]);
if ~strcmp(epsdirname,viewdirname)
%disp([ 'warning: The view-file has to be supplemented by '...
% 'path information.' ])
fprintf(fid,[ '\\graphicspath{{' epsdirname '}}\n' ]);
end
fprintf(fid,[ '\\begin{document}\n' ]);
fprintf(fid,[ '\\pagestyle{empty}\n' ]);
fprintf(fid,[ '\\begin{figure}[ht]\n' ]);
fprintf(fid,[ ' \\begin{center}\n' ]);
if strcmp(texdirname,viewdirname)
%fprintf(fid,[ ' \\fbox{\\input{' texbasenameext '}}\n' ]);
fprintf(fid,[ ' \\input{' texbasenameext '}\n' ]);
else
%fprintf(fid,[ ' \\fbox{\\input{' texdirname texbasenameext '}}\n' ]);
fprintf(fid,[ ' \\input{' texdirname texbasenameext '}\n' ]);
end
fprintf(fid,[ ' %% \\caption{A LaPrint figure}\n' ]);
fprintf(fid,[ ' %% \\label{fig:' texbasename '}\n' ]);
fprintf(fid,[ ' \\end{center}\n' ]);
fprintf(fid,[ '\\end{figure}\n' ]);
fprintf(fid,[ '\\vfill\n' ]);
fprintf(fid,[ '\\begin{flushright}\n' ]);
fprintf(fid,[ '\\tiny printed with LaPrint on ' ...
datestr(now) '\\\\\n' ]);
fprintf(fid,[ '\\verb+' viewdirname viewbasenameext '+\\\\\n' ]);
fprintf(fid,[ '\\verb+( ' texdirname texbasenameext ' )+\\\\\n' ]);
fprintf(fid,[ '\\verb+( ' epsdirname epsbasenameext ' )+\n' ]);
fprintf(fid,[ '\\end{flushright}\n' ]);
fprintf(fid,[ '\\end{document}\n' ]);
fclose(fid);
if verbose
yn=input([ 'Perform LaTeX run on ' viewbasenameext '? (y/n) '],'s');
if strcmp(yn,'y')
cmd=[ '!latex ' viewbasenameext ];
disp([ 'executing: '' ' cmd ' ''' ]);
eval(cmd);
yn=input([ 'Perform dvips run on ' viewbasename '.dvi? (y/n) '],'s');
if strcmp(yn,'y')
cmd=[ '!dvips -o' viewbasename '.ps ' viewbasename '.dvi' ];
disp([ 'executing: '' ' cmd ' ''' ]);
eval(cmd);
yn=input([ 'Call ghostview on ' viewbasename '.ps? (y/n) '],'s');
if strcmp(yn,'y')
cmd=[ '!ghostview ' viewbasename '.ps&' ];
disp([ 'executing: '' ' cmd ' ''' ]);
eval(cmd);
end
end
end
end
end
if ~directcall & iswarning
showtext({'Watch the LaPrint messages in the command window!'},'add')
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%
%%%% functions used
%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function showtext(txt,add)
global LAPRINTHAN
txt=textwrap(LAPRINTHAN.helptext,txt);
if nargin==1
set(LAPRINTHAN.helptext,'string','')
set(LAPRINTHAN.helptext,'string',txt)
else
txt0=get(LAPRINTHAN.helptext,'string');
set(LAPRINTHAN.helptext,'string','')
set(LAPRINTHAN.helptext,'string',{txt0{:},txt{:}})
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function showsizes()
global LAPRINTOPT
global LAPRINTHAN
figpos=get(LAPRINTOPT.figno,'position');
latexwidth=LAPRINTOPT.width;
latexheight=latexwidth*figpos(4)/figpos(3);
epswidth=latexwidth/LAPRINTOPT.factor;
epsheight=latexheight/LAPRINTOPT.factor;
set(LAPRINTHAN.texsize,'string',[ 'latex figure size: ' num2str(latexwidth) ...
'cm x ' num2str(latexheight) 'cm' ])
set(LAPRINTHAN.epssize,'string',[ 'postscript figure size: ' ...
num2str(epswidth) ...
'cm x ' num2str(epsheight) 'cm' ])
% some warnings
tx
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -