⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fm_laprint.m

📁 这是一个很适合研究和学习用的电力系统仿真软件
💻 M
📖 第 1 页 / 共 5 页
字号:
function fm_laprint(figno,filename,varargin)
%FM_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. The packages 'epsfig' and 'psfrag' are 
%  required for the LaTeX run. A postscript driver like 'dvips' is 
%  required for printing. 
%
%  Usage:   fm_laprint
%
%  This opens a graphical user interface window, to control the
%  various options. It is self-explainatory. Just try it.
%
%  Example: Suppose you have created a MATLAB Figure. 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: 
%       .. \usepackage{epsfig,psfrag} ..
%       .. \input{unnamed} ..
%  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. Figure widths, text font
%  sizes, file names and various other issues can be freely 
%  adjusted using the interface window.
%
%  Alternatively, you can control the behaviour of LaPrint using various 
%  extra input arguments. This is recommended for advanced users only.
%  Help on advanced usage is obtained by typing fm_laprint({'AdvancedHelp'}).
%
%  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/.

%  known problems and limitations, things to do, ...
%  --  The matlab functions copyobj and plotedit have bugs. 
%      If this is a problem, use option 'nofigcopy'.
%  --  multi-line text is not supported
%  --  cm is the only unit used (inches not supported)
%  --  a small preview would be nice

%  (c) Arno Linnemann.   All rights reserved. 
%  The author of this program assumes no responsibility for any  errors 
%  or omissions. In no event shall he be liable for damages  arising out of 
%  any use of the software. Redistribution of the unchanged file is allowed.
%  Distribution of changed versions is allowed provided the file is renamed
%  and the source and authorship of the original version is acknowledged in 
%  the modified file.

%  Please report bugs, suggestions and comments to:
%  Arno Linnemann
%  Control and Systems Theory
%  Department of Electrical Engineering 
%  University of Kassel
%  34109 Kassel
%  Germany
%  mailto:linnemann@uni-kassel.de
%  http://www.uni-kassel.de/~linne/

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%
%%%% Initialize
%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

global LAPRINTOPT
global LAPRINTHAN
global Theme Fig

laprintident = '2.03 (19.1.2000)'; 
vers=version;
vers=eval(vers(1:3));
if vers < 5.0
  fm_disp('LaPrint Error: Matlab 5.0 or above is required.',2)
  return
end

% no output
if nargout
  fm_disp('La Print Error: No output argument is required.',2)
  return
end  

