📄 fm_laprint.m
字号:
global LAPRINTHAN
txt1=[ 'With this option set to ''on'', LaPrint adds ',...
'\caption{' LAPRINTOPT.commenttext ,...
'} and \label{fig:' LAPRINTOPT.filename '} entries ',...
'to the tex-file.'];
if LAPRINTOPT.caption==1
LAPRINTOPT.caption=0;
set(LAPRINTHAN.caption,'check','off')
txt2= 'Current setting is: off';
else
LAPRINTOPT.caption=1;
set(LAPRINTHAN.caption,'check','on')
txt2='Current setting is: on';
end
showtext({txt1, txt2});
case 'viewfile'
global LAPRINTOPT
global LAPRINTHAN
txt1=[ 'With this option set to ''on'', LaPrint creates an ',...
'additional file ' LAPRINTOPT.viewfilename ...
'.tex containing a LaTeX document ',...
'which calls the tex-file.'];
if LAPRINTOPT.viewfile==1
LAPRINTOPT.viewfile=0;
set(LAPRINTHAN.viewfile,'check','off')
txt2= 'Current setting is: off';
else
LAPRINTOPT.viewfile=1;
set(LAPRINTHAN.viewfile,'check','on')
txt2='Current setting is: on';
end
showtext({txt1, txt2});
case 'defaults'
global LAPRINTOPT
global LAPRINTHAN
LAPRINTOPT.asonscreen=0;
LAPRINTOPT.keepticklabels=0;
LAPRINTOPT.mathticklabels=0;
LAPRINTOPT.keepfontprops=0;
LAPRINTOPT.extrapicture=1;
LAPRINTOPT.loose=0;
LAPRINTOPT.nofigcopy=0;
LAPRINTOPT.nohead=0;
LAPRINTOPT.noscalefonts=0;
LAPRINTOPT.caption=0;
LAPRINTOPT.viewfile=0;
set(LAPRINTHAN.asonscreen,'check','off')
set(LAPRINTHAN.keepticklabels,'check','off')
set(LAPRINTHAN.mathticklabels,'check','off')
set(LAPRINTHAN.keepfontprops,'check','off')
set(LAPRINTHAN.extrapicture,'check','off')
set(LAPRINTHAN.loose,'check','off')
set(LAPRINTHAN.nofigcopy,'check','on')
set(LAPRINTHAN.nohead,'check','on')
set(LAPRINTHAN.noscalefonts,'check','on')
set(LAPRINTHAN.caption,'check','off')
set(LAPRINTHAN.viewfile,'check','off')
showtext({[ 'All options availabe through the menu bar '...
'are set to their default values.']});
case 'whois'
showtext({'To blame for LaPrint:',...
'Arno Linnemann','Control and Systems Theory',...
'Department of Electrical Engineering',...
'University of Kassel',...
'34109 Kassel | mailto:linnemann@uni-kassel.de'...
'Germany | http://www.uni-kassel.de/~linne/'})
%%% help %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case 'help'
global LAPRINTOPT
global LAPRINTHAN
txt0='...Press ''Help'' again to continue....';
if LAPRINTOPT.HELP==1
txt=[ 'LAPRINT prints a figure for inclusion in LaTeX documents. ',...
'It creates an eps-file and a tex-file. The tex-file contains the ',...
'annotation of the figure such as titles, labels and texts. The ',...
'eps-file contains the non-text part of the figure as well as the ',...
'position of the text-objects.'];
txt={txt,txt0};
elseif LAPRINTOPT.HELP==2
txt1= [ 'The packages epsfig and psfrag are ',...
'required for the LaTeX run. A postscript driver like dvips is ',...
'required for printing. ' ];
txt2=' ';
txt3= ['It is recommended to switch off the Matlab TeX ' ...
'interpreter before using LaPrint:'];
txt4= ' >> set(0,''DefaultTextInterpreter'',''none'')';
txt={txt1,txt2,txt3,txt4,txt0};
elseif LAPRINTOPT.HELP==3
txt1= [ 'EXAMPLE: Suppose you have created a MATLAB Figure.'];
txt2= [ 'Saving the figure with LaPrint (using default '...
'values everywhere), creates the two files unnamed.eps '...
'and unnamed.tex. The tex-file calls the eps-file '...
'and can be included into a LaTeX document as follows:'];
txt={txt1,txt2,txt0};
elseif LAPRINTOPT.HELP==4
txt1=' ..';
txt2=' \usepackage{epsfig,psfrag}';
txt3=' ..';
txt4=' \input{unnamed}';
txt5=' ..';
txt={txt1,txt2,txt3,txt4,txt5,txt0};
elseif LAPRINTOPT.HELP==5
txt1=[ 'This will create a figure of width 12cm in the LaTeX '...
'document. Its texts (labels,title, etc) are set in '...
'LaTeX and have 80% of the font size of the '...
'surrounding text.'];
txt={txt1,txt0};
elseif LAPRINTOPT.HELP==6
txt1=[ 'The LaTeX figure width, the scaling factor and the '...
'file names can be adjusted using '...
'this interface window.'];
txt2=[ 'More options are available through the menu bar above. '...
'Associated help is displayed as you change the options.'];
txt={txt1,txt2,txt0};
elseif LAPRINTOPT.HELP==7
txt1=[ 'The document ''MATLAB graphics in LaTeX documents: '...
'Some tips and a tool'' contains more help on LaPrint '...
'and various examples. It can be obtained along '...
'with the most recent version of LaPrint from '...
'http://www.uni-kassel.de/~linne/matlab/.'];
txt2=[ 'Please report bugs, suggestions '...
'and comments to linnemann@uni-kassel.de.'];
txt={txt1,txt2,txt0};
else
txt={'Have fun!'};
LAPRINTOPT.HELP=0;
end
LAPRINTOPT.HELP=LAPRINTOPT.HELP+1;
showtext(txt);
%%% quit %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case 'quit'
LAPRINTHAN=[];
LAPRINTOPT=[];
delete(Fig.laprint)
Fig.laprint = 0;
%%% Advanced Help %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case 'advancedhelp'
disp(' ')
disp('Advanced usage: fm_laprint(figno,filename,opt1,opt2,..)')
disp('where ')
disp(' figno : integer, figure to be printed')
disp(' filename : string, basename of files to be created')
disp(' opt1,.. : strings, describing optional inputs as follows')
disp('')
disp(' ''width=xx'' : xx is the width of the figure in the tex')
disp(' file (in cm).')
disp(' ''factor=xx'' : xx is the factor by which the figure in ')
disp(' the LaTeX document is smaller than the figure')
disp(' in the postscript file.')
disp(' A non-positive number for xx lets the factor')
disp(' be computed such that the figure in the')
disp(' postscript file has the same size as the')
disp(' figure on screen.')
disp(' ''asonscreen'' : prints a graphics ''as on screen'',')
disp(' retaining ticks, ticklabels and lims.')
disp(' ''verbose'' : verbose mode; asks before overwriting')
disp(' files and issues some more messages.')
disp(' ''keepticklabels'': keeps the tick labels within the eps-file')
disp(' ''mathticklabels'': tick labels are set in LaTeX math mode')
disp(' ''keepfontprops'' : tries to translate the MATLAB font')
disp(' properties (size, width, angle) into')
disp(' similar LaTeX font properties.')
disp(' ''noscalefonts'' : does not scale the fonts with the figure.')
disp(' ''noextrapicture'': does not add extra picture environments.')
disp(' ''loose'' : uses ''-loose'' in the Matlab print command.')
disp(' ''nofigcopy'' : directly modifies the figure figno.')
disp(' ''nohead'' : does not place a commenting head in ')
disp(' the tex-file. ')
disp(' ''caption=xx'' : adds \caption{xx} and \label{fig:filename}')
disp(' entries to the tex-file.')
disp(' ''comment=xx'' : places the comment xx into the header')
disp(' of the tex-file')
disp(' ''viewfile=xx'' : creates an additional file xx.tex')
disp(' containing a LaTeX document which calls')
disp(' the tex-file.')
disp(' ')
%%% save %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case 'save'
global LAPRINTOPT
global LAPRINTHAN
global Fig
psatfigs = fieldnames(Fig);
for hhh = 1:length(psatfigs)
psatfigno = getfield(Fig,psatfigs{hhh});
if psatfigno == LAPRINTOPT.figno
fm_choice('Exporting PSAT GUIs using LaPrint is not allowed.',2)
return
end
end
lapcmd = [ 'fm_laprint(' int2str(LAPRINTOPT.figno) ...
', ''' LAPRINTOPT.filename ''''...
', ''width=' num2str(LAPRINTOPT.width) '''' ...
', ''factor=' num2str(LAPRINTOPT.factor) '''' ];
if LAPRINTOPT.verbose
lapcmd = [ lapcmd ,', ''verbose''' ];
end
if LAPRINTOPT.asonscreen
lapcmd = [ lapcmd ,', ''asonscreen''' ];
end
if LAPRINTOPT.keepticklabels
lapcmd = [ lapcmd ,', ''keepticklabels''' ];
end
if LAPRINTOPT.mathticklabels
lapcmd = [ lapcmd ,', ''mathticklabels''' ];
end
if LAPRINTOPT.keepfontprops
lapcmd = [ lapcmd ,', ''keepfontprops''' ];
end
if ~LAPRINTOPT.extrapicture
lapcmd = [ lapcmd ,', ''noextrapicture''' ];
end
if LAPRINTOPT.loose
lapcmd = [ lapcmd ,', ''loose''' ];
end
if LAPRINTOPT.nofigcopy
lapcmd = [ lapcmd ,', ''nofigcopy''' ];
end
if LAPRINTOPT.nohead
lapcmd = [ lapcmd ,', ''nohead''' ];
end
if LAPRINTOPT.noscalefonts
lapcmd = [ lapcmd ,', ''noscalefonts''' ];
end
if LAPRINTOPT.caption
lapcmd = [ lapcmd ,', ''caption=' LAPRINTOPT.commenttext '''' ];
end
if length(LAPRINTOPT.commenttext)
lapcmd = [ lapcmd ,', ''comment=' LAPRINTOPT.commenttext '''' ];
end
if LAPRINTOPT.viewfile
lapcmd = [ lapcmd ,', ''viewfile=' LAPRINTOPT.viewfilename '''' ];
end
lapcmd = [ lapcmd ')'];
showtext({'Saving using:', lapcmd });
eval(lapcmd)
otherwise
fm_disp('LaPrint Error: unknown callback option!',2)
end
return
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%
%%%% PART 1 of advanced usage:
%%%% Check inputs and initialize
%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% called directly or via gui?
directcall=1;
iswarning=0;
if exist('LAPRINTHAN','var')
if ~isempty(LAPRINTHAN)
directcall=0;
end
end
if nargin==1
if ~isa(figno,'char')
filename='unnamed';
else
filename=figno;
figno=gcf;
end
end
if ~isa(figno,'double')
fm_disp(['LaPrint Error: "',num2str(figno),'" is not a figure handle.'],2)
return
end
if ~any(get(0,'children')==figno)
fm_disp(['LaPrint Error: "',num2str(figno),'" is not a figure handle.'],2)
return
end
if ~isa(filename,'char')
filename
fm_disp(['La Print Error: file name is not valid.'],2)
return
end
% default values
furtheroptions='';
verbose=0;
asonscreen=0;
keepticklabels=0;
mathticklabels=0;
keepfontprops=0;
extrapicture=1;
loose=0;
nofigcopy=0;
nohead=0;
noscalefonts=0;
caption=0;
commenttext='';
captiontext='';
width=12;
factor=0.8;
viewfile=0;
% read and check options
if nargin>2
for i=1:nargin-2
if ~isa(varargin{i},'char')
fm_disp('LaPrint Error: Options must be character arrays.',2)
return
end
oriopt=varargin{i}(:)';
opt=[ lower(strrep(oriopt,' ','')) ' ' ];
if strcmp(opt(1:7),'verbose')
verbose=1;
furtheroptions=[ furtheroptions ' / ' deblank(opt) ];
elseif strcmp(opt(1:10),'asonscreen')
asonscreen=1;
furtheroptions=[furtheroptions ' / ' deblank(opt) ];
elseif strcmp(opt(1:14),'keepticklabels')
keepticklabels=1;
furtheroptions=[furtheroptions ' / ' deblank(opt) ];
elseif strcmp(opt(1:14),'mathticklabels')
mathticklabels=1;
furtheroptions=[furtheroptions ' / ' deblank(opt) ];
elseif strcmp(opt(1:13),'keepfontprops')
keepfontprops=1;
furtheroptions=[furtheroptions ' / ' deblank(opt) ];
elseif strcmp(opt(1:14),'noextrapicture')
extrapicture=0;
furtheroptions=[furtheroptions ' / ' deblank(opt) ];
elseif strcmp(opt(1:5),'loose')
loose=1;
furtheroptions=[furtheroptions ' / ' deblank(opt) ];
elseif strcmp(opt(1:9),'nofigcopy')
nofigcopy=1;
furtheroptions=[furtheroptions ' / ' deblank(opt) ];
elseif strcmp(opt(1:12),'noscalefonts')
noscalefonts=1;
furtheroptions=[furtheroptions ' / ' deblank(opt) ];
elseif strcmp(opt(1:6),'nohead')
nohead=1;
furtheroptions=[furtheroptions ' / ' deblank(opt) ];
elseif strcmp(opt(1:7),'caption')
caption=1;
eqpos=findstr(oriopt,'=');
if isempty(eqpos)
furtheroptions=[furtheroptions ' / ' deblank(opt) ];
captiontext=[];
else
furtheroptions=[furtheroptions ' / ' oriopt ];
captiontext=oriopt(eqpos+1:length(oriopt));
end
elseif strcmp(opt(1:8),'comment=')
eqpos=findstr(oriopt,'=');
furtheroptions=[furtheroptions ' / ' oriopt ];
commenttext=oriopt(eqpos(1)+1:length(oriopt));
elseif strcmp(opt(1:9),'viewfile=')
viewfile=1;
eqpos=findstr(oriopt,'=');
furtheroptions=[furtheroptions ' / ' oriopt ];
viewfilename=oriopt(eqpos(1)+1:length(oriopt));
elseif strcmp(opt(1:6),'width=')
eval([ opt ';' ]);
elseif strcmp(opt(1:7),'factor=')
eval([ opt ';' ]);
else
fm_disp(['LaPrint Error: Option ' varargin{i} ' not recognized.'],2)
return
end
end
end
furtheroptions=strrep(strrep(furtheroptions,'\','\\'),'%','%%');
captiontext=strrep(strrep(captiontext,'\','\\'),'%','%%');
commenttext=strrep(strrep(commenttext,'\','\\'),'%','%%');
if verbose,
fm_disp(['This is LaPrint, version ',laprintident,'.']);
end
if mathticklabels
Do='$';
else
Do='';
end
% eps- and tex- filenames
[epsfullnameext,epsbasenameext,epsbasename,epsdirname]= ...
getfilenames(filename,'eps',verbose);
[texfullnameext,texbasenameext,texbasename,texdirname]= ...
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -