/trunk/MSc_Matlab_Code/Common/laprint.m

http://thesisyossim.googlecode.com/ · Objective C · 1765 lines · 1629 code · 136 blank · 0 comment · 201 complexity · 2e5d9a0af40cec14c4b71e04963c2f2e MD5 · raw file

Large files are truncated click here to view the full file

  1. function laprint(figno,filename,varargin)
  2. %LAPRINT prints a figure for inclusion in LaTeX documents.
  3. % LaPrint creates an eps-file and a tex-file. The tex-file contains
  4. % the annotation of the figure such as titles, labels and texts. The
  5. % eps-file contains the non-text part of the figure as well as the
  6. % position of the text-objects. The packages 'graphicx' (or 'epsfig')
  7. % and 'psfrag' (and possibly ''color'') are required for the LaTeX
  8. % run. A postscript driver like 'dvips' is required for printing.
  9. %
  10. % Usage: >> laprint
  11. %
  12. % This opens a graphical user interface window, to control the
  13. % various settings. It includes a help facility. Just try it.
  14. %
  15. % As an alternative to the GUI you can call laprint from the command
  16. % line with various extra input arguments. These arguments are
  17. % explained in the help window of the GUI, which can be also be
  18. % opened using the command
  19. % >> laprint helpwindow
  20. %
  21. % There is an Users Guide available at
  22. % http://www.uni-kassel.de/fb16/rat/matlab/laprint/laprintdoc.ps
  23. % (c) Arno Linnemann. All rights reserved.
  24. % The author of this program assumes no responsibility for any errors
  25. % or omissions. In no event shall he be liable for damages arising out of
  26. % any use of the software. Redistribution of the unchanged file is allowed.
  27. % Distribution of changed versions is allowed provided the file is renamed
  28. % and the source and authorship of the original version is acknowledged in
  29. % the modified file.
  30. % Please report bugs, suggestions and comments to:
  31. % Arno Linnemann
  32. % Control and Automation
  33. % Department of Electrical and Computer Engineering
  34. % University of Kassel
  35. % 34109 Kassel
  36. % Germany
  37. % mailto:linnemann@uni-kassel.de
  38. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  39. %%%%
  40. %%%% Initialize
  41. %%%%
  42. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  43. laprintident = '3.16 (13.9.2004)';
  44. vers = version;
  45. vers = eval(vers(1:3));
  46. if vers < 6.1
  47. error('Sorry. Matlab 6.1 or above is required.')
  48. end
  49. hf=131;
  50. hhf=132;
  51. % no output
  52. if nargout
  53. error('No output argument, please.')
  54. end
  55. inter=get(0,'defaulttextinterpreter');
  56. if ~strcmp(inter,'none')
  57. warning('LaPrint:general',['It is recommended to switch off the '...
  58. 'text interpreter\nbefore creating a figure to be saved '...
  59. 'with LaPrint. Use the command\n',...
  60. ' >> set(0,''defaulttextinterpreter'',''none'').'])
  61. end
  62. if nargin==0
  63. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  64. %%%%
  65. %%%% GUI
  66. %%%%
  67. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  68. try
  69. delete(hf)
  70. end
  71. try
  72. delete(hhf)
  73. end
  74. %---------------------------------
  75. % open window
  76. %---------------------------------
  77. hf = figure(hf);
  78. clf reset;
  79. set(hf,'NumberTitle','off',...
  80. 'Name','LaPrint (LaTeX Print)',...
  81. 'Units','points',...
  82. 'CloseRequestFcn','laprint(''quit'');',...
  83. 'menubar','none')
  84. h = uicontrol('Parent',hf,'Units','points');
  85. fsize = get(h,'Fontsize');
  86. delete(h)
  87. posf = get(hf,'Position');
  88. figheight = 10*fsize;
  89. figwidth = 32*fsize;
  90. posf = [ posf(1) posf(2)+posf(4)-figheight figwidth figheight];
  91. set(hf,'Position',posf)
  92. uicontrol('Parent',hf,'style','frame','Units','points',...
  93. 'Position',[0 0 figwidth figheight])
  94. curh = figheight-0*fsize;
  95. LAPRINTHAN=struct('figno',{0},'filename',{0},...
  96. 'keepfontprops',{0},'asonscreen',{0},'keepticklabels',{0},...
  97. 'mathticklabels',{0},'head',{0},'extrapicture',{0},...
  98. 'verbose',{0},'figcopy',{0},'package_epsfig',{0},...
  99. 'package_graphicx',{0},'color',{0},'createview',{0},...
  100. 'processview',{0});
  101. %---------------------------------
  102. % figure no.
  103. %---------------------------------
  104. loch = 1.7*fsize;
  105. curh = curh-loch-1.5*fsize;
  106. h = uicontrol('Parent',hf,...
  107. 'style','text',...
  108. 'Units','points',...
  109. 'Position',[1*fsize curh 18*fsize loch],...
  110. 'HorizontalAlignment','left',...
  111. 'string','Number of Figure to be saved:');
  112. h = uicontrol('Parent',hf,...
  113. 'style','edit',...
  114. 'Units','points',...
  115. 'Position',[19*fsize curh 12*fsize loch],...
  116. 'HorizontalAlignment','left',...
  117. 'BackgroundColor',[1 1 1],...
  118. 'Callback','laprint(''figno'');');
  119. LAPRINTHAN.figno = h;
  120. %---------------------------------
  121. % filename
  122. %---------------------------------
  123. loch = 1.7*fsize;
  124. curh = curh-loch-1*fsize;
  125. h = uicontrol('Parent',hf,...
  126. 'style','text',...
  127. 'Units','points',...
  128. 'Position',[1*fsize curh 18*fsize loch],...
  129. 'HorizontalAlignment','left',...
  130. 'string','Basename of Files to be Created:');
  131. h = uicontrol('Parent',hf,...
  132. 'style','edit',...
  133. 'Units','points',...
  134. 'Position',[19*fsize curh 12*fsize loch],...
  135. 'HorizontalAlignment','left',...
  136. 'BackgroundColor',[1 1 1],...
  137. 'Callback','laprint(''filename'');');
  138. LAPRINTHAN.filename = h;
  139. %---------------------------------
  140. % save, quit
  141. %---------------------------------
  142. loch = 2*fsize;
  143. curh = curh-loch-1*fsize;
  144. h = uicontrol('Parent',hf,...
  145. 'Style','pushbutton',...
  146. 'Units','Points',...
  147. 'Position',[19*fsize curh 5*fsize loch],...
  148. 'HorizontalAlignment','center',...
  149. 'String','Go !',...
  150. 'Callback','laprint(''save'');');
  151. h = uicontrol('Parent',hf,...
  152. 'Style','pushbutton',...
  153. 'Units','Points',...
  154. 'Position',[26*fsize curh 5*fsize loch],...
  155. 'HorizontalAlignment','center',...
  156. 'String','Quit',...
  157. 'Callback','laprint(''quit'');');
  158. %---------------------------------
  159. % options uimenue
  160. %---------------------------------
  161. hm1 = uimenu('label','Options');
  162. uimenu(hm1,...
  163. 'label','Sizes and Scalings ...',...
  164. 'callback','laprint(''size'')');
  165. LAPRINTHAN.keepfontprops = uimenu(hm1,...
  166. 'label','Translate Matlab Font Properties to LaTeX',...
  167. 'callback','laprint(''keepfontprops'')');
  168. LAPRINTHAN.asonscreen = uimenu(hm1,...
  169. 'label','Print Limits and Ticks as on Screen',...
  170. 'separator','on',...
  171. 'callback','laprint(''asonscreen'')');
  172. LAPRINTHAN.keepticklabels = uimenu(hm1,...
  173. 'label','Keep Tick Labels within eps File',...
  174. 'callback','laprint(''keepticklabels'')');
  175. LAPRINTHAN.mathticklabels = uimenu(hm1,...
  176. 'label','Set Tick Labels in LaTeX Math Mode',...
  177. 'callback','laprint(''mathticklabels'')');
  178. LAPRINTHAN.head = uimenu(hm1,...
  179. 'label','Equip the tex File with a Head',...
  180. 'separator','on',...
  181. 'callback','laprint(''head'')');
  182. uimenu(hm1,...
  183. 'label','Comment in the Head of the tex File ...',...
  184. 'callback','laprint(''comment'')');
  185. uimenu(hm1,...
  186. 'label','Place a LaTeX Caption in the tex File ...',...
  187. 'callback','laprint(''caption'')');
  188. LAPRINTHAN.extrapicture = uimenu(hm1,...
  189. 'label','Place an Extra Picture in each Axes',...
  190. 'callback','laprint(''extrapicture'')');
  191. uimenu(hm1,...
  192. 'label','Length of psfrag Replacement Strings ...',...
  193. 'callback','laprint(''nzeros'')');
  194. LAPRINTHAN.verbose = uimenu(hm1,...
  195. 'label','Call LaPrint in Verbose Mode',...
  196. 'separator','on',...
  197. 'callback','laprint(''verbose'')');
  198. LAPRINTHAN.figcopy = uimenu(hm1,...
  199. 'label','Copy Figure and Modify that Copy',...
  200. 'callback','laprint(''figcopy'')');
  201. uimenu(hm1,...
  202. 'label','Matlab Print Command ...',...
  203. 'separator','on',...
  204. 'callback','laprint(''printcmd'')');
  205. h=uimenu(hm1,...
  206. 'separator','on',...
  207. 'label','LaTeX Graphics Package');
  208. LAPRINTHAN.package_graphicx = uimenu(h,...
  209. 'label','graphicx',...
  210. 'callback','laprint(''package_graphicx'')');
  211. LAPRINTHAN.package_epsfig = uimenu(h,...
  212. 'label','epsfig',...
  213. 'callback','laprint(''package_epsfig'')');
  214. LAPRINTHAN.color = uimenu(hm1,...
  215. 'label','Use LaTeX ''color'' Package',...
  216. 'callback','laprint(''color'')');
  217. h = uimenu(hm1,...
  218. 'label','View File ...',...
  219. 'separator','on');
  220. LAPRINTHAN.createview = uimenu(h,...
  221. 'label','Create a View File',...
  222. 'callback','laprint(''createview'')');
  223. uimenu(h,...
  224. 'label','Name of the View File ...',...
  225. 'callback','laprint(''viewfilename'')');
  226. LAPRINTHAN.processview = uimenu(h,...
  227. 'label','Process the View File',...
  228. 'separator','on',...
  229. 'callback','laprint(''processview'')');
  230. uimenu(h,...
  231. 'label','Executables for Processing View File...',...
  232. 'callback','laprint(''cmdsview'')');
  233. %---------------------------------
  234. % Preferences uimenue
  235. %---------------------------------
  236. hm3=uimenu('label','Preferences');
  237. uimenu(hm3,...
  238. 'label','Get Preferences',...
  239. 'callback','laprint(''getpref'')')
  240. uimenu(hm3,...
  241. 'label','Set Preferences to Current Settings',...
  242. 'callback','laprint(''setpref'')')
  243. uimenu(hm3,...
  244. 'label','Remove Preferences',...
  245. 'callback','laprint(''rmpref'')')
  246. uimenu(hm3,...
  247. 'label','Save Current Settings to a File ...',...
  248. 'separator','on',...
  249. 'callback','laprint(''savepref'')')
  250. uimenu(hm3,...
  251. 'label','Load Settings from a File ...',...
  252. 'callback','laprint(''loadpref'')')
  253. uimenu(hm3,...
  254. 'label','Get Factory Defaults',...
  255. 'separator','on',...
  256. 'callback','laprint(''factory'')')
  257. %---------------------------------
  258. % Help uimenue
  259. %---------------------------------
  260. hm2=uimenu('label','Help');
  261. uimenu(hm2,...
  262. 'label',['LaPrint Online Help ...'],...
  263. 'callback','laprint(''helpwindow'')');
  264. uimenu(hm2,...
  265. 'label','Get the LaPrint Users Guide',...
  266. 'callback',['web www.uni-kassel.de/fb16/rat/matlab',...
  267. '/laprint/laprintdoc.ps -browser'])
  268. uimenu(hm2,...
  269. 'label',['Look for a newer version of LaPrint ' ...
  270. '(Matlab Central File Exchange)...'],...
  271. 'callback',['web http://www.mathworks.de/matlabcentral/',...
  272. 'fileexchange/loadFile.do?objectId=4638',...
  273. '&objectType=file -browser'])
  274. uimenu(hm2,...
  275. 'label','Version and Author ...',...
  276. 'callback','laprint(''whois'')')
  277. %---------------------------------
  278. % make hf invisible
  279. %---------------------------------
  280. set(hf,'HandleVisibility','callback')
  281. %---------------------------------
  282. % get settings
  283. %---------------------------------
  284. LAPRINTOPT = prefsettings;
  285. if isempty(LAPRINTOPT)
  286. LAPRINTOPT = factorysettings;
  287. end
  288. %---------------------------------
  289. % get figure
  290. %---------------------------------
  291. gcfig=gcf;
  292. if gcfig == hf
  293. allfigs = findobj('type','figure');
  294. allfigs = allfigs(find(allfigs~=hf));
  295. if length(allfigs)
  296. figno = allfigs(1);
  297. else
  298. figure(1)
  299. figno=1;
  300. end
  301. else
  302. figno=gcfig;
  303. end
  304. LAPRINTOPT.figno = figno;
  305. %---------------------------------
  306. % update
  307. %---------------------------------
  308. updategui(LAPRINTHAN,LAPRINTOPT)
  309. sethf(hf,LAPRINTHAN,LAPRINTOPT)
  310. figure(hf)
  311. %---------------------------------
  312. % done
  313. %---------------------------------
  314. return
  315. end % if nargin==0
  316. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  317. %%%%
  318. %%%% callback calls ('factory' and 'getprefs' also
  319. %%%% used from command line)
  320. %%%%
  321. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  322. if isa(figno,'char')
  323. switch figno
  324. case 'figno'
  325. [LAPRINTHAN,LAPRINTOPT]=gethf(hf);
  326. LAPRINTOPT.figno=eval(get(LAPRINTHAN.figno,'string'));
  327. figure(LAPRINTOPT.figno)
  328. figure(hf)
  329. sethf(hf,LAPRINTHAN,LAPRINTOPT);
  330. case 'filename'
  331. [LAPRINTHAN,LAPRINTOPT]=gethf(hf);
  332. LAPRINTOPT.filename=get(LAPRINTHAN.filename,'string');
  333. [texfullnameext,texbasenameext,texbasename,texdirname] = ...
  334. getfilenames(LAPRINTOPT.filename,'tex',0);
  335. [epsfullnameext,epsbasenameext,epsbasename,epsdirname] = ...
  336. getfilenames(LAPRINTOPT.filename,'eps',0);
  337. sethf(hf,LAPRINTHAN,LAPRINTOPT);
  338. case 'save'
  339. % lapcmd = [ 'laprint(' int2str(LAPRINTOPT.figno) ...
  340. % ', ''' LAPRINTOPT.filename ''''...
  341. % ', ''options'', LAPRINTOPT)'];
  342. lapcmd = 'laprint({})';
  343. eval(lapcmd)
  344. case 'quit'
  345. delete(hf)
  346. try
  347. delete(hhf)
  348. end
  349. case 'size'
  350. [LAPRINTHAN,LAPRINTOPT]=gethf(hf);
  351. answer = inputdlg({['Please enter the width (in centimeters) ',...
  352. 'of the graphics in the LaTeX document (The height ',...
  353. 'will be computed such that the aspect ratio of the ',...
  354. 'figure on screen is retained.) :'],...
  355. ['Please enter the factor by which the size of the '...
  356. 'graphics in the LaTeX document differs from the size of the '...
  357. 'Postscipt graphics ( Explaination: A factor <1 scales ',...
  358. 'the picture down. This means that lines become thinner ',...
  359. 'and fonts become smaller. ) :'],...
  360. ['Please specify if you want to scale the fonts along with ',...
  361. 'the graphics (enter ''on'' or ''off'') : '] },...
  362. 'LaPrint Settings',1,{num2str(LAPRINTOPT.width),...
  363. num2str(LAPRINTOPT.factor),...
  364. valueyn(LAPRINTOPT.scalefonts)},'on');
  365. if length(answer)
  366. LAPRINTOPT.width=eval(answer{1});
  367. LAPRINTOPT.factor = eval(answer{2});
  368. LAPRINTOPT.scalefonts = value01(answer{3});
  369. end
  370. sethf(hf,LAPRINTHAN,LAPRINTOPT);
  371. case 'keepfontprops'
  372. [LAPRINTHAN,LAPRINTOPT]=gethf(hf);
  373. if LAPRINTOPT.keepfontprops==1
  374. LAPRINTOPT.keepfontprops=0;
  375. set(LAPRINTHAN.keepfontprops,'check','off')
  376. else
  377. LAPRINTOPT.keepfontprops=1;
  378. set(LAPRINTHAN.keepfontprops,'check','on')
  379. end
  380. sethf(hf,LAPRINTHAN,LAPRINTOPT);
  381. case 'asonscreen'
  382. [LAPRINTHAN,LAPRINTOPT]=gethf(hf);
  383. if LAPRINTOPT.asonscreen==1
  384. LAPRINTOPT.asonscreen=0;
  385. set(LAPRINTHAN.asonscreen,'check','off')
  386. else
  387. LAPRINTOPT.asonscreen=1;
  388. set(LAPRINTHAN.asonscreen,'check','on')
  389. end
  390. sethf(hf,LAPRINTHAN,LAPRINTOPT);
  391. case 'keepticklabels'
  392. [LAPRINTHAN,LAPRINTOPT]=gethf(hf);
  393. if LAPRINTOPT.keepticklabels==1
  394. LAPRINTOPT.keepticklabels=0;
  395. set(LAPRINTHAN.keepticklabels,'check','off')
  396. else
  397. LAPRINTOPT.keepticklabels=1;
  398. set(LAPRINTHAN.keepticklabels,'check','on')
  399. end
  400. sethf(hf,LAPRINTHAN,LAPRINTOPT);
  401. case 'mathticklabels'
  402. [LAPRINTHAN,LAPRINTOPT]=gethf(hf);
  403. if LAPRINTOPT.mathticklabels==1
  404. LAPRINTOPT.mathticklabels=0;
  405. set(LAPRINTHAN.mathticklabels,'check','off')
  406. else
  407. LAPRINTOPT.mathticklabels=1;
  408. set(LAPRINTHAN.mathticklabels,'check','on')
  409. end
  410. sethf(hf,LAPRINTHAN,LAPRINTOPT);
  411. case 'head'
  412. [LAPRINTHAN,LAPRINTOPT]=gethf(hf);
  413. if LAPRINTOPT.head==1
  414. LAPRINTOPT.head=0;
  415. set(LAPRINTHAN.head,'check','off')
  416. else
  417. LAPRINTOPT.head=1;
  418. set(LAPRINTHAN.head,'check','on')
  419. end
  420. sethf(hf,LAPRINTHAN,LAPRINTOPT);
  421. case 'comment'
  422. [LAPRINTHAN,LAPRINTOPT]=gethf(hf);
  423. answer = inputdlg({['Please enter a describing comment to '...
  424. 'be placed into the head of the tex file:']},...
  425. 'LaPrint Settings',1,{LAPRINTOPT.comment},'on');
  426. if length(answer)
  427. LAPRINTOPT.comment = answer{1};
  428. end
  429. sethf(hf,LAPRINTHAN,LAPRINTOPT);
  430. case 'caption'
  431. [LAPRINTHAN,LAPRINTOPT]=gethf(hf);
  432. answer = inputdlg(['If the following text is nonempty, ' ...
  433. 'then it will be placed as a \caption{} into the tex '...
  434. 'file along with \label{fig:' LAPRINTOPT.filename '}. '...
  435. 'Please enter the caption text:'],...
  436. 'LaPrint Settings',1,{LAPRINTOPT.caption},'on');
  437. if length(answer)
  438. LAPRINTOPT.caption = answer{1};
  439. end
  440. sethf(hf,LAPRINTHAN,LAPRINTOPT);
  441. case 'extrapicture'
  442. [LAPRINTHAN,LAPRINTOPT]=gethf(hf);
  443. if LAPRINTOPT.extrapicture==1
  444. LAPRINTOPT.extrapicture=0;
  445. set(LAPRINTHAN.extrapicture,'check','off')
  446. else
  447. LAPRINTOPT.extrapicture=1;
  448. set(LAPRINTHAN.extrapicture,'check','on')
  449. end
  450. sethf(hf,LAPRINTHAN,LAPRINTOPT);
  451. case 'nzeros'
  452. [LAPRINTHAN,LAPRINTOPT]=gethf(hf);
  453. answer = inputdlg({['Please enter length of the psfrag replacement '...
  454. 'strings (must be >= 3) :']},...
  455. 'LaPrint Settings',1,{num2str(LAPRINTOPT.nzeros)},'on');
  456. if length(answer)
  457. LAPRINTOPT.nzeros = max(eval(answer{1}),3);
  458. end
  459. sethf(hf,LAPRINTHAN,LAPRINTOPT);
  460. case 'verbose'
  461. [LAPRINTHAN,LAPRINTOPT]=gethf(hf);
  462. if LAPRINTOPT.verbose==1
  463. LAPRINTOPT.verbose=0;
  464. set(LAPRINTHAN.verbose,'check','off')
  465. else
  466. LAPRINTOPT.verbose=1;
  467. set(LAPRINTHAN.verbose,'check','on')
  468. end
  469. sethf(hf,LAPRINTHAN,LAPRINTOPT);
  470. case 'figcopy'
  471. [LAPRINTHAN,LAPRINTOPT]=gethf(hf);
  472. if LAPRINTOPT.figcopy==1
  473. LAPRINTOPT.figcopy=0;
  474. set(LAPRINTHAN.figcopy,'check','off')
  475. else
  476. LAPRINTOPT.figcopy=1;
  477. set(LAPRINTHAN.figcopy,'check','on')
  478. end
  479. sethf(hf,LAPRINTHAN,LAPRINTOPT);
  480. case 'printcmd'
  481. [LAPRINTHAN,LAPRINTOPT]=gethf(hf);
  482. answer = inputdlg({['Please enter the Matlab command '...
  483. 'to be used for printing the eps file '...
  484. '(LaPrint will internally replace <figurenumber> by the '...
  485. 'number of the figure <filename.eps> by the ' ...
  486. 'eps-filename and <filename> '...
  487. 'by the basename of the file, respectively). You can add options '...
  488. 'here (like ''-loose'') or use a different program '...
  489. 'for printing (like ''exportfig'') :']},...
  490. 'LaPrint Settings',1,{LAPRINTOPT.printcmd},'on');
  491. if length(answer)
  492. LAPRINTOPT.printcmd = answer{1};
  493. end
  494. sethf(hf,LAPRINTHAN,LAPRINTOPT);
  495. case 'package_epsfig'
  496. [LAPRINTHAN,LAPRINTOPT]=gethf(hf);
  497. LAPRINTOPT.package='epsfig';
  498. set(LAPRINTHAN.package_epsfig,'check','on')
  499. set(LAPRINTHAN.package_graphicx,'check','off')
  500. sethf(hf,LAPRINTHAN,LAPRINTOPT);
  501. case 'package_graphicx'
  502. [LAPRINTHAN,LAPRINTOPT]=gethf(hf);
  503. LAPRINTOPT.package='graphicx';
  504. set(LAPRINTHAN.package_epsfig,'check','off')
  505. set(LAPRINTHAN.package_graphicx,'check','on')
  506. sethf(hf,LAPRINTHAN,LAPRINTOPT);
  507. case 'color'
  508. [LAPRINTHAN,LAPRINTOPT]=gethf(hf);
  509. if LAPRINTOPT.color==1
  510. LAPRINTOPT.color=0;
  511. set(LAPRINTHAN.color,'check','off')
  512. else
  513. LAPRINTOPT.color=1;
  514. set(LAPRINTHAN.color,'check','on')
  515. end
  516. sethf(hf,LAPRINTHAN,LAPRINTOPT);
  517. case 'createview'
  518. [LAPRINTHAN,LAPRINTOPT]=gethf(hf);
  519. if LAPRINTOPT.createview==1
  520. LAPRINTOPT.createview=0;
  521. LAPRINTOPT.processview=0;
  522. set(LAPRINTHAN.createview,'check','off')
  523. set(LAPRINTHAN.processview,'check','off')
  524. else
  525. LAPRINTOPT.createview=1;
  526. set(LAPRINTHAN.createview,'check','on')
  527. end
  528. sethf(hf,LAPRINTHAN,LAPRINTOPT);
  529. case 'viewfilename'
  530. [LAPRINTHAN,LAPRINTOPT]=gethf(hf);
  531. trydlg=1;
  532. txt=['Please enter the name of the '...
  533. 'viewfile (without extension .tex) : '];
  534. txt2='';
  535. while trydlg
  536. answer = inputdlg({[txt txt2]},...
  537. 'LaPrint Settings',1,{LAPRINTOPT.viewfilename},'on');
  538. if length(answer)
  539. if strcmp(answer{1},LAPRINTOPT.filename)
  540. txt2=['The name must be different from the name of the '...
  541. 'graphics file):'];
  542. else
  543. trydlg=0;
  544. LAPRINTOPT.viewfilename = answer{1};
  545. [viewfullnameext,viewbasenameext,viewbasename,viewdirname] = ...
  546. getfilenames(LAPRINTOPT.viewfilename,'tex',0);
  547. end
  548. else
  549. trydlg=0;
  550. end
  551. end
  552. sethf(hf,LAPRINTHAN,LAPRINTOPT);
  553. case 'processview'
  554. [LAPRINTHAN,LAPRINTOPT]=gethf(hf);
  555. if LAPRINTOPT.processview==1
  556. LAPRINTOPT.processview=0;
  557. set(LAPRINTHAN.processview,'check','off')
  558. else
  559. LAPRINTOPT.processview=1;
  560. set(LAPRINTHAN.processview,'check','on')
  561. LAPRINTOPT.createview=1;
  562. set(LAPRINTHAN.createview,'check','on')
  563. end
  564. sethf(hf,LAPRINTHAN,LAPRINTOPT);
  565. case 'cmdsview'
  566. [LAPRINTHAN,LAPRINTOPT]=gethf(hf);
  567. answer = inputdlg({...
  568. ['Please enter up to 8 commands to process the view-file. ',...
  569. 'Leave any of the fields empty, if you have ',...
  570. 'less than 8 commands. ',...
  571. 'In any of the following commands, LaPrint internally '...
  572. 'replaces the tag <viewfile> by the name of the viewfile ',...
  573. 'and the tag <filename> by the basename specified in the ',...
  574. 'main LaPrint Window. ',...
  575. 'At minimum you should enter the commands for the LaTeX ',...
  576. 'compilation and for the dvi-to-postscript conversion ',...
  577. 'here. See the LaPrint Online-Help for futher ',...
  578. 'suggestions. ',...
  579. 'Please enter the 1st command:'],...
  580. 'Please enter the 2nd command:',...
  581. 'Please enter the 3rd command:',...
  582. 'Please enter the 4th command:',...
  583. 'Please enter the 5th command:',...
  584. 'Please enter the 6th command:',...
  585. 'Please enter the 7th command:',...
  586. 'Please enter the 8th command:'},...
  587. 'LaPrint Settings',1,{LAPRINTOPT.cmd1,...
  588. LAPRINTOPT.cmd2,LAPRINTOPT.cmd3,...
  589. LAPRINTOPT.cmd4,LAPRINTOPT.cmd5,LAPRINTOPT.cmd6,...
  590. LAPRINTOPT.cmd7,LAPRINTOPT.cmd8},'on');
  591. if length(answer)==8
  592. LAPRINTOPT.cmd1=answer{1};
  593. LAPRINTOPT.cmd2=answer{2};
  594. LAPRINTOPT.cmd3=answer{3};
  595. LAPRINTOPT.cmd4=answer{4};
  596. LAPRINTOPT.cmd5=answer{5};
  597. LAPRINTOPT.cmd6=answer{6};
  598. LAPRINTOPT.cmd7=answer{7};
  599. LAPRINTOPT.cmd8=answer{8};
  600. end
  601. sethf(hf,LAPRINTHAN,LAPRINTOPT);
  602. case 'getpref'
  603. [LAPRINTHAN,LAPRINTOPT]=gethf(hf);
  604. out = prefsettings;
  605. if ~isempty(out)
  606. oldfigno = LAPRINTOPT.figno; % keep this!
  607. LAPRINTOPT = out;
  608. LAPRINTOPT.figno = oldfigno;
  609. else
  610. errordlg('No LaPrint preferences available.')
  611. end
  612. updategui(LAPRINTHAN,LAPRINTOPT);
  613. sethf(hf,LAPRINTHAN,LAPRINTOPT);
  614. case 'setpref'
  615. [LAPRINTHAN,LAPRINTOPT]=gethf(hf);
  616. setpref('LaPrint','LAPRINTOPT',LAPRINTOPT);
  617. case 'rmpref'
  618. if ispref('LaPrint')
  619. rmpref('LaPrint');
  620. else
  621. errordlg('Preference does not exist.')
  622. end
  623. case 'savepref'
  624. [LAPRINTHAN,LAPRINTOPT]=gethf(hf);
  625. txt = 'Save preferences file ';
  626. [preffile,prefpath]=uiputfile('laprint.mat',txt);
  627. save([prefpath preffile],'LAPRINTOPT');
  628. case 'loadpref'
  629. [LAPRINTHAN,LAPRINTOPT]=gethf(hf);
  630. txt = ['Load preferences file '...
  631. '(must be previously created by LaPrint)'];
  632. [preffile,prefpath]=uigetfile('laprint.mat',txt);
  633. if ~isequal(preffile,0) & ~isequal(prefpath,0)
  634. oldfigno = LAPRINTOPT.figno; % keep this!
  635. load([prefpath preffile]); % hope file contains correct
  636. LAPRINTOPT.figno = oldfigno; % LAPRINTOPT
  637. updategui(LAPRINTHAN,LAPRINTOPT);
  638. sethf(hf,LAPRINTHAN,LAPRINTOPT);
  639. end
  640. case 'factory'
  641. [LAPRINTHAN,LAPRINTOPT]=gethf(hf);
  642. out = factorysettings;
  643. if ~isempty(out)
  644. oldfigno = LAPRINTOPT.figno; % keep this!
  645. LAPRINTOPT = out;
  646. LAPRINTOPT.figno = oldfigno;
  647. else
  648. errordlg('No LaPrint preferences available.')
  649. end
  650. updategui(LAPRINTHAN,LAPRINTOPT);
  651. sethf(hf,LAPRINTHAN,LAPRINTOPT);
  652. case 'helpwindow'
  653. hhf=figure(hhf);
  654. set(hhf,'Name','LaPrint Online Help',...
  655. 'Numbertitle','off',...
  656. 'menubar','none',...
  657. 'HandleVisibility','callback',...
  658. 'resize','on',...
  659. 'ResizeFcn','laprint(''helpwindow'');');
  660. hht=uicontrol('Parent',hhf,...
  661. 'style','listbox',...
  662. 'units','normalized',...
  663. 'position',[0.005 0.005 0.9 0.99],...
  664. 'BackgroundColor','w',...
  665. 'Fontsize',12,...
  666. 'foregroundcolor','k',...
  667. 'FontName','FixedWidth',...
  668. 'HorizontalAlignment','left');
  669. [txt,hhtpos]=textwrap(hht,helptext);
  670. set(hht,'string',txt)
  671. set(hht,'position',[0.005 0.005 0.99 0.99])
  672. set(hht,'HandleVisibility','callback')
  673. case 'whois'
  674. msgbox({['This is LaPrint, Version ' laprintident],...
  675. '',...
  676. 'To blame for LaPrint:',...
  677. 'Arno Linnemann','Control and Automation',...
  678. 'Department of Electrical and Computer Engineering',...
  679. 'University of Kassel',...
  680. '34109 Kassel',...
  681. 'Germany',...
  682. 'mailto:linnemann@uni-kassel.de'},...
  683. 'LaPrint Info')
  684. otherwise
  685. error('unknown callback option')
  686. end
  687. return
  688. end % if isa(figno,'char')
  689. % nargin >=1 and ~isa(figno,'char')
  690. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  691. %%%%
  692. %%%% PART 1 of advanced usage:
  693. %%%% Check inputs and initialize
  694. %%%%
  695. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  696. if isa(figno,'cell') % called from GUI (all set)
  697. [LAPRINTHAN,LAPRINTOPT]=gethf(hf);
  698. figno=LAPRINTOPT.figno;
  699. filename=LAPRINTOPT.filename;
  700. else % advanced usage
  701. % get settings
  702. LAPRINTOPT = prefsettings;
  703. if isempty(LAPRINTOPT)
  704. LAPRINTOPT = factorysettings;
  705. end
  706. % modify prefs
  707. if ~isa(figno,'double')
  708. figno
  709. error('This is not a figure handle.')
  710. end
  711. if ~any(get(0,'children')==figno)
  712. figno
  713. error('This is not a figure handle.')
  714. end
  715. LAPRINTOPT.figno = figno;
  716. if nargin>1
  717. if ~isa(filename,'char')
  718. filename
  719. error('This is not a file name.')
  720. end
  721. LAPRINTOPT.filename=filename;
  722. end
  723. end
  724. % read and check command line options
  725. try % try old usage (Version 2.03)
  726. if nargin <=2
  727. error('lets take new usage')
  728. end
  729. % 2.03 defaults
  730. width = 12;
  731. factor = 0.8;
  732. scalefonts = 1;
  733. keepfontprops = 0;
  734. asonscreen = 0;
  735. keepticklabels = 0;
  736. mathticklabels = 0;
  737. head = 1;
  738. comment = '';
  739. caption = '';
  740. extrapicture = 1;
  741. nzeros = 5;
  742. verbose = 0;
  743. figcopy = 1;
  744. printcmd = ['print(''-f<figurenumber>'',' ...
  745. '''-deps'',''<filename.eps>'')'];
  746. package = 'epsfig';
  747. color = 0;
  748. createview = 0;
  749. viewfilename = [filename '_'];
  750. processview = 0;
  751. cmd1 = '';
  752. cmd2 = '';
  753. cmd3 = '';
  754. cmd4 = '';
  755. cmd5 = '';
  756. cmd6 = '';
  757. cmd7 = '';
  758. cmd8 = '';
  759. for i=1:nargin-2
  760. if ~isa(varargin{i},'char')
  761. error('Options must be character arrays.')
  762. end
  763. oriopt=varargin{i}(:)';
  764. opt=[ lower(strrep(oriopt,' ','')) ' ' ];
  765. if strcmp(opt(1:7),'verbose')
  766. verbose=1;
  767. elseif strcmp(opt(1:10),'asonscreen')
  768. asonscreen=1;
  769. elseif strcmp(opt(1:14),'keepticklabels')
  770. keepticklabels=1;
  771. elseif strcmp(opt(1:14),'mathticklabels')
  772. mathticklabels=1;
  773. elseif strcmp(opt(1:13),'keepfontprops')
  774. keepfontprops=1;
  775. elseif strcmp(opt(1:14),'noextrapicture')
  776. extrapicture=0;
  777. elseif strcmp(opt(1:14),'noextrapicture')
  778. extrapicture=0;
  779. elseif strcmp(opt(1:5),'loose')
  780. printcmd = ['print(''-f<figurenumber>'',' ...
  781. '''-deps'',''-loose'',''<filename.eps>'')'];
  782. elseif strcmp(opt(1:9),'nofigcopy')
  783. figcopy=0;
  784. elseif strcmp(opt(1:12),'noscalefonts')
  785. scalefonts=0;
  786. elseif strcmp(opt(1:6),'nohead')
  787. head=0;
  788. elseif strcmp(opt(1:7),'caption')
  789. eqpos=findstr(oriopt,'=');
  790. if isempty(eqpos)
  791. caption='Matlab Figure';
  792. else
  793. caption=oriopt(eqpos+1:length(oriopt));
  794. end
  795. elseif strcmp(opt(1:8),'comment=')
  796. eqpos=findstr(oriopt,'=');
  797. comment=oriopt(eqpos(1)+1:length(oriopt));
  798. elseif strcmp(opt(1:9),'viewfile=')
  799. createview=1;
  800. eqpos=findstr(oriopt,'=');
  801. viewfilename=oriopt(eqpos(1)+1:length(oriopt));
  802. elseif strcmp(opt(1:6),'width=')
  803. eval([ opt ';' ]);
  804. elseif strcmp(opt(1:7),'factor=')
  805. eval([ opt ';' ]);
  806. else
  807. error([ 'Option ' varargin{i} ' not recognized.'])
  808. end
  809. end
  810. warning('LaPrint:general',['You are using the old LaPrint '...
  811. 'syntax. This syntax might not be supported in '...
  812. 'future releases of LaPrint.'])
  813. catch % old usage doesn't work, take new one
  814. % restore preferences / factory defaults
  815. width = LAPRINTOPT.width;
  816. factor = LAPRINTOPT.factor;
  817. scalefonts = LAPRINTOPT.scalefonts;
  818. keepfontprops = LAPRINTOPT.keepfontprops;
  819. asonscreen = LAPRINTOPT.asonscreen;
  820. keepticklabels = LAPRINTOPT.keepticklabels;
  821. mathticklabels = LAPRINTOPT.mathticklabels;
  822. head = LAPRINTOPT.head;
  823. comment = LAPRINTOPT.comment;
  824. caption = LAPRINTOPT.caption;
  825. extrapicture = LAPRINTOPT.extrapicture;
  826. nzeros = LAPRINTOPT.nzeros;
  827. verbose = LAPRINTOPT.verbose;
  828. figcopy = LAPRINTOPT.figcopy;
  829. printcmd = LAPRINTOPT.printcmd;
  830. package = LAPRINTOPT.package;
  831. color = LAPRINTOPT.color;
  832. createview = LAPRINTOPT.createview;
  833. viewfilename = LAPRINTOPT.viewfilename;
  834. processview = LAPRINTOPT.processview;
  835. cmd1 = LAPRINTOPT.cmd1;
  836. cmd2 = LAPRINTOPT.cmd2;
  837. cmd3 = LAPRINTOPT.cmd3;
  838. cmd4 = LAPRINTOPT.cmd4;
  839. cmd5 = LAPRINTOPT.cmd5;
  840. cmd6 = LAPRINTOPT.cmd6;
  841. cmd7 = LAPRINTOPT.cmd7;
  842. cmd8 = LAPRINTOPT.cmd8;
  843. if nargin > 2
  844. if rem(nargin,2)
  845. error('Option names/values must appear in pairs.')
  846. end
  847. for i=1:2:nargin-2
  848. if ~isa(varargin{i},'char')
  849. error('Option name must be a character array.')
  850. end
  851. opt = lower(strrep(varargin{i}(:)',' ',''));
  852. val = varargin{i+1}(:)';
  853. switch opt
  854. case 'options'
  855. if isa(val,'char')
  856. if strcmp(val,'factory')
  857. val = factorysettings;
  858. else
  859. load(val)
  860. val = LAPRINTOPT;
  861. end
  862. end
  863. if ~isa(val,'struct')
  864. error('Value of options must be a structure array.')
  865. end
  866. % no error checking here!
  867. width = val.width;
  868. factor = val.factor;
  869. scalefonts = val.scalefonts;
  870. keepfontprops = val.keepfontprops;
  871. asonscreen = val.asonscreen;
  872. keepticklabels = val.keepticklabels;
  873. mathticklabels = val.mathticklabels;
  874. head = val.head;
  875. comment = val.comment;
  876. caption = val.caption;
  877. extrapicture = val.extrapicture;
  878. nzeros = val.nzeros;
  879. verbose = val.verbose;
  880. figcopy = val.figcopy;
  881. printcmd = val.printcmd;
  882. package = val.package;
  883. color = val.color;
  884. createview = val.createview;
  885. viewfilename = val.viewfilename;
  886. processview = val.processview;
  887. cmd1 = val.cmd1;
  888. cmd2 = val.cmd2;
  889. cmd3 = val.cmd3;
  890. cmd4 = val.cmd4;
  891. cmd5 = val.cmd5;
  892. cmd6 = val.cmd6;
  893. cmd7 = val.cmd7;
  894. cmd8 = val.cmd8;
  895. case 'width'
  896. if ~isa(val,'double')
  897. error('Value of width must be a double.')
  898. end
  899. width = val;
  900. case 'factor'
  901. if ~isa(val,'double')
  902. error('Value of factor must be a double.')
  903. end
  904. factor=val;
  905. case 'scalefonts'
  906. scalefonts = value01(val,opt);
  907. case 'keepfontprops'
  908. keepfontprops = value01(val,opt);
  909. case 'asonscreen'
  910. asonscreen = value01(val,opt);
  911. case 'keepticklabels'
  912. keepticklabels = value01(val,opt);
  913. case 'mathticklabels'
  914. mathticklabels = value01(val,opt) ;
  915. case 'head'
  916. head = value01(val,opt);
  917. case 'comment'
  918. if ~isa(val,'char')
  919. error('Value of comment must be a character array.')
  920. end
  921. comment = val;
  922. case 'caption'
  923. if ~isa(val,'char')
  924. error('Value of caption must be a character array.')
  925. end
  926. caption = val;
  927. case 'extrapicture'
  928. extrapicture = value01(val,opt);
  929. case 'nzeros'
  930. if ~isa(val,'double')
  931. error('Value of nzeros must be a double.')
  932. end
  933. nzeros = val;
  934. case 'verbose'
  935. verbose = value01(val,opt);
  936. case 'figcopy'
  937. figcopy = value01(val,opt);
  938. case 'printcmd'
  939. if ~isa(val,'char')
  940. error('Value of printcmd must be a character array.')
  941. end
  942. printcmd = val;
  943. case 'package'
  944. if ~isa(val,'char')
  945. error('Value of package must be a character array.')
  946. end
  947. val = lower(strrep(val,' ',''));
  948. switch val
  949. case {'graphicx','epsfig'}
  950. % fine
  951. otherwise
  952. error('Value of package is unknown.')
  953. end
  954. package = val;
  955. case 'color'
  956. color = value01(val,opt);
  957. case 'createview'
  958. createview = value01(val,opt);
  959. case 'viewfilename'
  960. if ~isa(val,'char')
  961. error('Value of viewfilename must be a character array.')
  962. end
  963. viewfilename = val;
  964. case 'processview'
  965. processview = value01(val,opt);
  966. case 'cmd1'
  967. if ~isa(val,'char')
  968. error('Value of cmd1 must be a character array.')
  969. end
  970. cmd1 = val;
  971. case 'cmd2'
  972. if ~isa(val,'char')
  973. error('Value of cmd2 must be a character array.')
  974. end
  975. cmd2 = val;
  976. case 'cmd3'
  977. if ~isa(val,'char')
  978. error('Value of cmd3 must be a character array.')
  979. end
  980. cmd3 = val;
  981. case 'cmd4'
  982. if ~isa(val,'char')
  983. error('Value of cmd4 must be a character array.')
  984. end
  985. cmd4 = val;
  986. case 'cmd5'
  987. if ~isa(val,'char')
  988. error('Value of cmd5 must be a character array.')
  989. end
  990. cmd5 = val;
  991. case 'cmd6'
  992. if ~isa(val,'char')
  993. error('Value of cmd6 must be a character array.')
  994. end
  995. cmd6 = val;
  996. case 'cmd7'
  997. if ~isa(val,'char')
  998. error('Value of cmd7 must be a character array.')
  999. end
  1000. cmd7 = val;
  1001. case 'cmd8'
  1002. if ~isa(val,'char')
  1003. error('Value of cmd8 must be a character array.')
  1004. end
  1005. cmd8 = val;
  1006. otherwise
  1007. error(['Option ''' opt ''' unknown'])
  1008. end % switch opt
  1009. end % for i=3:2:nargin
  1010. end % if nargin > 2
  1011. end % try / catch
  1012. if verbose,
  1013. disp([ 'This is LaPrint, version ' laprintident '.' ]);
  1014. end
  1015. comment = strrep(strrep(comment,'\','\\'),'%','%%');
  1016. caption = strrep(strrep(caption,'\','\\'),'%','%%');
  1017. iscaption = logical(length(caption));
  1018. if nzeros < 3
  1019. warning('LaPrint:general',...
  1020. 'The value of nzero should be >=3. I will use nzeros=3.')
  1021. nzeros=3;
  1022. end
  1023. if processview
  1024. createview=1;
  1025. end
  1026. if mathticklabels
  1027. Do='$';
  1028. else
  1029. Do='';
  1030. end
  1031. % eps- and tex- filenames
  1032. [epsfullnameext,epsbasenameext,epsbasename,epsdirname] = ...
  1033. getfilenames(filename,'eps',verbose);
  1034. [texfullnameext,texbasenameext,texbasename,texdirname] = ...
  1035. getfilenames(filename,'tex',verbose);
  1036. if ~strcmp(texdirname,epsdirname)
  1037. warning('LaPrint:files',['The eps-file and tex-file are '...
  1038. 'placed in different directories.']);
  1039. end
  1040. if createview | processview
  1041. [viewfullnameext,viewbasenameext,viewbasename,viewdirname] = ...
  1042. getfilenames(viewfilename,'tex',verbose);
  1043. if strcmp(texfullnameext,viewfullnameext)
  1044. viewfilename=[ viewfilename '_'];
  1045. warning('LaPrint:files',['The tex- and view-file coincide. '...
  1046. 'I''ll use '' ' viewfilename ' ''. Hope that''s ok.' ])
  1047. end
  1048. [viewfullnameext,viewbasenameext,viewbasename,viewdirname]= ...
  1049. getfilenames(viewfilename,'tex',verbose);
  1050. if ~strcmp(texdirname,viewdirname)
  1051. warning('LaPrint:files',['The eps-file and view-file are '...
  1052. 'placed in different directories.' ])
  1053. end
  1054. end
  1055. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1056. %%%%
  1057. %%%% PART 2 of advanced usage:
  1058. %%%% Create new figure, insert tags, and bookkeep original text
  1059. %%%%
  1060. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1061. % show all
  1062. shh = get(0,'ShowHiddenHandles');
  1063. set(0,'ShowHiddenHandles','on');
  1064. % preparing check for copyobj bug
  1065. figno_ori = figno;
  1066. number_children_ori = length(get(figno_ori,'children'));
  1067. % open new figure (if required) and set properties
  1068. if figcopy
  1069. figno = copyobj(figno,0);
  1070. set(figno,'visible','off')
  1071. set(figno,'Numbertitle','off')
  1072. set(figno,'MenuBar','none')
  1073. pause(0.5)
  1074. end
  1075. if asonscreen
  1076. xlimmodeauto = findobj(figno,'xlimmode','auto');
  1077. xtickmodeauto = findobj(figno,'xtickmode','auto');
  1078. xticklabelmodeauto = findobj(figno,'xticklabelmode','auto');
  1079. ylimmodeauto = findobj(figno,'ylimmode','auto');
  1080. ytickmodeauto = findobj(figno,'ytickmode','auto');
  1081. yticklabelmodeauto = findobj(figno,'yticklabelmode','auto');
  1082. zlimmodeauto = findobj(figno,'zlimmode','auto');
  1083. ztickmodeauto = findobj(figno,'ztickmode','auto');
  1084. zticklabelmodeauto = findobj(figno,'zticklabelmode','auto');
  1085. set(xlimmodeauto,'xlimmode','manual')
  1086. set(xtickmodeauto,'xtickmode','manual')
  1087. set(xticklabelmodeauto,'xticklabelmode','manual')
  1088. set(ylimmodeauto,'ylimmode','manual')
  1089. set(ytickmodeauto,'ytickmode','manual')
  1090. set(yticklabelmodeauto,'yticklabelmode','manual')
  1091. set(zlimmodeauto,'ylimmode','manual')
  1092. set(ztickmodeauto,'ytickmode','manual')
  1093. set(zticklabelmodeauto,'yticklabelmode','manual')
  1094. end
  1095. set(figno,'paperunits','centimeters');
  1096. set(figno,'units','centimeters');
  1097. orip = get(figno,'Position');
  1098. % determine width and height
  1099. if factor <= 0
  1100. factor = width/orip(3);
  1101. end
  1102. latexwidth = width;
  1103. epswidth = latexwidth/factor;
  1104. epsheight = epswidth*orip(4)/orip(3);
  1105. set(figno,'PaperPosition',[0 0 epswidth epsheight ])
  1106. set(figno,'papersize',[epswidth epsheight])
  1107. set(figno,'Position',[orip(1)+0.5 orip(2)-0.5 epswidth epsheight ])
  1108. set(figno,'Name',[ 'To be printed; size: ' num2str(factor,3) ...
  1109. ' x (' num2str(epswidth,3) 'cm x ' num2str(epsheight,3) 'cm)' ])
  1110. % some warnings
  1111. if verbose
  1112. if (epswidth<13) | (epsheight<13*0.75)
  1113. warning('LaPrint:size',['The size of the eps-figure is quite '...
  1114. 'small. The text objects might not be properly set. '...
  1115. 'Reducing ''factor'' might help.'])
  1116. end
  1117. if latexwidth/epswidth<0.5
  1118. warning('LaPrint:size',['The size of the eps-figure is large ' ...
  1119. 'compared to the latex figure. '...
  1120. 'The text size might be too small. '...
  1121. 'Increasing ''factor'' might help.'])
  1122. end
  1123. if (orip(3)-epswidth)/orip(3) > 0.1
  1124. warning('LaPrint:size',['The size of the eps-figure is much '...
  1125. 'smaller than the original '...
  1126. 'figure on screen. Matlab might save different ticks '...
  1127. 'and ticklabels than in the original figure. '...
  1128. 'See option ''asonscreen''.'])
  1129. end
  1130. disp('Strike any key to continue.');
  1131. pause
  1132. end
  1133. %
  1134. % TEXT OBJECTS: modify new figure
  1135. %
  1136. % find all text objects
  1137. hxl = get(findobj(figno,'type','axes'),'xlabel');
  1138. hyl = get(findobj(figno,'type','axes'),'ylabel');
  1139. hzl = get(findobj(figno,'type','axes'),'zlabel');
  1140. hti = get(findobj(figno,'type','axes'),'title');
  1141. hte = findobj(figno,'type','text');
  1142. % array of all text handles
  1143. htext = unique([ celltoarray(hxl) celltoarray(hyl) celltoarray(hzl) ...
  1144. celltoarray(hti) celltoarray(hte)]);
  1145. nt = length(htext);
  1146. % set(celltoarray(hxl),'VerticalAlignment','top');
  1147. % get alignments
  1148. hora = get(htext,'HorizontalAlignment');
  1149. vera = get(htext,'VerticalAlignment');
  1150. align = cell(nt,1);
  1151. for i=1:nt
  1152. align{i} = hora{i}(1);
  1153. switch vera{i}
  1154. case 'top'
  1155. align{i} = [align{i} 't'];
  1156. case 'cap'
  1157. % if ~isempty(get(htext(i),'string'))
  1158. % warning('LaPrint:text',['Using vertical ' ...
  1159. % 'alignment ''top'' instead of ''cap''.'])
  1160. % end
  1161. align{i} = [align{i} 't'];
  1162. case 'middle'
  1163. align{i} = [align{i} 'c'];
  1164. case 'baseline'
  1165. align{i} = [align{i} 'B'];
  1166. case 'bottom'
  1167. align{i} = [align{i} 'b'];
  1168. otherwise
  1169. warning('LaPrint:text',['Vertical alignment ' vera{i} ...
  1170. ' unknown. Using ''c''.'])
  1171. align{i} = [align{i} 'c'];
  1172. end
  1173. end
  1174. % generate new strings and store old ones
  1175. oldstr = get(htext,'string');
  1176. newstr = cell(nt,1);
  1177. basestr = ['s' char(48*ones(1,nzeros-1))];
  1178. extrastr = 0;
  1179. for i=1:nt
  1180. osi = oldstr{i};
  1181. oldstr{i} = ['\setlength{\tabcolsep}{0pt}\begin{tabular}{' ...
  1182. align{i}(1) '}'];
  1183. isnonempty_osi = 0;
  1184. if strcmp(get(get(htext(i),'parent'),'tag'),'legend')
  1185. newstr1 = [];
  1186. if isa(osi,'cell')
  1187. % Legend/cell : Don't use tabular, employ extra strings
  1188. nlines = length(osi);
  1189. if nlines > 1
  1190. newstr{nt+extrastr+nlines-1} = [];
  1191. oldstr{nt+extrastr+nlines-1} = [];
  1192. htext((nt+extrastr+1):(nt+extrastr+nlines-1))=htext(i);
  1193. for line=1:nlines-1
  1194. oldstr{nt+extrastr+line} = ...
  1195. strrep(strrep(osi{line},'\','\\'),'%','%%');
  1196. newstr{nt+extrastr+line} = ...
  1197. overwritetail(basestr,nt+extrastr+line);
  1198. newstr1 = [newstr1; overwritetail(basestr,nt+extrastr+line)];
  1199. end
  1200. extrastr = extrastr+nlines-1;
  1201. end
  1202. if nlines > 0
  1203. oldstr{i} = strrep(strrep(osi{nlines},'\','\\'),'%','%%');
  1204. newstr{i} = overwritetail(basestr,i);
  1205. newstr1 = [newstr1; overwritetail(basestr,i)];
  1206. end
  1207. % replace strings in figure
  1208. set(htext(i),'string',cellstr(newstr1));
  1209. else
  1210. % Legend/matrix : Don't use tabular, employ extra strings
  1211. nlines=size(osi,1);
  1212. if nlines > 1
  1213. newstr{nt+extrastr+nlines-1} = [];
  1214. oldstr{nt+extrastr+nlines-1} = [];
  1215. htext((nt+extrastr+1):(nt+extrastr+nlines-1))=htext(i);
  1216. for line=1:nlines-1
  1217. oldstr{nt+extrastr+line} = ...
  1218. strrep(strrep(osi(line,:),'\','\\'),'%','%%');
  1219. newstr{nt+extrastr+line} = ...
  1220. overwritetail(basestr,nt+extrastr+line);
  1221. newstr1 = [newstr1; ov