/laprint_org.m

https://github.com/sievers/matlab · Objective C · 2929 lines · 2727 code · 202 blank · 0 comment · 333 complexity · 7841c464dbcdf596e227fd1b439b2028 MD5 · raw 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. width = 5;
  732. factor = 0.8;
  733. scalefonts = 1;
  734. keepfontprops = 0;
  735. asonscreen = 0;
  736. keepticklabels = 0;
  737. mathticklabels = 0;
  738. head = 1;
  739. comment = '';
  740. caption = '';
  741. extrapicture = 1;
  742. nzeros = 5;
  743. verbose = 0;
  744. figcopy = 1;
  745. printcmd = ['print(''-f<figurenumber>'',' ...
  746. '''-deps'',''<filename.eps>'')'];
  747. package = 'epsfig';
  748. color = 0;
  749. createview = 0;
  750. viewfilename = [filename '_'];
  751. processview = 0;
  752. cmd1 = '';
  753. cmd2 = '';
  754. cmd3 = '';
  755. cmd4 = '';
  756. cmd5 = '';
  757. cmd6 = '';
  758. cmd7 = '';
  759. cmd8 = '';
  760. for i=1:nargin-2
  761. if ~isa(varargin{i},'char')
  762. error('Options must be character arrays.')
  763. end
  764. oriopt=varargin{i}(:)';
  765. opt=[ lower(strrep(oriopt,' ','')) ' ' ];
  766. if strcmp(opt(1:7),'verbose')
  767. verbose=1;
  768. elseif strcmp(opt(1:10),'asonscreen')
  769. asonscreen=1;
  770. elseif strcmp(opt(1:14),'keepticklabels')
  771. keepticklabels=1;
  772. elseif strcmp(opt(1:14),'mathticklabels')
  773. mathticklabels=1;
  774. elseif strcmp(opt(1:13),'keepfontprops')
  775. keepfontprops=1;
  776. elseif strcmp(opt(1:14),'noextrapicture')
  777. extrapicture=0;
  778. elseif strcmp(opt(1:14),'noextrapicture')
  779. extrapicture=0;
  780. elseif strcmp(opt(1:5),'loose')
  781. printcmd = ['print(''-f<figurenumber>'',' ...
  782. '''-deps'',''-loose'',''<filename.eps>'')'];
  783. elseif strcmp(opt(1:9),'nofigcopy')
  784. figcopy=0;
  785. elseif strcmp(opt(1:12),'noscalefonts')
  786. scalefonts=0;
  787. elseif strcmp(opt(1:6),'nohead')
  788. head=0;
  789. elseif strcmp(opt(1:7),'caption')
  790. eqpos=findstr(oriopt,'=');
  791. if isempty(eqpos)
  792. caption='Matlab Figure';
  793. else
  794. caption=oriopt(eqpos+1:length(oriopt));
  795. end
  796. elseif strcmp(opt(1:8),'comment=')
  797. eqpos=findstr(oriopt,'=');
  798. comment=oriopt(eqpos(1)+1:length(oriopt));
  799. elseif strcmp(opt(1:9),'viewfile=')
  800. createview=1;
  801. eqpos=findstr(oriopt,'=');
  802. viewfilename=oriopt(eqpos(1)+1:length(oriopt));
  803. elseif strcmp(opt(1:6),'width=')
  804. eval([ opt ';' ]);
  805. elseif strcmp(opt(1:7),'factor=')
  806. eval([ opt ';' ]);
  807. else
  808. error([ 'Option ' varargin{i} ' not recognized.'])
  809. end
  810. end
  811. warning('LaPrint:general',['You are using the old LaPrint '...
  812. 'syntax. This syntax might not be supported in '...
  813. 'future releases of LaPrint.'])
  814. catch % old usage doesn't work, take new one
  815. % restore preferences / factory defaults
  816. width = LAPRINTOPT.width;
  817. factor = LAPRINTOPT.factor;
  818. scalefonts = LAPRINTOPT.scalefonts;
  819. keepfontprops = LAPRINTOPT.keepfontprops;
  820. asonscreen = LAPRINTOPT.asonscreen;
  821. keepticklabels = LAPRINTOPT.keepticklabels;
  822. mathticklabels = LAPRINTOPT.mathticklabels;
  823. head = LAPRINTOPT.head;
  824. comment = LAPRINTOPT.comment;
  825. caption = LAPRINTOPT.caption;
  826. extrapicture = LAPRINTOPT.extrapicture;
  827. nzeros = LAPRINTOPT.nzeros;
  828. verbose = LAPRINTOPT.verbose;
  829. figcopy = LAPRINTOPT.figcopy;
  830. printcmd = LAPRINTOPT.printcmd;
  831. package = LAPRINTOPT.package;
  832. color = LAPRINTOPT.color;
  833. createview = LAPRINTOPT.createview;
  834. viewfilename = LAPRINTOPT.viewfilename;
  835. processview = LAPRINTOPT.processview;
  836. cmd1 = LAPRINTOPT.cmd1;
  837. cmd2 = LAPRINTOPT.cmd2;
  838. cmd3 = LAPRINTOPT.cmd3;
  839. cmd4 = LAPRINTOPT.cmd4;
  840. cmd5 = LAPRINTOPT.cmd5;
  841. cmd6 = LAPRINTOPT.cmd6;
  842. cmd7 = LAPRINTOPT.cmd7;
  843. cmd8 = LAPRINTOPT.cmd8;
  844. if nargin > 2
  845. if rem(nargin,2)
  846. error('Option names/values must appear in pairs.')
  847. end
  848. for i=1:2:nargin-2
  849. if ~isa(varargin{i},'char')
  850. error('Option name must be a character array.')
  851. end
  852. opt = lower(strrep(varargin{i}(:)',' ',''));
  853. val = varargin{i+1}(:)';
  854. switch opt
  855. case 'options'
  856. if isa(val,'char')
  857. if strcmp(val,'factory')
  858. val = factorysettings;
  859. else
  860. load(val)
  861. val = LAPRINTOPT;
  862. end
  863. end
  864. if ~isa(val,'struct')
  865. error('Value of options must be a structure array.')
  866. end
  867. % no error checking here!
  868. width = val.width;
  869. factor = val.factor;
  870. scalefonts = val.scalefonts;
  871. keepfontprops = val.keepfontprops;
  872. asonscreen = val.asonscreen;
  873. keepticklabels = val.keepticklabels;
  874. mathticklabels = val.mathticklabels;
  875. head = val.head;
  876. comment = val.comment;
  877. caption = val.caption;
  878. extrapicture = val.extrapicture;
  879. nzeros = val.nzeros;
  880. verbose = val.verbose;
  881. figcopy = val.figcopy;
  882. printcmd = val.printcmd;
  883. package = val.package;
  884. color = val.color;
  885. createview = val.createview;
  886. viewfilename = val.viewfilename;
  887. processview = val.processview;
  888. cmd1 = val.cmd1;
  889. cmd2 = val.cmd2;
  890. cmd3 = val.cmd3;
  891. cmd4 = val.cmd4;
  892. cmd5 = val.cmd5;
  893. cmd6 = val.cmd6;
  894. cmd7 = val.cmd7;
  895. cmd8 = val.cmd8;
  896. case 'width'
  897. if ~isa(val,'double')
  898. error('Value of width must be a double.')
  899. end
  900. width = val;
  901. case 'factor'
  902. if ~isa(val,'double')
  903. error('Value of factor must be a double.')
  904. end
  905. factor=val;
  906. case 'scalefonts'
  907. scalefonts = value01(val,opt);
  908. case 'keepfontprops'
  909. keepfontprops = value01(val,opt);
  910. case 'asonscreen'
  911. asonscreen = value01(val,opt);
  912. case 'keepticklabels'
  913. keepticklabels = value01(val,opt);
  914. case 'mathticklabels'
  915. mathticklabels = value01(val,opt) ;
  916. case 'head'
  917. head = value01(val,opt);
  918. case 'comment'
  919. if ~isa(val,'char')
  920. error('Value of comment must be a character array.')
  921. end
  922. comment = val;
  923. case 'caption'
  924. if ~isa(val,'char')
  925. error('Value of caption must be a character array.')
  926. end
  927. caption = val;
  928. case 'extrapicture'
  929. extrapicture = value01(val,opt);
  930. case 'nzeros'
  931. if ~isa(val,'double')
  932. error('Value of nzeros must be a double.')
  933. end
  934. nzeros = val;
  935. case 'verbose'
  936. verbose = value01(val,opt);
  937. case 'figcopy'
  938. figcopy = value01(val,opt);
  939. case 'printcmd'
  940. if ~isa(val,'char')
  941. error('Value of printcmd must be a character array.')
  942. end
  943. printcmd = val;
  944. case 'package'
  945. if ~isa(val,'char')
  946. error('Value of package must be a character array.')
  947. end
  948. val = lower(strrep(val,' ',''));
  949. switch val
  950. case {'graphicx','epsfig'}
  951. % fine
  952. otherwise
  953. error('Value of package is unknown.')
  954. end
  955. package = val;
  956. case 'color'
  957. color = value01(val,opt);
  958. case 'createview'
  959. createview = value01(val,opt);
  960. case 'viewfilename'
  961. if ~isa(val,'char')
  962. error('Value of viewfilename must be a character array.')
  963. end
  964. viewfilename = val;
  965. case 'processview'
  966. processview = value01(val,opt);
  967. case 'cmd1'
  968. if ~isa(val,'char')
  969. error('Value of cmd1 must be a character array.')
  970. end
  971. cmd1 = val;
  972. case 'cmd2'
  973. if ~isa(val,'char')
  974. error('Value of cmd2 must be a character array.')
  975. end
  976. cmd2 = val;
  977. case 'cmd3'
  978. if ~isa(val,'char')
  979. error('Value of cmd3 must be a character array.')
  980. end
  981. cmd3 = val;
  982. case 'cmd4'
  983. if ~isa(val,'char')
  984. error('Value of cmd4 must be a character array.')
  985. end
  986. cmd4 = val;
  987. case 'cmd5'
  988. if ~isa(val,'char')
  989. error('Value of cmd5 must be a character array.')
  990. end
  991. cmd5 = val;
  992. case 'cmd6'
  993. if ~isa(val,'char')
  994. error('Value of cmd6 must be a character array.')
  995. end
  996. cmd6 = val;
  997. case 'cmd7'
  998. if ~isa(val,'char')
  999. error('Value of cmd7 must be a character array.')
  1000. end
  1001. cmd7 = val;
  1002. case 'cmd8'
  1003. if ~isa(val,'char')
  1004. error('Value of cmd8 must be a character array.')
  1005. end
  1006. cmd8 = val;
  1007. otherwise
  1008. error(['Option ''' opt ''' unknown'])
  1009. end % switch opt
  1010. end % for i=3:2:nargin
  1011. end % if nargin > 2
  1012. end % try / catch
  1013. if verbose,
  1014. disp([ 'This is LaPrint, version ' laprintident '.' ]);
  1015. end
  1016. comment = strrep(strrep(comment,'\','\\'),'%','%%');
  1017. caption = strrep(strrep(caption,'\','\\'),'%','%%');
  1018. iscaption = logical(length(caption));
  1019. if nzeros < 3
  1020. warning('LaPrint:general',...
  1021. 'The value of nzero should be >=3. I will use nzeros=3.')
  1022. nzeros=3;
  1023. end
  1024. if processview
  1025. createview=1;
  1026. end
  1027. if mathticklabels
  1028. Do='$';
  1029. else
  1030. Do='';
  1031. end
  1032. % eps- and tex- filenames
  1033. [epsfullnameext,epsbasenameext,epsbasename,epsdirname] = ...
  1034. getfilenames(filename,'eps',verbose);
  1035. [texfullnameext,texbasenameext,texbasename,texdirname] = ...
  1036. getfilenames(filename,'tex',verbose);
  1037. if ~strcmp(texdirname,epsdirname)
  1038. warning('LaPrint:files',['The eps-file and tex-file are '...
  1039. 'placed in different directories.']);
  1040. end
  1041. if createview | processview
  1042. [viewfullnameext,viewbasenameext,viewbasename,viewdirname] = ...
  1043. getfilenames(viewfilename,'tex',verbose);
  1044. if strcmp(texfullnameext,viewfullnameext)
  1045. viewfilename=[ viewfilename '_'];
  1046. warning('LaPrint:files',['The tex- and view-file coincide. '...
  1047. 'I''ll use '' ' viewfilename ' ''. Hope that''s ok.' ])
  1048. end
  1049. [viewfullnameext,viewbasenameext,viewbasename,viewdirname]= ...
  1050. getfilenames(viewfilename,'tex',verbose);
  1051. if ~strcmp(texdirname,viewdirname)
  1052. warning('LaPrint:files',['The eps-file and view-file are '...
  1053. 'placed in different directories.' ])
  1054. end
  1055. end
  1056. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1057. %%%%
  1058. %%%% PART 2 of advanced usage:
  1059. %%%% Create new figure, insert tags, and bookkeep original text
  1060. %%%%
  1061. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1062. % show all
  1063. shh = get(0,'ShowHiddenHandles');
  1064. set(0,'ShowHiddenHandles','on');
  1065. % preparing check for copyobj bug
  1066. figno_ori = figno;
  1067. number_children_ori = length(get(figno_ori,'children'));
  1068. % open new figure (if required) and set properties
  1069. if figcopy
  1070. figno = copyobj(figno,0);
  1071. set(figno,'visible','off')
  1072. set(figno,'Numbertitle','off')
  1073. set(figno,'MenuBar','none')
  1074. pause(0.5)
  1075. end
  1076. if asonscreen
  1077. xlimmodeauto = findobj(figno,'xlimmode','auto');
  1078. xtickmodeauto = findobj(figno,'xtickmode','auto');
  1079. xticklabelmodeauto = findobj(figno,'xticklabelmode','auto');
  1080. ylimmodeauto = findobj(figno,'ylimmode','auto');
  1081. ytickmodeauto = findobj(figno,'ytickmode','auto');
  1082. yticklabelmodeauto = findobj(figno,'yticklabelmode','auto');
  1083. zlimmodeauto = findobj(figno,'zlimmode','auto');
  1084. ztickmodeauto = findobj(figno,'ztickmode','auto');
  1085. zticklabelmodeauto = findobj(figno,'zticklabelmode','auto');
  1086. set(xlimmodeauto,'xlimmode','manual')
  1087. set(xtickmodeauto,'xtickmode','manual')
  1088. set(xticklabelmodeauto,'xticklabelmode','manual')
  1089. set(ylimmodeauto,'ylimmode','manual')
  1090. set(ytickmodeauto,'ytickmode','manual')
  1091. set(yticklabelmodeauto,'yticklabelmode','manual')
  1092. set(zlimmodeauto,'ylimmode','manual')
  1093. set(ztickmodeauto,'ytickmode','manual')
  1094. set(zticklabelmodeauto,'yticklabelmode','manual')
  1095. end
  1096. set(figno,'paperunits','centimeters');
  1097. set(figno,'units','centimeters');
  1098. orip = get(figno,'Position');
  1099. % determine width and height
  1100. if factor <= 0
  1101. factor = width/orip(3);
  1102. end
  1103. latexwidth = width;
  1104. epswidth = latexwidth/factor;
  1105. epsheight = epswidth*orip(4)/orip(3);
  1106. set(figno,'PaperPosition',[0 0 epswidth epsheight ])
  1107. set(figno,'papersize',[epswidth epsheight])
  1108. set(figno,'Position',[orip(1)+0.5 orip(2)-0.5 epswidth epsheight ])
  1109. set(figno,'Name',[ 'To be printed; size: ' num2str(factor,3) ...
  1110. ' x (' num2str(epswidth,3) 'cm x ' num2str(epsheight,3) 'cm)' ])
  1111. % some warnings
  1112. if verbose
  1113. if (epswidth<13) | (epsheight<13*0.75)
  1114. warning('LaPrint:size',['The size of the eps-figure is quite '...
  1115. 'small. The text objects might not be properly set. '...
  1116. 'Reducing ''factor'' might help.'])
  1117. end
  1118. if latexwidth/epswidth<0.5
  1119. warning('LaPrint:size',['The size of the eps-figure is large ' ...
  1120. 'compared to the latex figure. '...
  1121. 'The text size might be too small. '...
  1122. 'Increasing ''factor'' might help.'])
  1123. end
  1124. if (orip(3)-epswidth)/orip(3) > 0.1
  1125. warning('LaPrint:size',['The size of the eps-figure is much '...
  1126. 'smaller than the original '...
  1127. 'figure on screen. Matlab might save different ticks '...
  1128. 'and ticklabels than in the original figure. '...
  1129. 'See option ''asonscreen''.'])
  1130. end
  1131. disp('Strike any key to continue.');
  1132. pause
  1133. end
  1134. %
  1135. % TEXT OBJECTS: modify new figure
  1136. %
  1137. % find all text objects
  1138. hxl = get(findobj(figno,'type','axes'),'xlabel');
  1139. hyl = get(findobj(figno,'type','axes'),'ylabel');
  1140. hzl = get(findobj(figno,'type','axes'),'zlabel');
  1141. hti = get(findobj(figno,'type','axes'),'title');
  1142. hte = findobj(figno,'type','text');
  1143. % array of all text handles
  1144. htext = unique([ celltoarray(hxl) celltoarray(hyl) celltoarray(hzl) ...
  1145. celltoarray(hti) celltoarray(hte)]);
  1146. nt = length(htext);
  1147. % set(celltoarray(hxl),'VerticalAlignment','top');
  1148. % get alignments
  1149. hora = get(htext,'HorizontalAlignment');
  1150. vera = get(htext,'VerticalAlignment');
  1151. align = cell(nt,1);
  1152. for i=1:nt
  1153. align{i} = hora{i}(1);
  1154. switch vera{i}
  1155. case 'top'
  1156. align{i} = [align{i} 't'];
  1157. case 'cap'
  1158. % if ~isempty(get(htext(i),'string'))
  1159. % warning('LaPrint:text',['Using vertical ' ...
  1160. % 'alignment ''top'' instead of ''cap''.'])
  1161. % end
  1162. align{i} = [align{i} 't'];
  1163. case 'middle'
  1164. align{i} = [align{i} 'c'];
  1165. case 'baseline'
  1166. align{i} = [align{i} 'B'];
  1167. case 'bottom'
  1168. align{i} = [align{i} 'b'];
  1169. otherwise
  1170. warning('LaPrint:text',['Vertical alignment ' vera{i} ...
  1171. ' unknown. Using ''c''.'])
  1172. align{i} = [align{i} 'c'];
  1173. end
  1174. end
  1175. % generate new strings and store old ones
  1176. oldstr = get(htext,'string');
  1177. newstr = cell(nt,1);
  1178. basestr = ['s' char(48*ones(1,nzeros-1))];
  1179. extrastr = 0;
  1180. for i=1:nt
  1181. osi = oldstr{i};
  1182. oldstr{i} = ['\setlength{\tabcolsep}{0pt}\begin{tabular}{' ...
  1183. align{i}(1) '}'];
  1184. isnonempty_osi = 0;
  1185. if strcmp(get(get(htext(i),'parent'),'tag'),'legend')
  1186. newstr1 = [];
  1187. if isa(osi,'cell')
  1188. % Legend/cell : Don't use tabular, employ extra strings
  1189. nlines = length(osi);
  1190. if nlines > 1
  1191. newstr{nt+extrastr+nlines-1} = [];
  1192. oldstr{nt+extrastr+nlines-1} = [];
  1193. htext((nt+extrastr+1):(nt+extrastr+nlines-1))=htext(i);
  1194. for line=1:nlines-1
  1195. oldstr{nt+extrastr+line} = ...
  1196. strrep(strrep(osi{line},'\','\\'),'%','%%');
  1197. newstr{nt+extrastr+line} = ...
  1198. overwritetail(basestr,nt+extrastr+line);
  1199. newstr1 = [newstr1; overwritetail(basestr,nt+extrastr+line)];
  1200. end
  1201. extrastr = extrastr+nlines-1;
  1202. end
  1203. if nlines > 0
  1204. oldstr{i} = strrep(strrep(osi{nlines},'\','\\'),'%','%%');
  1205. newstr{i} = overwritetail(basestr,i);
  1206. newstr1 = [newstr1; overwritetail(basestr,i)];
  1207. end
  1208. % replace strings in figure
  1209. set(htext(i),'string',cellstr(newstr1));
  1210. else
  1211. % Legend/matrix : Don't use tabular, employ extra strings
  1212. nlines=size(osi,1);
  1213. if nlines > 1
  1214. newstr{nt+extrastr+nlines-1} = [];
  1215. oldstr{nt+extrastr+nlines-1} = [];
  1216. htext((nt+extrastr+1):(nt+extrastr+nlines-1))=htext(i);
  1217. for line=1:nlines-1
  1218. oldstr{nt+extrastr+line} = ...
  1219. strrep(strrep(osi(line,:),'\','\\'),'%','%%');
  1220. newstr{nt+extrastr+line} = ...
  1221. overwritetail(basestr,nt+extrastr+line);
  1222. newstr1 = [newstr1; overwritetail(basestr,nt+extrastr+line)];
  1223. end
  1224. extrastr = extrastr+nlines-1;
  1225. end
  1226. if nlines > 0
  1227. oldstr{i} = strrep(strrep(osi(nlines,:),'\','\\'),'%','%%');
  1228. newstr{i} = overwritetail(basestr,i);
  1229. newstr1 = [newstr1; overwritetail(basestr,i)];
  1230. end
  1231. % replace strings in figure
  1232. set(htext(i),'string',newstr1);
  1233. end
  1234. else
  1235. % text, not a legend
  1236. if isa(osi,'cell')
  1237. nlines = length(osi);
  1238. if nlines > 1
  1239. for line=1:nlines-1
  1240. oldstr{i}=[oldstr{i} osi{line} '\\'];
  1241. isnonempty_osi = isnonempty_osi+length(osi{line});
  1242. end
  1243. if align{i}(2) == 'B'
  1244. warning('LaPrint:text',['Vertical Alignment ''baseline'' '...
  1245. 'in text with multiple rows might not match.'])
  1246. align{i}(2) = 't';
  1247. end
  1248. end
  1249. if nlines > 0
  1250. oldstr{i} = [oldstr{i} osi{nlines} '\end{tabular}'];
  1251. isnonempty_osi = isnonempty_osi+length(osi{nlines});
  1252. end
  1253. oldstr{i} = strrep(strrep(oldstr{i},'\','\\'),'%','%%');
  1254. if isnonempty_osi
  1255. newstr{i} = overwritetail(basestr,i);
  1256. else
  1257. newstr{i} = '';
  1258. end
  1259. % replace strings in figure
  1260. set(htext(i),'string',newstr{i});
  1261. else
  1262. nlines=size(osi,1);
  1263. if nlines > 1
  1264. for line=1:nlines-1
  1265. oldstr{i} = [oldstr{i} osi(line,:) '\\'];
  1266. isnonempty_osi = isnonempty_osi+length(osi(line,:));
  1267. end
  1268. if align{i}(2) == 'B'
  1269. warning('LaPrint:text',['Vertical Alignment ''baseline'' '...
  1270. 'in text with multiple rows might not match.'])
  1271. align{i}(2) = 't';
  1272. end
  1273. end
  1274. if nlines > 0
  1275. oldstr{i} = [oldstr{i} osi(nlines,:) '\end{tabular}'];
  1276. isnonempty_osi = isnonempty_osi+length(osi(nlines,:));
  1277. end
  1278. oldstr{i} = strrep(strrep(oldstr{i},'\','\\'),'%','%%');
  1279. if isnonempty_osi
  1280. newstr{i} = overwritetail(basestr,i);
  1281. else
  1282. newstr{i} = '';
  1283. end
  1284. % replace string in figure
  1285. set(htext(i),'string',newstr{i});
  1286. end % isa cell
  1287. end % isa legend
  1288. end % for
  1289. ntp = nt+extrastr;
  1290. % Alignment of Legends
  1291. if extrastr > 0
  1292. align{ntp} = [];
  1293. [align{nt+1:ntp}] = deal('lc');
  1294. end
  1295. % get font properties and create commands
  1296. if ntp > 0
  1297. [fontsizecmd{1:ntp}] = deal('');
  1298. [fontanglecmd{1:ntp}] = deal('');
  1299. [fontweightcmd{1:ntp}] = deal('');
  1300. [colorcmd{1:ntp}] = deal('');
  1301. [colorclose{1:ntp}] = deal('');
  1302. end
  1303. selectfontcmd = '';
  1304. if keepfontprops
  1305. % fontsize
  1306. set(htext,'fontunits','points');
  1307. fontsize = get(htext,'fontsize');
  1308. for i=1:ntp
  1309. fontsizecmd{i} = [ '\\fontsize{' num2str(fontsize{i}) '}{' ...
  1310. num2str(fontsize{i}*1.5) '}' ];
  1311. end
  1312. % fontweight
  1313. fontweight = get(htext,'fontweight');
  1314. for i=1:ntp
  1315. switch fontweight{i}
  1316. case 'light'
  1317. fontweightcmd{i} = [ '\\fontseries{l}\\mathversion{normal}' ];
  1318. case 'normal'
  1319. fontweightcmd{i} = [ '\\fontseries{m}\\mathversion{normal}' ];
  1320. case 'demi'
  1321. fontweightcmd{i} = [ '\\fontseries{sb}\\mathversion{bold}' ];
  1322. case 'bold'
  1323. fontweightcmd{i} = [ '\\fontseries{bx}\\mathversion{bold}' ];
  1324. otherwise
  1325. warning('LaPrint:text',['Unknown fontweight: ' fontweight{i} ])
  1326. fontweightcmd{i} = [ '\\fontseries{m}\\mathversion{normal}' ];
  1327. end
  1328. end
  1329. % fontangle
  1330. fontangle = get(htext,'fontangle');
  1331. for i=1:ntp
  1332. switch fontangle{i}
  1333. case 'normal'
  1334. fontanglecmd{i} = [ '\\fontshape{n}' ];
  1335. case 'italic'
  1336. fontanglecmd{i} = [ '\\fontshape{it}' ];
  1337. case 'oblique'
  1338. fontanglecmd{i} = [ '\\fontshape{it}' ];
  1339. otherwise
  1340. warning('LaPrint:text',['unknown fontangle: ' fontangle{i} ])
  1341. fontanglecmd{i} = [ '\\fontshape{n}' ];
  1342. end
  1343. end
  1344. selectfontcmd = '\\selectfont ';
  1345. end
  1346. if color & ntp>0
  1347. col = get(htext,'color');
  1348. bgcol = get(htext,'BackgroundColor');
  1349. ecol = get(htext,'EdgeColor');
  1350. for i=1:ntp
  1351. col0 = get(get(htext(i),'parent'),'color');
  1352. [coli,isc] = char2rgb(col{i},[0 0 0]);
  1353. [bgcoli,isbgc] = char2rgb(bgcol{i},col0);
  1354. [ecoli,isec] = char2rgb(ecol{i},col0);
  1355. if isbgc | isec
  1356. set(htext(i),'BackgroundColor','none')
  1357. set(htext(i),'EdgeColor','none')
  1358. colorcmd{i} = ['\\setlength{\\fboxsep}{2pt}\\fcolorbox[rgb]{' ...
  1359. num2str(ecoli(1)) ',' num2str(ecoli(2)) ',' ...
  1360. num2str(ecoli(3)) '}{' ...
  1361. num2str(bgcoli(1)) ',' num2str(bgcoli(2)) ',' ...
  1362. num2str(bgcoli(3)) '}{\\color[rgb]{' ...
  1363. num2str(coli(1)) ',' num2str(coli(2)) ',' num2str(coli(3)) '}' ];
  1364. colorclose{i} = '}';
  1365. else
  1366. colorcmd{i} = ['\\color[rgb]{' ...
  1367. num2str(coli(1)) ',' num2str(coli(2)) ',' num2str(coli(3)) '}' ];
  1368. end
  1369. end
  1370. end
  1371. %
  1372. % LABELS: modify new figure
  1373. %
  1374. if ~keepticklabels
  1375. % all axes
  1376. hax = celltoarray(findobj(figno,'type','axes'));
  1377. na = length(hax);
  1378. % % try to figure out if we have 3D axes an warn
  1379. % issuewarning = 0;
  1380. % for i=1:na
  1381. % issuewarning = max(issuewarning,is3d(hax(i)));
  1382. % end
  1383. % if issuewarning
  1384. % warning('LaPrint:label',['This seems to be a 3D plot. '...
  1385. % 'The LaTeX labels are possibly incorrect. '...
  1386. % 'The option ''keepticklabels'' might help. '...
  1387. % 'Setting ''figcopy'' to ''off'' might be wise, too.'])
  1388. % end
  1389. % try to figure out if we linear scale with extra factor
  1390. % and determine powers of 10
  1391. powers = NaN*zeros(na,3); % matrix with powers of 10
  1392. for i=1:na % all axes
  1393. allxyz = { 'x', 'y', 'z' };
  1394. for ixyz=1:3 % x,y,z
  1395. xyz = allxyz{ixyz};
  1396. ticklabelmode = get(hax(i),[ xyz 'ticklabelmode']);
  1397. if strcmp(ticklabelmode,'auto')
  1398. tick = get(hax(i),[ xyz 'tick']);
  1399. ticklabel = get(hax(i),[ xyz 'ticklabel']);
  1400. nticklabels = size(ticklabel,1);
  1401. nticks = length(tick);
  1402. if nticks==0,
  1403. powers(i,ixyz)=0;
  1404. nticklabels=0;
  1405. end
  1406. if nticklabels==0,
  1407. powers(i,ixyz)=0;
  1408. end
  1409. for k=1:nticklabels % all ticks
  1410. label = str2num(ticklabel(k,:));
  1411. if length(label)==0,
  1412. powers(i,ixyz) = 0;
  1413. break;
  1414. end
  1415. if ( label==0 ) & ( abs(tick(k))>1e-10 )
  1416. powers(i,ixyz) = 0;
  1417. break;
  1418. end
  1419. if label~=0
  1420. expon = log10(tick(k)/label);
  1421. rexpon = round(expon);
  1422. if abs(rexpon-expon)>1e-10
  1423. powers(i,ixyz) = 0;
  1424. break;
  1425. end
  1426. if isnan(powers(i,ixyz))
  1427. powers(i,ixyz) = rexpon;
  1428. else
  1429. if powers(i,ixyz)~=rexpon
  1430. powers(i,ixyz) = 0;
  1431. break;
  1432. end
  1433. end
  1434. end
  1435. end % k
  1436. else % if 'auto'
  1437. powers(i,ixyz) = 0;
  1438. end % if 'auto'
  1439. end % ixyz
  1440. end % i
  1441. % place text to be replaced by powers on y-axis
  1442. for i=1:na
  1443. allxyz = { 'x', 'y', 'z' };
  1444. ixyz=2; % x,y,z
  1445. xyz = allxyz{ixyz};
  1446. leftright=get(hax(i),'yaxislocation');
  1447. if powers(i,ixyz) & ~is3d(hax(i)) & isequal(leftright,'left')
  1448. powertext = ['ypower' int2str(i)];
  1449. xlimit = get(hax(i),'xlim');
  1450. ylimit = get(hax(i),'ylim');
  1451. htext = text(xlimit(1),ylimit(2)+...
  1452. 0.01*(ylimit(2)-ylimit(1)),...
  1453. powertext);
  1454. set(htext,'VerticalAlignment','Baseline');
  1455. end
  1456. end % i
  1457. % replace all ticklabels and bookkeep
  1458. nxlabel = zeros(1,na);
  1459. nylabel = zeros(1,na);
  1460. nzlabel = zeros(1,na);
  1461. allxyz={ 'x', 'y', 'z' };
  1462. for ixyz=1:3
  1463. xyz = allxyz{ixyz};
  1464. k=1;
  1465. if strcmp(xyz,'y')
  1466. basestr = [ 'v' char(48*ones(1,nzeros-1))];
  1467. else
  1468. basestr = [ xyz char(48*ones(1,nzeros-1))];
  1469. end
  1470. oldtl = cell(na,1);
  1471. newtl = cell(na,1);
  1472. nlabel = zeros(1,na);
  1473. for i=1:na
  1474. % set(hax(i),[ xyz 'tickmode' ],'manual')
  1475. % set(hax(i),[ xyz 'ticklabelmode' ],'manual')
  1476. oldtl{i} = chartocell(get(hax(i),[ xyz 'ticklabel' ]));
  1477. nlabel(i) = length(oldtl{i});
  1478. newtl{i} = cell(1,nlabel(i));
  1479. for j=1:nlabel(i)
  1480. newtl{i}{j} = overwritetail(basestr,k);
  1481. k = k+1;
  1482. oldtl{i}{j} = deblank(strrep(strrep(oldtl{i}{j},'\','\\'),...
  1483. '%','%%'));
  1484. end
  1485. set(hax(i),[ xyz 'ticklabel' ],newtl{i});
  1486. end
  1487. eval([ 'old' xyz 'tl=oldtl;' ]);
  1488. eval([ 'new' xyz 'tl=newtl;' ]);
  1489. eval([ 'n' xyz 'label=nlabel;' ]);
  1490. end
  1491. % determine latex commands for font properties
  1492. if keepfontprops
  1493. % ticklabel font size
  1494. afsize = zeros(na,1);
  1495. for i=1:na
  1496. afsize(i) = get(hax(i),'fontsize');
  1497. end
  1498. if (any(afsize ~= afsize(1) ))
  1499. warning('LaPrint:text',['Different font sizes for axes not '...
  1500. 'supported. All axes will have font size ' ...
  1501. num2str(afsize(1)) '.' ] )
  1502. end
  1503. afsizecmd = [ '\\fontsize{' num2str(afsize(1)) '}{' ...
  1504. num2str(afsize(1)*1.5) '}' ];
  1505. % ticklabel font weight
  1506. afweight = cell(na,1);
  1507. for i=1:na
  1508. afweight{i} = get(hax(i),'fontweight');
  1509. end
  1510. switch afweight{1}
  1511. case 'light'
  1512. afweightcmd = [ '\\fontseries{l}\\mathversion{normal}' ];
  1513. case 'normal'
  1514. afweightcmd = [ '\\fontseries{m}\\mathversion{normal}' ];
  1515. case 'demi'
  1516. afweightcmd = [ '\\fontseries{sb}\\mathversion{bold}' ];
  1517. case 'bold'
  1518. afweightcmd = [ '\\fontseries{bx}\\mathversion{bold}' ];
  1519. otherwise
  1520. warning('LaPrint:text',['unknown fontweight: ' afweight{1} ])
  1521. afweightcmd = [ '\\fontseries{m}\\mathversion{normal}' ];
  1522. end
  1523. for i=1:na
  1524. if ~strcmp(afweight{i},afweight{1})
  1525. warning('LaPrint:text',['Different font weights for axes '...
  1526. 'are not supported. All axes will have font weight ' ...
  1527. afweightcmd '.'])
  1528. end
  1529. end
  1530. % ticklabel font angle
  1531. afangle = cell(na,1);
  1532. for i=1:na
  1533. afangle{i} = get(hax(i),'fontangle');
  1534. end
  1535. switch afangle{1}
  1536. case 'normal'
  1537. afanglecmd = [ '\\fontshape{n}' ];
  1538. case 'italic'
  1539. afanglecmd = [ '\\fontshape{it}' ];
  1540. case 'oblique'
  1541. afanglecmd = [ '\\fontshape{it}' ];
  1542. otherwise
  1543. warning('LaPrint:text',['unknown fontangle: ' afangle{1} ])
  1544. afanglecmd=[ '\\fontshape{n}' ];
  1545. end
  1546. for i=1:na
  1547. if ~strcmp(afangle{i},afangle{1})
  1548. warning('LaPrint:text',['Different font angles for axes not '...
  1549. 'supported. All axes will have font angle ' ...
  1550. afanglecmd '.'] )
  1551. end
  1552. end
  1553. end
  1554. % ticklabel color
  1555. acolcmd='';
  1556. if color
  1557. acol=[];
  1558. allxyz={ 'x', 'y', 'z' };
  1559. acolwarn = 0;
  1560. for i=1:na
  1561. for ixyz=1:3
  1562. xyzcolor = [allxyz{ixyz} 'color'];
  1563. if ~isempty(get(hax(i),[allxyz{ixyz} 'ticklabel']))
  1564. if isempty(acol)
  1565. acol = char2rgb(get(hax(i),xyzcolor));
  1566. else
  1567. if any(char2rgb(get(hax(i),xyzcolor))~=acol)
  1568. acolwarn = 1;
  1569. end
  1570. end
  1571. end
  1572. end
  1573. end
  1574. if acolwarn
  1575. warning('LaPrint:label',['Different colors for axes not ' ...
  1576. 'supported. All ticklabels will have color [ ' ...
  1577. num2str(acol) ' ].' ] )
  1578. end
  1579. if ~isempty(acol)
  1580. if any(acol~=[0 0 0])
  1581. acolcmd = [ '\\color[rgb]{' num2str(acol(1)) ',' ...
  1582. num2str(acol(2)) ',' num2str(acol(3)) '}' ];
  1583. end
  1584. end
  1585. end
  1586. % ticklabel alignment
  1587. xyzalign = char([116*ones(na,1) 114*ones(na,1) 114*ones(na,1)]);
  1588. for i=1:na
  1589. switch get(hax(i),'XAxisLocation')
  1590. case 'top'
  1591. xyzalign(i,1)='B';
  1592. end
  1593. switch get(hax(i),'YAxisLocation')
  1594. case 'right'
  1595. xyzalign(i,2)='l';
  1596. end
  1597. end
  1598. end
  1599. %
  1600. % extra picture environment
  1601. %
  1602. if extrapicture
  1603. unitlength = zeros(na,1);
  1604. ybound = zeros(na,1);
  1605. for i=na:-1:1 % reverse order, to keep axes in original order
  1606. if ~is3d(hax(i))
  1607. xlim = get(hax(i),'xlim');
  1608. ylim = get(hax(i),'ylim');
  1609. axes(hax(i));
  1610. hori = text(ylim(1),ylim(1),[ 'origin' int2str(i) ]);
  1611. set(hori,'VerticalAlignment','bottom');
  1612. set(hori,'Fontsize',2);
  1613. set(hax(i),'Units','normalized')
  1614. pos = get(hax(i),'Position');
  1615. unitlength(i) = pos(3)*epswidth;
  1616. ybound(i) = (pos(4)*epsheight)/(pos(3)*epswidth);
  1617. else
  1618. warning('LaPrint:extrapic',['Option ''extrapicture'' for 3D ' ...
  1619. 'axes not supported.'])
  1620. end
  1621. end
  1622. end
  1623. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1624. %%%%
  1625. %%%% PART 3 of advanced usage:
  1626. %%%% save eps and tex files
  1627. %%%%
  1628. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1629. % prevent matlab print command to modify lims and ticks
  1630. % (empty, if asonscreen=1)
  1631. if ~keepticklabels
  1632. xlimmodeauto = findobj(figno,'xlimmode','auto');
  1633. xtickmodeauto = findobj(figno,'xtickmode','auto');
  1634. xticklabelmodeauto = findobj(figno,'xticklabelmode','auto');
  1635. ylimmodeauto = findobj(figno,'ylimmode','auto');
  1636. ytickmodeauto = findobj(figno,'ytickmode','auto');
  1637. yticklabelmodeauto = findobj(figno,'yticklabelmode','auto');
  1638. zlimmodeauto = findobj(figno,'zlimmode','auto');
  1639. ztickmodeauto = findobj(figno,'ztickmode','auto');
  1640. zticklabelmodeauto = findobj(figno,'zticklabelmode','auto');
  1641. set(xlimmodeauto,'xlimmode','manual')
  1642. set(xtickmodeauto,'xtickmode','manual')
  1643. set(xticklabelmodeauto,'xticklabelmode','manual')
  1644. set(ylimmodeauto,'ylimmode','manual')
  1645. set(ytickmodeauto,'ytickmode','manual')
  1646. set(yticklabelmodeauto,'yticklabelmode','manual')
  1647. set(zlimmodeauto,'ylimmode','manual')
  1648. set(ztickmodeauto,'ytickmode','manual')
  1649. set(zticklabelmodeauto,'yticklabelmode','manual')
  1650. end
  1651. % create eps file
  1652. cmd = strrep(printcmd,'<filename.eps>',epsfullnameext);
  1653. cmd = strrep(cmd,'<filename>',filename);
  1654. cmd = strrep(cmd,'<figurenumber>',int2str(figno));
  1655. if verbose
  1656. disp([ 'executing: '' ' cmd ' ''' ]);
  1657. end
  1658. eval(cmd);
  1659. %
  1660. % create latex file
  1661. %
  1662. if verbose
  1663. disp([ 'writing to: '' ' texfullnameext ' ''' ])
  1664. end
  1665. fid = fopen(texfullnameext,'w');
  1666. % head
  1667. if head
  1668. fprintf(fid,[ '%% This file is generated by the MATLAB m-file' ...
  1669. ' laprint.m. It can be included\n']);
  1670. fprintf(fid,[ '%% into LaTeX documents using the packages ']);
  1671. fprintf(fid,package);
  1672. if color
  1673. fprintf(fid,', color');
  1674. end
  1675. fprintf(fid,[ ' and psfrag.\n' ]);
  1676. fprintf(fid, ['%% It is accompanied by a postscript file. ',...
  1677. 'A sample LaTeX file is:\n']);
  1678. fprintf(fid, '%% \\documentclass{article}\\usepackage{');
  1679. fprintf(fid,package);
  1680. if color
  1681. fprintf(fid,',color');
  1682. end
  1683. fprintf(fid, ',psfrag}\n');
  1684. fprintf(fid,[ '%% \\begin{document}\\input{' ...
  1685. texbasename '}\\end{document}\n' ]);
  1686. fprintf(fid, [ '%% See http://www.mathworks.de/matlabcentral'...
  1687. '/fileexchange/loadFile.do?objectId=4638\n']);
  1688. fprintf(fid, [ '%% for recent versions of laprint.m.\n' ]);
  1689. fprintf(fid, '%%\n');
  1690. fprintf(fid,[ '%% created by: ' 'LaPrint version ' ...
  1691. laprintident '\n' ]);
  1692. fprintf(fid,[ '%% created on: ' datestr(now) '\n' ]);
  1693. fprintf(fid,[ '%% eps bounding box: ' num2str(epswidth) ...
  1694. ' cm x ' num2str(epsheight) ' cm\n' ]);
  1695. fprintf(fid,[ '%% comment: ' comment '\n' ]);
  1696. fprintf(fid,'%%\n');
  1697. else
  1698. fprintf(fid,[ '%% generated by laprint.m\n' ]);
  1699. fprintf(fid,'%%\n');
  1700. end
  1701. % go on
  1702. fprintf(fid,'\\begin{psfrags}%%\n');
  1703. %fprintf(fid,'\\fontsize{10}{12}\\selectfont%%\n');
  1704. fprintf(fid,'\\psfragscanon%%\n');
  1705. % text strings
  1706. numbertext=0;
  1707. for i=1:nt
  1708. numbertext = numbertext+length(newstr{i});
  1709. end
  1710. if numbertext>0,
  1711. fprintf(fid,'%%\n');
  1712. fprintf(fid,'%% text strings:\n');
  1713. for i=1:ntp
  1714. if length(newstr{i})
  1715. alig = strrep(align{i},'c','');
  1716. fprintf(fid,[ '\\psfrag{' newstr{i} '}[' alig '][' alig ']{' ...
  1717. fontsizecmd{i} fontweightcmd{i} fontanglecmd{i} ...
  1718. selectfontcmd colorcmd{i} oldstr{i} colorclose{i} '}%%\n' ]);
  1719. end
  1720. end
  1721. end
  1722. % labels
  1723. if ~keepticklabels
  1724. if ~isempty(acolcmd)
  1725. fprintf(fid,'%%\n');
  1726. fprintf(fid,'%% axes ticklabel color:\n');
  1727. fprintf(fid,[ acolcmd '%%\n' ]);
  1728. end
  1729. if keepfontprops
  1730. fprintf(fid,'%%\n');
  1731. fprintf(fid,'%% axes font properties:\n');
  1732. fprintf(fid,[ afsizecmd afweightcmd '%%\n' ]);
  1733. fprintf(fid,[ afanglecmd '\\selectfont%%\n' ]);
  1734. end
  1735. nxlabel = zeros(1,na);
  1736. nylabel = zeros(1,na);
  1737. nzlabel = zeros(1,na);
  1738. for i=1:na
  1739. nxlabel(i) = length(newxtl{i});
  1740. nylabel(i) = length(newytl{i});
  1741. nzlabel(i) = length(newztl{i});
  1742. end
  1743. allxyz = { 'x', 'y', 'z' };
  1744. for ixyz=1:3
  1745. xyz = allxyz{ixyz};
  1746. eval([ 'oldtl=old' xyz 'tl;' ]);
  1747. eval([ 'newtl=new' xyz 'tl;' ]);
  1748. eval([ 'nlabel=n' xyz 'label;' ]);
  1749. if sum(nlabel) > 0
  1750. fprintf(fid,'%%\n');
  1751. fprintf(fid,[ '%% ' xyz 'ticklabels:\n']);
  1752. for i=1:na
  1753. poss = ['[' xyzalign(i,ixyz) '][' xyzalign(i,ixyz) ']'];
  1754. if nlabel(i)
  1755. if strcmp(get(hax(i),[ xyz 'scale']),'linear')
  1756. % lin scale
  1757. rexpon = powers(i,ixyz);
  1758. if ~rexpon
  1759. % no powers
  1760. for j=1:nlabel(i)
  1761. fprintf(fid,[ '\\psfrag{' newtl{i}{j} '}' poss '{' ...
  1762. Do oldtl{i}{j} Do '}%%\n' ]);
  1763. end
  1764. else
  1765. % powers
  1766. if ixyz==2
  1767. leftright=get(hax(i),'yaxislocation');
  1768. if ~is3d(hax(i)) & isequal(leftright,'left')
  1769. for j=1:nlabel(i)
  1770. fprintf(fid,[ '\\psfrag{' newtl{i}{j} '}' poss '{' ...
  1771. Do oldtl{i}{j} Do '}%%\n' ]);
  1772. end
  1773. fprintf(fid,[ '\\psfrag{ypower' int2str(i) ...
  1774. '}[Bl][Bl]{$\\times 10^{' ...
  1775. int2str(rexpon) '}$}%%\n' ]);
  1776. else
  1777. for j=1:nlabel(i)-1
  1778. fprintf(fid,[ '\\psfrag{' newtl{i}{j} '}' poss '{' ...
  1779. Do oldtl{i}{j} Do '}%%\n' ]);
  1780. end
  1781. if ~is3d(hax(i))
  1782. fprintf(fid,[ '\\psfrag{' newtl{i}{nlabel(i)} ...
  1783. '}' poss '{' ...
  1784. Do oldtl{i}{nlabel(i)} Do '$\\times 10^{'...
  1785. int2str(rexpon) '}$}%%\n' ]);
  1786. else
  1787. fprintf(fid,[ '\\psfrag{' newtl{i}{nlabel(i)} ...
  1788. '}' poss '{\\shortstack{' ...
  1789. Do oldtl{i}{nlabel(i)} Do '\\\\$\\times 10^{'...
  1790. int2str(rexpon) '}\\ $}}%%\n' ]);
  1791. end
  1792. end
  1793. elseif ixyz==1
  1794. for j=1:nlabel(i)-1
  1795. fprintf(fid,[ '\\psfrag{' newtl{i}{j} '}' poss '{' ...
  1796. Do oldtl{i}{j} Do '}%%\n' ]);
  1797. end
  1798. leftright=get(hax(i),'xaxislocation');
  1799. if isequal(leftright,'bottom')
  1800. fprintf(fid,[ '\\psfrag{' newtl{i}{nlabel(i)} ...
  1801. '}' poss '{\\shortstack{' ...
  1802. Do oldtl{i}{nlabel(i)} Do '\\\\$\\times 10^{'...
  1803. int2str(rexpon) '}\\ $}}%%\n' ]);
  1804. else
  1805. fprintf(fid,[ '\\psfrag{' newtl{i}{nlabel(i)} ...
  1806. '}' poss '{\\shortstack{$\\times 10^{' ...
  1807. int2str(rexpon) '}\\ $\\\\' ...
  1808. Do oldtl{i}{nlabel(i)} Do '}}%%\n' ]);
  1809. end
  1810. else
  1811. for j=1:nlabel(i)-1
  1812. fprintf(fid,[ '\\psfrag{' newtl{i}{j} '}' poss '{' ...
  1813. Do oldtl{i}{j} Do '}%%\n' ]);
  1814. end
  1815. fprintf(fid,[ '\\psfrag{' newtl{i}{nlabel(i)} ...
  1816. '}' poss '{' Do oldtl{i}{nlabel(i)} Do ...
  1817. '\\setlength{\\unitlength}{1ex}' ...
  1818. '\\begin{picture}(0,0)\\put(0.5,1.5){$\\times 10^{' ...
  1819. int2str(rexpon) '}$}\\end{picture}}%%\n' ]);
  1820. end
  1821. end % rexpon
  1822. else
  1823. % log scale
  1824. for j=1:nlabel(i)
  1825. fprintf(fid,[ '\\psfrag{' newtl{i}{j} '}' poss '{$10^{' ...
  1826. oldtl{i}{j} '}$}%%\n' ]);
  1827. end % for (log)
  1828. end % if linear
  1829. end % if nlabel(i)
  1830. end
  1831. end
  1832. end
  1833. end
  1834. % extra picture
  1835. if extrapicture
  1836. fprintf(fid,'%%\n');
  1837. fprintf(fid,'%% extra picture(s):\n');
  1838. for i=1:na
  1839. fprintf(fid,[ '\\psfrag{origin' int2str(i) '}[lb][lb]{' ...
  1840. '\\setlength{\\unitlength}{' ...
  1841. num2str(unitlength(i),'%5.5f') 'cm}%%\n' ]);
  1842. fprintf(fid,[ '\\begin{picture}(1,' ...
  1843. num2str(ybound(i),'%5.5f') ')%%\n' ]);
  1844. %fprintf(fid,'\\put(0,0){}%% lower left corner\n');
  1845. %fprintf(fid,[ '\\put(1,' num2str(ybound(i),'%5.5f') ...
  1846. % '){}%% upper right corner\n' ]);
  1847. fprintf(fid,'\\end{picture}%%\n');
  1848. fprintf(fid,'}%%\n');
  1849. end
  1850. end
  1851. % figure
  1852. fprintf(fid,'%%\n');
  1853. fprintf(fid,'%% Figure:\n');
  1854. if iscaption
  1855. fprintf(fid,[ '\\parbox{' num2str(latexwidth) 'cm}{\\centering%%\n' ]);
  1856. end
  1857. if ~scalefonts
  1858. switch package
  1859. case 'epsfig'
  1860. fprintf(fid,[ '\\epsfig{file=' epsbasenameext ',width=' ...
  1861. num2str(latexwidth) 'cm}%%\n' ]);
  1862. case 'graphicx'
  1863. fprintf(fid,[ '\\includegraphics[width=' num2str(latexwidth) ...
  1864. 'cm]{' epsbasenameext '}%%\n' ]);
  1865. otherwise
  1866. warning('LaPrint:general',['Package ''' package ''' not known. '...
  1867. 'I hope you know what you are doing...'])
  1868. end
  1869. else
  1870. switch package
  1871. case 'epsfig'
  1872. fprintf(fid,[ '\\resizebox{' num2str(latexwidth) 'cm}{!}' ...
  1873. '{\\epsfig{file=' epsbasenameext '}}%%\n' ]);
  1874. case 'graphicx'
  1875. fprintf(fid,[ '\\resizebox{' num2str(latexwidth) 'cm}{!}' ...
  1876. '{\\includegraphics{' epsbasenameext '}}%%\n' ]);
  1877. otherwise
  1878. warning('LaPrint:general',['Package ''' package ''' not known. '...
  1879. 'I hope you know what you are doing...'])
  1880. end
  1881. end
  1882. if iscaption
  1883. fprintf(fid,[ '\\caption{' caption '}%%\n' ]);
  1884. fprintf(fid,[ '\\label{fig:' texbasename '}%%\n' ]);
  1885. fprintf(fid,[ '}%%\n' ]);
  1886. end
  1887. fprintf(fid,'\\end{psfrags}%%\n');
  1888. fprintf(fid,'%%\n');
  1889. fprintf(fid,[ '%% End ' texbasenameext '\n' ]);
  1890. fclose(fid);
  1891. set(figno,'Name','Printed by LaPrint')
  1892. if figcopy
  1893. if verbose
  1894. disp('Strike any key to continue.');
  1895. pause
  1896. end
  1897. hlegend = findobj(figno,'Tag','legend');
  1898. set(hlegend,'DeleteFcn','')
  1899. close(figno)
  1900. end
  1901. % check for copyobj-bug --> should be ok now!
  1902. number_children_new = length(get(figno_ori,'children'));
  1903. if number_children_new < number_children_ori
  1904. if figcopy
  1905. warning(['LaPrint:general','Objects in the figure have been '...
  1906. 'deleted! This is due to a bug in matlabs '...
  1907. '''copyopj''. You might want to try to set '...
  1908. '''figcopy'' to ''off''.'])
  1909. else
  1910. warning('LaPrint:general',['Objects in the figure have been '...
  1911. 'deleted!'])
  1912. end
  1913. end
  1914. %
  1915. % create view file
  1916. %
  1917. if createview | processview
  1918. if verbose
  1919. disp([ 'writing to: '' ' viewfullnameext ' ''' ])
  1920. end
  1921. fid = fopen(viewfullnameext,'w');
  1922. if head
  1923. fprintf(fid,[ '%% This file is generated by laprint.m.\n' ]);
  1924. fprintf(fid,[ '%% It calls ' texbasenameext ...
  1925. ', which in turn calls ' epsbasenameext '.\n' ]);
  1926. fprintf(fid,[ '%% Process this file using, e.g.,\n' ]);
  1927. fprintf(fid,[ '%% latex ' viewbasenameext '\n' ]);
  1928. fprintf(fid,[ '%% dvips -o' viewbasename '.ps ' viewbasename ...
  1929. '.dvi\n']);
  1930. fprintf(fid,[ '%% ghostview ' viewbasename '.ps&\n' ]);
  1931. else
  1932. fprintf(fid,[ '%% generated by laprint.m\n' ]);
  1933. end
  1934. fprintf(fid,[ '\\documentclass{article}\n' ]);
  1935. fprintf(fid,[ '\\usepackage{' ]);
  1936. fprintf(fid,package);
  1937. if color
  1938. fprintf(fid,',color');
  1939. end
  1940. fprintf(fid,[ ',psfrag,a4}\n' ]);
  1941. fprintf(fid,[ '\\usepackage[latin1]{inputenc}\n' ]);
  1942. if ~strcmp(epsdirname,viewdirname)
  1943. fprintf(fid,[ '\\graphicspath{{' epsdirname '}}\n' ]);
  1944. end
  1945. fprintf(fid,[ '\\begin{document}\n' ]);
  1946. fprintf(fid,[ '\\pagestyle{empty}\n' ]);
  1947. if strcmp(texdirname,viewdirname)
  1948. fprintf(fid,[ ' \\input{' texbasenameext '}\n' ]);
  1949. else
  1950. fprintf(fid,[ ' \\input{' texdirname texbasenameext '}\n' ]);
  1951. end
  1952. fprintf(fid,[ '\\end{document}\n' ]);
  1953. fclose(fid);
  1954. end
  1955. % process view file
  1956. if processview
  1957. conti=1;
  1958. for i=1:8
  1959. eval(['cmdi=cmd' int2str(i) ';'])
  1960. if ~isempty(cmdi) & conti
  1961. cmd = strrep(cmdi,'<viewfile>',viewbasename);
  1962. cmd = strrep(cmd,'<filename>',filename);
  1963. disp([ 'executing: '' ' cmd ' ''' ]);
  1964. [stat,resu]=system(cmd);
  1965. if stat %| isempty(strfind(resu,'Output written on'))
  1966. disp(resu)
  1967. conti=0;
  1968. end
  1969. end
  1970. end
  1971. if ~conti
  1972. disp('An error occured in the latex/friends sequence.')
  1973. end
  1974. end
  1975. set(0,'ShowHiddenHandles',shh);
  1976. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1977. %%%%
  1978. %%%% functions used
  1979. %%%%
  1980. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1981. function [fullnameext,basenameext,basename,dirname] = getfilenames(...
  1982. filename,extension,verbose);
  1983. % appends an extension to a filename (as '/home/tom/tt') and determines
  1984. % fullnameext: filename with extension and dirname, as '/home/tom/tt.tex'
  1985. % basenameext: filename with extension without dirname, as 'tt.tex'
  1986. % basename : filename without extension without dirname, as 'tt'
  1987. % dirname : dirname without filename, as '/home/tom/'
  1988. % In verbose mode, it asks if to overwrite or to modify.
  1989. %
  1990. [dirname, basename] = splitfilename(filename);
  1991. fullnameext = [ dirname basename '.' extension ];
  1992. basenameext = [ basename '.' extension ];
  1993. if verbose
  1994. quest = (exist(fullnameext)==2);
  1995. while quest
  1996. yn = input([ strrep(strrep(fullnameext,'\','\\'),'%','%%') ...
  1997. ' exists. Overwrite? (y/n) '],'s');
  1998. if strcmp(yn,'y')
  1999. quest = 0;
  2000. else
  2001. filename = input( ...
  2002. [ 'Please enter new filename (without extension .' ...
  2003. extension '): ' ],'s');
  2004. [dirname, basename] = splitfilename(filename);
  2005. fullnameext = [ dirname basename '.' extension ];
  2006. basenameext = [ basename '.' extension ];
  2007. quest = (exist(fullnameext)==2);
  2008. end
  2009. end
  2010. end
  2011. if ( exist(dirname)~=7 & ~strcmp(dirname,[ '.' filesep ]) ...
  2012. & ~strcmp(dirname,filesep) )
  2013. error([ 'Directory ' dirname ' does not exist.' ] )
  2014. end
  2015. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2016. function [dirname,basename] = splitfilename(filename);
  2017. % splits filename into dir and base
  2018. slashpos = findstr(filename,filesep);
  2019. nslash = length(slashpos);
  2020. nfilename = length(filename);
  2021. if nslash
  2022. dirname = filename(1:slashpos(nslash));
  2023. basename = filename(slashpos(nslash)+1:nfilename);
  2024. else
  2025. dirname = pwd;
  2026. nn=length(dirname);
  2027. if ~strcmp(dirname(nn),filesep)
  2028. dirname = [ dirname filesep ];
  2029. end
  2030. basename = filename;
  2031. end
  2032. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2033. function yesno = is3d(haxes);
  2034. % tries to figure out if axes is 3D
  2035. yesno = 0;
  2036. CameraPosition = get(haxes,'CameraPosition');
  2037. CameraTarget = get(haxes,'CameraTarget');
  2038. CameraUpVector = get(haxes,'CameraUpVector');
  2039. if CameraPosition(1)~=CameraTarget(1)
  2040. yesno = 1;
  2041. end
  2042. if CameraPosition(2)~=CameraTarget(2)
  2043. yesno = 1;
  2044. end
  2045. if any(CameraUpVector~=[0 1 0])
  2046. yesno = 1;
  2047. end
  2048. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2049. function b = celltoarray(a);
  2050. % converts a cell of doubles to an array
  2051. if iscell(a),
  2052. b = [];
  2053. for i=1:length(a),
  2054. b = [b a{i}];
  2055. end
  2056. else,
  2057. b = a(:)';
  2058. end
  2059. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2060. function b = chartocell(a)
  2061. % converts a character array into a cell array of characters
  2062. % convert to cell
  2063. if isa(a,'char')
  2064. n = size(a,1);
  2065. b = cell(1,n);
  2066. for j=1:n
  2067. b{j}=a(j,:);
  2068. end
  2069. else
  2070. b = a;
  2071. end
  2072. % convert to char
  2073. n=length(b);
  2074. for j=1:n
  2075. if isa(b{j},'double')
  2076. b{j} = num2str(b{j});
  2077. end
  2078. end
  2079. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2080. function b = overwritetail(a,k)
  2081. % overwrites tail of a by k
  2082. % a,b: strings
  2083. % k: integer
  2084. ks = int2str(k);
  2085. b = [ a(1:(length(a)-length(ks))) ks ];
  2086. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2087. function [rgb,isc] = char2rgb(c,c0)
  2088. % convert color definitions from character to rgb-vector
  2089. isc = 1;
  2090. if ~ischar(c)
  2091. rgb = c;
  2092. else
  2093. switch c
  2094. case {'y','yellow'}
  2095. rgb = [1 1 0];
  2096. case {'m','magenta'}
  2097. rgb = [1 0 1];
  2098. case {'c','cyan'}
  2099. rgb = [0 1 1];
  2100. case {'r','red'}
  2101. rgb = [1 0 0];
  2102. case {'g','green'}
  2103. rgb = [0 1 0];
  2104. case {'b','blue'}
  2105. rgb = [0 0 1];
  2106. case {'w','white'}
  2107. rgb = [1 1 1];
  2108. case {'k','black'}
  2109. rgb = [0 0 0];
  2110. case 'none'
  2111. if nargin==2
  2112. rgb = char2rgb(c0);
  2113. else
  2114. rgb = [1 1 1];
  2115. end
  2116. isc = 0;
  2117. otherwise
  2118. warning('LaPrint:general',['Unknown Color: ''' c ...
  2119. '''. Taking black.'])
  2120. rgb = [0 0 0];
  2121. end
  2122. end
  2123. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2124. function v = value01(val,opt)
  2125. % convert off/on to 0/1
  2126. if nargin==2
  2127. txt = ['Value of ' opt ' must be ''on'' or ''off'''];
  2128. else
  2129. txt = ['Value must be ''on'' or ''off'''];
  2130. end
  2131. if ~isa(val,'char')
  2132. error(txt)
  2133. end
  2134. val = lower(strrep(val,' ',''));
  2135. switch val
  2136. case 'on'
  2137. v = 1;
  2138. case 'off'
  2139. v = 0;
  2140. otherwise
  2141. error(txt)
  2142. end
  2143. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2144. function v = valueyn(val)
  2145. % convert 0/1 to off/on
  2146. if ~isa(val,'double')
  2147. error([ 'Value must be ''0'' or ''1'''])
  2148. end
  2149. switch val
  2150. case 0
  2151. v = 'off';
  2152. case 1
  2153. v = 'on';
  2154. otherwise
  2155. error([ 'Value must be ''0'' or ''1'''])
  2156. end
  2157. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2158. function sethf(hf,LAPRINTHAN,LAPRINTOPT)
  2159. % store in UserData of gui
  2160. set(hf,'UserData',{LAPRINTHAN,LAPRINTOPT})
  2161. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2162. function [LAPRINTHAN,LAPRINTOPT]=gethf(hf)
  2163. % load from UserData of gui
  2164. d=get(hf,'UserData');
  2165. LAPRINTHAN=d{1};
  2166. LAPRINTOPT=d{2};
  2167. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2168. function opt = prefsettings
  2169. if ispref('LaPrint','LAPRINTOPT')
  2170. opt = getpref('LaPrint','LAPRINTOPT');
  2171. else
  2172. opt = [];
  2173. end
  2174. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2175. function opt=factorysettings
  2176. % try to find LaTeX and friends
  2177. if ispc
  2178. try
  2179. latexpath = winqueryreg('HKEY_LOCAL_MACHINE',...
  2180. 'SOFTWARE\MiK\MiKTeX\CurrentVersion\MiKTeX','Install Root');
  2181. latexcmd = [latexpath '\miktex\bin\latex.exe -halt-on-error '...
  2182. '-interaction nonstopmode <viewfile>.tex'];
  2183. dvipscmd = [latexpath '\miktex\bin\dvips.exe -D600 -E* '...
  2184. '-o<viewfile>.eps <viewfile>.dvi'];
  2185. catch % hoping the path variable is properly set
  2186. latexcmd = ['latex.exe -halt-on-error '...
  2187. '-interaction nonstopmode <viewfile>.tex'];
  2188. dvipscmd = ['dvips.exe -D600 -E* '...
  2189. '-o<viewfile>.eps <viewfile>.dvi'];
  2190. end
  2191. epstoolcmd = ['C:\Ghostgum\epstool\bin\epstool.exe '...
  2192. '--bbox --copy --output '...
  2193. '<filename>_final.eps <viewfile>.eps'];
  2194. delcmd = ['del <viewfile>.eps <viewfile>.dvi ',...
  2195. '<viewfile>.aux <viewfile>.log ',...
  2196. '<viewfile>.pfg'];
  2197. gsviewcmd = 'C:\Ghostgum\gsview\gsview32.exe <filename>_final.eps&';
  2198. else % hoping the path variable is properly set
  2199. latexcmd = ['latex -halt-on-error '...
  2200. '-interaction nonstopmode <viewfile>.tex'];
  2201. dvipscmd = ['dvips -D600 -E* '...
  2202. '-o<viewfile>.eps <viewfile>.dvi'];
  2203. epstoolcmd = ['epstool --bbox --copy --output '...
  2204. '<filename>_final.eps <viewfile>.eps'];
  2205. delcmd = ['rm <viewfile>.eps <viewfile>.dvi ',...
  2206. '<viewfile>.aux <viewfile>.log ',...
  2207. '<viewfile>.pfg'];
  2208. gsviewcmd = 'ghostview <filename>_final.eps&';
  2209. end
  2210. vers = version;
  2211. vers = eval(vers(1:3));
  2212. if vers < 6.5
  2213. colorvalue=0;
  2214. else
  2215. colorvalue=1;
  2216. end
  2217. % 'width',12,...
  2218. opt = struct(...
  2219. 'figno',{1},...
  2220. 'filename','unnamed',...
  2221. 'width',10,...
  2222. 'factor',0.8,...
  2223. 'scalefonts',1,...
  2224. 'keepfontprops',0,...
  2225. 'asonscreen',0,...
  2226. 'keepticklabels',0,...
  2227. 'mathticklabels',0,...
  2228. 'head',1,...
  2229. 'comment','',...
  2230. 'caption','',...
  2231. 'extrapicture',0,...
  2232. 'nzeros',3,...
  2233. 'verbose',0,...
  2234. 'figcopy',1,...
  2235. 'printcmd',['print(''-f<figurenumber>'',' ...
  2236. '''-depsc'',''-painters'','...
  2237. '''<filename.eps>'')'],...
  2238. 'package','graphicx',...
  2239. 'color',colorvalue,...
  2240. 'createview',0,...
  2241. 'viewfilename','unnamed_',...
  2242. 'processview',0,...
  2243. 'cmd1',latexcmd,...
  2244. 'cmd2',dvipscmd,...
  2245. 'cmd3',epstoolcmd,...
  2246. 'cmd4',delcmd,...
  2247. 'cmd5',gsviewcmd,...
  2248. 'cmd6','',...
  2249. 'cmd7','',...
  2250. 'cmd8','');
  2251. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2252. function updategui(LAPRINTHAN,LAPRINTOPT)
  2253. % update gui
  2254. set(LAPRINTHAN.figno,'string',num2str(LAPRINTOPT.figno))
  2255. set(LAPRINTHAN.filename,'string',LAPRINTOPT.filename)
  2256. % width, factor, scalefonts
  2257. if LAPRINTOPT.keepfontprops
  2258. set(LAPRINTHAN.keepfontprops,'check','on')
  2259. else
  2260. set(LAPRINTHAN.keepfontprops,'check','off')
  2261. end
  2262. if LAPRINTOPT.asonscreen
  2263. set(LAPRINTHAN.asonscreen,'check','on')
  2264. else
  2265. set(LAPRINTHAN.asonscreen,'check','off')
  2266. end
  2267. if LAPRINTOPT.keepticklabels
  2268. set(LAPRINTHAN.keepticklabels,'check','on')
  2269. else
  2270. set(LAPRINTHAN.keepticklabels,'check','off')
  2271. end
  2272. if LAPRINTOPT.mathticklabels
  2273. set(LAPRINTHAN.mathticklabels,'check','on')
  2274. else
  2275. set(LAPRINTHAN.mathticklabels,'check','off')
  2276. end
  2277. if LAPRINTOPT.head
  2278. set(LAPRINTHAN.head,'check','on')
  2279. else
  2280. set(LAPRINTHAN.head,'check','off')
  2281. end
  2282. % comment, caption
  2283. if LAPRINTOPT.extrapicture
  2284. set(LAPRINTHAN.extrapicture,'check','on')
  2285. else
  2286. set(LAPRINTHAN.extrapicture,'check','off')
  2287. end
  2288. % nzeros
  2289. if LAPRINTOPT.verbose
  2290. set(LAPRINTHAN.verbose,'check','on')
  2291. else
  2292. set(LAPRINTHAN.verbose,'check','off')
  2293. end
  2294. if LAPRINTOPT.figcopy
  2295. set(LAPRINTHAN.figcopy,'check','on')
  2296. else
  2297. set(LAPRINTHAN.figcopy,'check','off')
  2298. end
  2299. % printcmd
  2300. switch LAPRINTOPT.package
  2301. case 'epsfig'
  2302. set(LAPRINTHAN.package_epsfig,'check','on')
  2303. set(LAPRINTHAN.package_graphicx,'check','off')
  2304. case 'graphicx'
  2305. set(LAPRINTHAN.package_epsfig,'check','off')
  2306. set(LAPRINTHAN.package_graphicx,'check','on')
  2307. end
  2308. if LAPRINTOPT.color
  2309. set(LAPRINTHAN.color,'check','on')
  2310. else
  2311. set(LAPRINTHAN.color,'check','off')
  2312. end
  2313. if LAPRINTOPT.createview
  2314. set(LAPRINTHAN.createview,'check','on')
  2315. else
  2316. set(LAPRINTHAN.createview,'check','off')
  2317. end
  2318. % viewfilename
  2319. if LAPRINTOPT.processview
  2320. set(LAPRINTHAN.processview,'check','on')
  2321. else
  2322. set(LAPRINTHAN.processview,'check','off')
  2323. end
  2324. % cmd1, cmd2, cmd3, cmd4, cmd5, cmd6, cmd7, cmd8
  2325. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2326. function txt = helptext()
  2327. % help text
  2328. txt={...
  2329. '',...
  2330. ['LAPRINT prints a figure for inclusion in LaTeX documents. ',...
  2331. 'It creates an eps-file and a tex-file. The tex-file contains the ',...
  2332. 'annotation of the figure such as titles, labels and texts. The ',...
  2333. 'eps-file contains the non-text part of the figure and is called ',...
  2334. 'by the tex-file. The main advantage of using LaPrint ',...
  2335. 'is that the annotation can be neatly (e.g., including math ',...
  2336. 'mode and fancy font constructs) set within LaTeX.'],...
  2337. '',...
  2338. 'Prerequisites:',...
  2339. '~~~~~~~~~~~~~~',...
  2340. ['Matlab 6.1 or above is required. To process the LaTeX file, a ',...
  2341. 'LaTeX compiler (including the packages ''graphicx'' and ',...
  2342. '''psfrag'') and a dvi-to-postscript converter (like dvips) '...
  2343. 'is required. Optional tools are a postscript-viewer ',...
  2344. '(like ghostview), a postscript bounding box converter ',...
  2345. '(like epstool) and the LaTeX packages color ',...
  2346. 'and epsfig.'],...
  2347. '',...
  2348. 'Installation:',...
  2349. '~~~~~~~~~~~~~',...
  2350. ['LaPrint comes as a single m-file, which has to be placed ',...
  2351. 'somewhere in the Matlab search path. If you want LaPrint to ',...
  2352. 'call LaTeX and friends, the (system dependent) executables have ',...
  2353. 'to be defined using the GUI (see below).'],...
  2354. '',...
  2355. 'An example to get started:',...
  2356. '~~~~~~~~~~~~~~~~~~~~~~~~~~',...
  2357. ['It is recommended to switch off the Matlab TeX ',...
  2358. 'interpreter before creating a graphics to be processed by ',...
  2359. 'LaPrint:'],...
  2360. ' >> set(0,''DefaultTextInterpreter'',''none'')',...
  2361. 'Create an example graphics using',...
  2362. ' >> figure(1), clf',...
  2363. ' >> plot([1 2])',...
  2364. ' >> xlabel(''$x$'')',...
  2365. ' >> ylabel(''A straight line $f(x)=\alpha x + \beta$'')',...
  2366. ' >> text(1.1,1.9,{''\textbf{This figure is not exiting.}'',...',...
  2367. ' ''(but it shows some features of \texttt{laprint})''})',...
  2368. ['Note that the text uses LaTeX constructs like ''$.$'', ',...
  2369. '''\alpha'' and ''\textbf{}''. You can employ the full LaTeX ',...
  2370. 'repertoire here.'],...
  2371. ['Open the LaPrint graphical user interface (GUI) ',...
  2372. '(if you haven''t already done so), by typing'],...
  2373. ' >> laprint',...
  2374. ['Check if the GUI points to Figure Number 1, ',...
  2375. 'and save the graphics by pressing ''Go!''. ',...
  2376. 'This creates the files ''unnamed.tex'' and ''unnamed.eps''. ',...
  2377. 'These can be included in a LaTeX document as follows:'],...
  2378. ' % This is the LaTeX document testdoc.tex',...
  2379. ' \documentclass{article}',...
  2380. ' \usepackage{graphicx,color,psfrag}',...
  2381. ' \begin{document}',...
  2382. ' Here comes a Matlab figure created with \texttt{laprint}:\\',...
  2383. ' \input{unnamed}',...
  2384. ' \end{document}',...
  2385. ['This document can be compiled with LaTeX (to create ',...
  2386. '''testdoc.dvi'') and converted to postscript (to create ',...
  2387. '''testdoc.ps''). The document ''testdoc.ps'' will contain the ',...
  2388. 'Matlab graphics with LaTeX annotation. Observe that the ',...
  2389. 'figure is 12cm wide and that the fonts are scaled to 80% ',...
  2390. 'of their original size. This is the default behaviour of ',...
  2391. 'LaPrint, which can be adjusted using ''Options'' in the ',...
  2392. 'GUI menu bar (as will explained below).'],...
  2393. '',...
  2394. ['Instead of using the GUI you can also call LaPrint ',...
  2395. 'from the command line (or from an m-file) as follows:'],...
  2396. ' >> laprint(1,''unnamed'')',...
  2397. '',...
  2398. 'This is what LaPrint does:',...
  2399. '~~~~~~~~~~~~~~~~~~~~~~~~~~',...
  2400. 'Basically, LaPrint performs the following tasks:',...
  2401. ' - Take a preliminary copy of the figure. ',...
  2402. ' - In the preliminary figure, replace all text objects by tags.',...
  2403. [' - Save the preliminary figure (with tags) as an eps-file using ',...
  2404. 'the Matlab ''print'' command.'],...
  2405. [' - Create a tex-file which calls the eps-file (using the ',...
  2406. '''graphicx'' package) and replaces ',...
  2407. 'the tags by the original text (using the ''psfrag'' package).'],...
  2408. '',...
  2409. ['It is instructive to have a look into the tex-file ',...
  2410. '(''unnamed.tex'' in the above example). ',...
  2411. 'If your graphics contains huge amounts of LaTeX-code, then ',...
  2412. 'you might also consider editing the tex-file with your ',...
  2413. 'favourate LaTeX editor. You have however to be carefull, ',...
  2414. 'because LaPrint (using default settings) doesn''t care ',...
  2415. 'overwriting files.'],...
  2416. '',...
  2417. 'Using the LaPrint GUI: ',...
  2418. '~~~~~~~~~~~~~~~~~~~~~~',...
  2419. ['The behaviour of LaPrint can be controlled by various settings ',...
  2420. 'and options. Using the GUI, these can be set using the ''Options'' ',...
  2421. 'entry in the menu bar. Using LaPrint from the command line, ' ,...
  2422. 'these can be set by extra input arguments in the form of ',...
  2423. 'option/value pairs. In the following, the options are explained ',...
  2424. 'in some detail based on the GUI. Later, a table with the ',...
  2425. 'command line option/value pairs is given.'],...
  2426. '',...
  2427. 'In the main LaPrint window you can specify',...
  2428. ['-- the number of the Matlab figure to be saved (this must be ',...
  2429. 'the handle of an open Matlab window) and '],...
  2430. ['-- the basename of the files to be saved (for instance, if ',...
  2431. 'the basename is ''unnamed'', then ''unnamed.tex'' and ',...
  2432. '''unnamed.eps'' are created;).'],...
  2433. '',...
  2434. 'Via the menu bar you can control the following settings:',...
  2435. '',...
  2436. 'Options --> Sizes and Scalings ...',...
  2437. '',...
  2438. 'This opens a window where you can specify ',...
  2439. '-- the width (in cm) of the graphics in the LaTeX document;',...
  2440. '-- a scaling factor and',...
  2441. '-- whether you want fonts to be scaled.',...
  2442. ['The width controls the size of the graphics. Its height ',...
  2443. 'is computed such that the ratio of width to height of the ',...
  2444. 'figure on screen is retained. The factor controls the ',...
  2445. '''denseness'' of the graphics. For instance, if the width is ',...
  2446. 'w=12 and the factor is f=0.8, then the graphics in the ',...
  2447. 'eps-file will have width w/f=15 cm and the tex-file ',...
  2448. 'scales it down to 12 cm. This means that lines become thinner ',...
  2449. 'and fonts become smaller (as compared to w=12; f=1.0). ',...
  2450. 'Good values for papers are f=0.8 to f=1.0, ',...
  2451. 'and f=1.5 is a good value for presentations. ',...
  2452. 'Switching font scaling off only scales the graphics. ',...
  2453. 'You may want to experiment with some w/f/scalefont combinations ',...
  2454. 'to find out your personal preference. '],...
  2455. '',...
  2456. 'Options --> Translate Matlab Font Properties to LaTeX ',...
  2457. '',...
  2458. ['This option can be switched on/off. When off, all text ',...
  2459. 'will be set using the LaTeX font which is active while ',...
  2460. 'entering the tex-file (Matlab font settings are ignored). When ',...
  2461. 'on, Matlab font settings are translated to LaTeX font ',...
  2462. 'settings.'],...
  2463. '',...
  2464. 'Options --> Print Limits and Ticks as on Screen',...
  2465. '',...
  2466. ['This option can be switched on/off. When on, the axes ',...
  2467. 'limits and ticks are frozen. They appear in the LaTeX ',...
  2468. 'document as on screen. When off, they are adapted by ',...
  2469. 'Matlab.'],...
  2470. '',...
  2471. 'Options --> Keep Tick Labels within eps File',...
  2472. '',...
  2473. ['This option can be switched on/off. When on, the tick ',...
  2474. 'labels aren''t replaced by their LaTeX equivalents. This is ',...
  2475. 'useful for some 3D-plots.'],...
  2476. '',...
  2477. 'Options --> Set Tick Labels in LaTeX Math Mode',...
  2478. '',...
  2479. ['This option can be switched on/off. When on, the tick ',...
  2480. 'labels are surrounded by a ''$''.'],...
  2481. '',...
  2482. 'Options --> Equip the tex File with a Head',...
  2483. '',...
  2484. ['This option can be switched on/off. When on, the tex-file ',...
  2485. 'is equipped with a header with a bunch of comments (date, files, ',...
  2486. 'example, comment text,...).'],...
  2487. '',...
  2488. 'Options --> Comment in the Head of the tex File ...',...
  2489. '',...
  2490. ['This opens a window where you can specify a comment to be ',...
  2491. 'placed in the header of the tex file.'],...
  2492. '',...
  2493. 'Options --> Place a LaTeX caption in the tex File ...',...
  2494. '',...
  2495. ['This opens a window where you can enter a caption text. If this ',...
  2496. 'caption text is nonempty, it is placed as a \caption{} ',...
  2497. 'into the tex-file. Thus the text will appear in the LaTeX ',...
  2498. 'document. In addition a \label{} is placed in the tex-file ',...
  2499. 'which can be used to refer to the graphics. The label will ',...
  2500. 'be fig: followed by the basename of the files, e.g., ',...
  2501. '\label{fig:unnamed}.'],...
  2502. '',...
  2503. 'Options --> Place an Extra Picture in each Axes',...
  2504. '',...
  2505. ['This option can be switched on/off. When on, each axes in the ',...
  2506. 'figure is equipped with an empty LaTeX ''picture'' environment. ',...
  2507. 'It can be used to place some additional material into the ',...
  2508. 'figure by editing the tex-file.'],...
  2509. '',...
  2510. 'Options --> Length of the psfrag Replacement Strings ...',...
  2511. '',...
  2512. ['This opens a window where you can enter the length of the ',...
  2513. 'psfrag tags. If you have huge amounts of text, the default ',...
  2514. 'length of 3 might not suffice.'],...
  2515. '',...
  2516. 'Options --> Call LaPrint in verbose mode',...
  2517. '',...
  2518. ['This option can be switched on/off. When on, LaPrint issues ',...
  2519. 'some messages and warns before overwriting files.'],...
  2520. '',...
  2521. 'Options --> Copy Figure and Modify that Copy',...
  2522. '',...
  2523. ['This option can be switched on/off. When on, LaPrint takes ',...
  2524. 'a copy of the figure to be printed and places its tags into ',...
  2525. 'that copy. When done, the copy is deleted. When off, the ',...
  2526. 'figure is messed up by tags. It gets unusable, but you can see ',...
  2527. 'what LaPrint is doing. Besides, there are bugs in the Matlab ',...
  2528. '''copyobj'' command. If these show up, this option is useful.'],...
  2529. '',...
  2530. 'Options --> Matlab Print Command ...',...
  2531. '',...
  2532. ['This opens a window where you can enter the Matlab command to ',...
  2533. 'save the graphics in an eps-file. You can modify the standard ',...
  2534. 'print command to include or remove options (like ''-loose'') ',...
  2535. 'or employ a different command (like exportfig). '],...
  2536. '',...
  2537. 'Options --> Matlab Graphics Package',...
  2538. '',...
  2539. 'You can chose between ''graphicx'' and ''epsfig''.',...
  2540. '',...
  2541. 'Options --> Use LaTeX ''color'' package',...
  2542. '',...
  2543. ['This option can be switched on/off. When on, LaPrint places ',...
  2544. 'color commands into the tex file to optain colored text.'],...
  2545. '',...
  2546. 'Options --> View File ... --> Create a View File',...
  2547. '',...
  2548. ['This option can be switched on/off. When on, LaPrint creates ',...
  2549. 'a third file (the view-file), which is a complete LaTeX ',...
  2550. 'document showing the graphics. You can process this file ',...
  2551. 'with your favourate LaTeX- and dvi-to-postscript compiler. ',...
  2552. 'This is useful to have a quick look at the result and to ',...
  2553. 'create a futher eps-file containing everything (see below). ',...
  2554. 'The process of compiling the view-file can be automated using ',...
  2555. 'the options described below.'],...
  2556. '',...
  2557. 'Options --> View File ... --> Name of the View File',...
  2558. '',...
  2559. ['This opens a window where you can enter the name of the ',...
  2560. 'view-file to be created.'],...
  2561. '',...
  2562. 'Options --> View File ... --> Process the View File',...
  2563. '',...
  2564. ['This option can be switched on/off. When on, LaPrint ',...
  2565. 'calls the LaTeX compiler and its friends to process the ',...
  2566. 'view file. The names of the executables to be used and ',...
  2567. 'their syntax can be set using the following option. '],...
  2568. '',...
  2569. ['Options --> View File ... --> Executables for processing ',...
  2570. 'View File'],...
  2571. '',...
  2572. ['This opens a window where you can enter the names of up to 8 ',...
  2573. 'system commands to process the view-file. If you have less than 8 ',...
  2574. 'programs, you can leave the some of the fields empty. In all ',...
  2575. 'commands, LaPrint internally replaces the tag ''<viewfile>'' ',...
  2576. 'by the basename of the viewfile and the tag <filename> by ',...
  2577. 'the basename specified in the main LaPrint window. ',...
  2578. 'In following example you have to add the paths, if the ',...
  2579. 'commands are not in the system search path.'],...
  2580. '',...
  2581. 'To create and view a ps document:',...
  2582. ' cmd1: latex <viewfile>.tex',...
  2583. ' cmd2: dvips -o<viewfile>.ps <viewfile>.dvi',...
  2584. ' cmd3: gsview32 <viewfile>.ps (ghostview for Unix)',...
  2585. '',...
  2586. '',...
  2587. 'Preferences:',...
  2588. '~~~~~~~~~~~~',...
  2589. ['All options and settings of LaPrint can be ',...
  2590. '(internally and externally) stored ',...
  2591. 'in ''Preferences''. Suppose that you have changed, via ',...
  2592. 'the ''Options'' menu bar entry, the settings of LaPrint. ',...
  2593. 'You can make these settings to your preferred (default) ',...
  2594. 'settings by chosing'],...
  2595. '',...
  2596. 'Preferences --> Set Preferences to Current Settings',...
  2597. '',...
  2598. ['This means that future sessions of LaPrint load these ',...
  2599. 'settings on startup. You can also manually reload these ',...
  2600. 'settings by chosing'],...
  2601. '',...
  2602. 'Preferences --> Get Preferences',...
  2603. '',...
  2604. ['LaPrint has built-in (factory default) preferences, ',...
  2605. 'which you see when using ',...
  2606. 'LaPrint the first time. You can restore these defaults ',...
  2607. 'by chosing'],...
  2608. '',...
  2609. 'Preferences --> Get Factory Defaults',...
  2610. '',...
  2611. ['If you want your personal preferences be completely removed ',...
  2612. '(switching back to factory defaults on startup), you should ',...
  2613. 'chose'],...
  2614. '',...
  2615. 'Preferences --> Remove Preferences',...
  2616. '',...
  2617. ['If you have multiple projects running and want to use different ',...
  2618. 'settings simultaneously, you can save/load preferences ',...
  2619. 'to/from mat-files by chosing'],...
  2620. '',...
  2621. 'Preferences --> Save Current Settings to a File ',...
  2622. 'Preferences --> Load Settings from a File ',...
  2623. '',...
  2624. 'These open a new window asking for the name of a .mat file.',...
  2625. '',...
  2626. 'Using LaPrint from the command line:',...
  2627. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~',...
  2628. ['When using LaPrint from the command line (or from an m-file), ',...
  2629. 'the following syntax is required:'],...
  2630. '',...
  2631. ' laprint(figno,filename)',...
  2632. ' laprint(figno,filename,opta,vala,optb,valb,..)',...
  2633. '',...
  2634. 'where',...
  2635. ' figno : integer, figure to be printed',...
  2636. ' filename : string (character array), basename of files',...
  2637. ' to be created',...
  2638. ' opta,vala,.. : option and value pairs, where opta is one',...
  2639. ' of the following options and vala is',...
  2640. ' the corresponding value.',...
  2641. '',...
  2642. ['When calling LaPrint from the command line without ',...
  2643. 'option/value pairs, it uses the same '],...
  2644. ['settings/options as the GUI on startup. This means that ',...
  2645. 'it uses'],...
  2646. ['-- the factory default settings (if you havn''t ',...
  2647. 'stored your personal preferences using the GUI) or '],...
  2648. '-- your personal preferences. ',...
  2649. 'The factory default settings can be enforced by typing ',...
  2650. ' laprint(figno,filename,''options'',''factory'')',...
  2651. ['These settings can be overwritten by option/value pairs ',...
  2652. 'as explained in the following table.'],...
  2653. '',...
  2654. 'option |class/val.| remark',...
  2655. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~',...
  2656. '''width'' | <double> | width of the figure in the LaTeX',...
  2657. ' | | document (in cm).',...
  2658. '''factor'' | <double> | factor by which the figure in ',...
  2659. ' | | the LaTeX document is smaller than ',...
  2660. ' | | the figure in the postscript file.',...
  2661. '''scalefonts'' |''on''/''off''| scales the fonts with the ',...
  2662. ' | | figure (see option ''factor'').',...
  2663. '''keepfontprops'' |''on''/''off''| translates MATLAB font',...
  2664. ' | | properties (size, width, angle) into',...
  2665. ' | | corresponding LaTeX font properties.',...
  2666. '''asonscreen'' |''on''/''off''| prints ticks and lims ',...
  2667. ' | | ''as on screen''.',...
  2668. '''keepticklabels''|''on''/''off''| keeps the tick labels within',...
  2669. ' | | the eps-file (not using LaTeX).',...
  2670. '''mathticklabels''|''on''/''off''| tick labels are set in LaTeX',...
  2671. ' | | math mode',...
  2672. '''head'' |''on''/''off''| places a commenting header in ',...
  2673. ' | | the tex-file.',...
  2674. '''comment'' | <string> | places the comment <string> into',...
  2675. ' | | the header of the tex-file.',...
  2676. '''caption'' | <string> | adds \caption{<string>} and',...
  2677. ' | | \label{fig:<filename>} to the',...
  2678. ' | | tex-file.',...
  2679. '''extrapicture'' |''on''/''off''| adds empty picture environments',...
  2680. ' | | to the axes.',...
  2681. '''nzeros'' | <int> | uses replacement strings of',...
  2682. ' | | length <int> in the eps-file.',...
  2683. '''verbose'' |''on''/''off''| verbose mode; asks before',...
  2684. ' | | overwriting files and issues some ',...
  2685. ' | | more messages.',...
  2686. '''figcopy'' |''on''/''off''| directly modifies the original',...
  2687. ' | | figure.',...
  2688. '''printcmd'' | <string> | uses ''<string>'' as Matlab print',...
  2689. ' | | command.',...
  2690. '''package'' | <string> | uses the LaTeX graphics package',...
  2691. ' | | ''<string>''. Possible values are',...
  2692. ' | | ''graphicx'' and ''epsfig''.',...
  2693. '''color'' |''on''/''off''| uses colored fonts (using the',...
  2694. ' | | LaTeX ''color'' package).',...
  2695. '''createview'' |''on''/''off''| creates a view-file, which ',...
  2696. ' | | calls the tex-file.',...
  2697. '''viewfilename'' | <string> | Basename of the view-file.',...
  2698. '''processview'' |''on''/''off''| processes the view-file ',...
  2699. ' | | by LaTeX and friends.',...
  2700. '''cmd1'' | <string> | 1st Command in the sequence of',...
  2701. ' | | LaTeX and friends (enter an empty',...
  2702. ' | | string to skip this command).',...
  2703. '''cmd2'' | <string> | 2nd LaTeX/friend Command ',...
  2704. '''cmd3'' | <string> | 3rd LaTeX/friend Command ',...
  2705. '''cmd4'' | <string> | 4th LaTeX/friend Command ',...
  2706. '''cmd5'' | <string> | 5th LaTeX/friend Command ',...
  2707. '''cmd6'' | <string> | 6th LaTeX/friend Command ',...
  2708. '''cmd7'' | <string> | 7th LaTeX/friend Command ',...
  2709. '''cmd8'' | <string> | 8th LaTeX/friend Command ',...
  2710. '''options'' | <string> | This option can be used to ',...
  2711. ' | | employ project-dependent ',...
  2712. ' | | preferences as follows:',...
  2713. ' | | 1) Save your preferences to a file ',...
  2714. ' | | using the GUI:',...
  2715. ' | | Preferences --> ',...
  2716. ' | | Save Current Settings to a file',...
  2717. ' | | 2) Reload these preferences',...
  2718. ' | | with laprint:',...
  2719. ' | | >> laprint(1,''unnamed'',..',...
  2720. ' | | ''options'',<string>)',...
  2721. ' | | where <string> is the name of ',...
  2722. ' | | the mat-file with preferences.',...
  2723. '',...
  2724. '',...
  2725. ' ...................... ENJOY ! .......................',...
  2726. '',...
  2727. };