if nargin==0

  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %%%%
  %%%% GUI
  %%%%
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  
  if Fig.laprint, return, end
  
  %---------------------------------
  % default values
  %---------------------------------
  
  LAPRINTOPT.figno=gcf;
  LAPRINTOPT.filename='unnamed';
  LAPRINTOPT.verbose=0;
  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.commenttext=['Figure No. ' int2str(LAPRINTOPT.figno)];
  LAPRINTOPT.width=12;
  LAPRINTOPT.factor=0.8;
  LAPRINTOPT.viewfile=0;
  LAPRINTOPT.viewfilename='unnamed_';
  
  LAPRINTOPT.HELP=1;
  
  %---------------------------------
  % open window
  %---------------------------------
  
  hf = figure;
  Fig.laprint = hf;
  clf reset;
  set(hf,'NumberTitle','off')
  %set(hf,'CreateFcn','Fig.laprint = hf;')
  set(hf,'FileName','fm_laprint')
  set(hf,'DeleteFcn','fm_laprint({''quit''})')
  set(hf,'MenuBar','none')
  set(hf,'Color',Theme.color01)
  set(hf,'Name','LaPrint (LaTeX Print)')
  set(hf,'Units','points')
  set(hf,'Resize','off')
  h=uicontrol(hf);
  set(h,'Units','points')
  fsize=get(h,'Fontsize');
  delete(h)
  posf=get(hf,'Position');
  figheight=30*fsize;
  posf= [ posf(1)   posf(2)+posf(4)-figheight ...
          31*fsize  figheight];
  set(hf,'Position',posf)
  curh=figheight-0*fsize;
  
  %---------------------------------
  % LaTeX logo
  %---------------------------------
  
  h1 = axes('Parent',hf, ...
            'Units','points', ...
            'Box','on', ...
            'CameraUpVector',[0 1 0], ...
            'CameraUpVectorMode','manual', ...
            'Color',Theme.color04, ...
            'HandleVisibility','on', ...
            'HitTest','off', ...
            'Layer','top', ...
            'Position',[23*fsize 20.5*fsize 7*fsize 7*fsize], ...
            'Tag','Axes1', ...
            'XColor',Theme.color03, ...
            'XLim',[0.5 128.5], ...
            'XLimMode','manual', ...
            'XTickLabelMode','manual', ...
            'XTickMode','manual', ...
            'YColor',Theme.color03, ...
            'YDir','reverse', ...
            'YLim',[0.5 128.5], ...
            'YLimMode','manual', ...
            'YTickLabelMode','manual', ...
            'YTickMode','manual', ...
            'ZColor',[0 0 0]);
  h2 = image('Parent',h1, ...
             'CData',fm_mat('misc_laprint'), ...
             'Tag','Axes1Image1', ...
             'XData',[1 128], ...
             'YData',[1 128]);

  %---------------------------------
  % figure no.
  %---------------------------------

  loch=1.7*fsize;
  curh=curh-loch-1*fsize;
  h = uicontrol;
  set(h,'Parent',hf)
  set(h,'BackgroundColor',Theme.color01)
  set(h,'style','text')
  set(h,'Units','points')
  set(h,'Position',[1*fsize curh 8*fsize loch])
  set(h,'HorizontalAlignment','left')
  set(h,'string','Figure No.:')

  h = uicontrol;
  set(h,'Parent',hf)
  set(h,'Parent',hf)
  set(h,'style','edit')
  set(h,'FontName',Theme.font01)
  set(h,'BackgroundColor',Theme.color04)
  set(h,'ForegroundColor',Theme.color05)
  set(h,'Units','points')
  set(h,'Position',[10*fsize curh 3*fsize loch])
  set(h,'HorizontalAlignment','left')
  set(h,'String',int2str(LAPRINTOPT.figno))
  set(h,'Callback','fm_laprint({''figno''});')
  LAPRINTHAN.figno=h;

  %---------------------------------
  % filename
  %---------------------------------

  loch=1.7*fsize;
  curh=curh-loch;
  h = uicontrol;
  set(h,'Parent',hf)
  set(h,'style','text')
  set(h,'BackgroundColor',Theme.color01)
  set(h,'Units','points')
  set(h,'Position',[1*fsize curh 8*fsize loch])
  set(h,'HorizontalAlignment','left')
  set(h,'string','filename (base):')

  h = uicontrol;
  set(h,'Parent',hf)
  set(h,'Parent',hf)
  set(h,'style','edit')
  set(h,'FontName',Theme.font01)
  set(h,'BackgroundColor',Theme.color04)
  set(h,'ForegroundColor',Theme.color05)
  set(h,'Units','points')
  set(h,'Position',[10*fsize curh 12*fsize loch])
  set(h,'HorizontalAlignment','left')
  set(h,'String',LAPRINTOPT.filename)
  set(h,'Callback','fm_laprint({''filename''});')
  LAPRINTHAN.filename=h;

  %---------------------------------
  % width
  %---------------------------------

  loch=1.7*fsize;
  curh=curh-loch-1*fsize;
  h = uicontrol;
  set(h,'Parent',hf)
  set(h,'style','text')
  set(h,'BackgroundColor',Theme.color01)
  set(h,'Units','points')
  set(h,'Position',[1*fsize curh 17*fsize loch])
  set(h,'HorizontalAlignment','left')
  set(h,'string','Width in LaTeX document [cm]:')

  h = uicontrol;
  set(h,'Parent',hf)
  set(h,'Parent',hf)
  set(h,'style','edit')
  set(h,'FontName',Theme.font01)
  set(h,'BackgroundColor',Theme.color04)
  set(h,'ForegroundColor',Theme.color05)
  set(h,'Units','points')
  set(h,'Position',[19*fsize curh 3*fsize loch])
  set(h,'HorizontalAlignment','left')
  set(h,'String',num2str(LAPRINTOPT.width))
  set(h,'Callback','fm_laprint({''width''});')
  LAPRINTHAN.width=h;

  %---------------------------------
  % factor
  %---------------------------------

  loch=1.7*fsize;
  curh=curh-loch;
  h = uicontrol;
  set(h,'Parent',hf)
  set(h,'style','text')
  set(h,'BackgroundColor',Theme.color01)
  set(h,'Units','points')
  set(h,'Position',[1*fsize curh 17*fsize loch])
  set(h,'HorizontalAlignment','left')
  set(h,'string','Factor to scale fonts and eps figure:')

  h = uicontrol;
  set(h,'Parent',hf)
  set(h,'Parent',hf)
  set(h,'style','edit')
  set(h,'FontName',Theme.font01)
  set(h,'BackgroundColor',Theme.color04)
  set(h,'ForegroundColor',Theme.color05)
  set(h,'Units','points')
  set(h,'Position',[19*fsize curh 3*fsize loch])
  set(h,'HorizontalAlignment','left')
  set(h,'String',num2str(LAPRINTOPT.factor))
  set(h,'Callback','fm_laprint({''factor''});')
  LAPRINTHAN.factor=h;

  %---------------------------------
  % show sizes
  %---------------------------------

  loch=1.7*fsize;
  curh=curh-loch;
  h = uicontrol;
  set(h,'Parent',hf)
  set(h,'style','text')
  set(h,'BackgroundColor',Theme.color01)
  set(h,'Units','points')
  set(h,'Position',[1*fsize curh 22*fsize loch])
  set(h,'HorizontalAlignment','left')
  set(h,'string',[ 'latex figure size: ' ])
  LAPRINTHAN.texsize=h;

  loch=1.7*fsize;
  curh=curh-loch;
  h = uicontrol;
  set(h,'Parent',hf)
  set(h,'style','text')
  set(h,'BackgroundColor',Theme.color01)
  set(h,'Units','points')
  set(h,'Position',[1*fsize curh 22*fsize loch])
  set(h,'HorizontalAlignment','left')
  set(h,'string',[ 'postscript figure size: ' ])
  LAPRINTHAN.epssize=h;

  %---------------------------------
  % comment/caption text
  %---------------------------------
  loch=1.7*fsize;
  curh=curh-loch-fsize;
  h = uicontrol;
  set(h,'Parent',hf)
  set(h,'style','text')
  set(h,'BackgroundColor',Theme.color01)
  set(h,'Units','points')
  set(h,'Position',[1*fsize curh 12*fsize loch])
  set(h,'HorizontalAlignment','left')
  set(h,'string','Comment/Caption text:')

  h = uicontrol;
  set(h,'Parent',hf)
  set(h,'style','edit')
  set(h,'FontName',Theme.font01)
  set(h,'BackgroundColor',Theme.color04)
  set(h,'ForegroundColor',Theme.color05)
  set(h,'Units','points')
  set(h,'Position',[14*fsize curh 16*fsize loch])
  set(h,'HorizontalAlignment','left')
  set(h,'String',LAPRINTOPT.commenttext)
  set(h,'Callback','fm_laprint({''commenttext''});')
  LAPRINTHAN.commenttext=h;

  %---------------------------------
  % text
  %---------------------------------

  loch=10*fsize;
  curh=curh-loch-fsize;
  h = uicontrol;
  set(h,'Parent',hf)
  set(h,'style','text')
  set(h,'FontName',Theme.font01)
  set(h,'BackgroundColor',Theme.color04)
  set(h,'ForegroundColor',Theme.color05)
  set(h,'Units','points')
  set(h,'Position',[1*fsize curh 29*fsize loch])
  set(h,'HorizontalAlignment','left')
  %set(h,'BackgroundColor',[1 1 1])
  LAPRINTHAN.helptext=h;
  if (isempty(get(LAPRINTOPT.figno,'children')))
    txt=['Warning: Figure ' int2str(LAPRINTOPT.figno) ... 
         ' is empty. There is nothing to do yet.' ];
  else
    txt='';
  end  
  showtext({['This is LaPrint, Version ', laprintident, ...
             ', by Arno Linnemann. ', ...
             'The present version was slightly modified by ', ...
             'Federico Milano (17.12.2003) and can be used only from within ', ...
             'PSAT. To get started, press ''Help'' below.', txt]})
  showsizes;
  %---------------------------------
  % save, quit, help
  %---------------------------------

  loch=2*fsize;
  curh=curh-loch-fsize;
  h=uicontrol;
  set(h,'Parent',hf)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -