-
Notifications
You must be signed in to change notification settings - Fork 0
/
tfInit.m
42 lines (34 loc) · 834 Bytes
/
tfInit.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
function tfInit(name)
% initialize TikZ figure
%
% tfInit
% tfInit(name)
%
% name: identifier of the figure window used for preview, and basis of the
% name of the file generated by tfRender
%
% If no name is specified, it is attempted to construct one from the name
% of the calling script or function.
% determine name
if nargin == 0
[ST,I] = dbstack;
if size(ST, 1) < I + 1
error('Cannot determine name of figure!')
end
[~, name] = fileparts(ST(I + 1).name);
end
% check
if ~isempty(intersect(name, ' '))
error('Invalid figure name "%s"!', name)
end
fprintf('tfInit %s\n', name)
% manage figure window
try close(name), catch, end
figure
set(gcf, 'Name', name)
% initialize TikZ-LaTeX code
tf_set('code', {});
% prepare temporary directory
temp = tempname;
mkdir(temp)
tf_set('temp', temp)