Rewrote name2tex routine and fixed bug.
parent
1fe3e4bc77
commit
d02171080c
|
@ -23,83 +23,53 @@ if nargin<2
|
||||||
info = 0;
|
info = 0;
|
||||||
end
|
end
|
||||||
|
|
||||||
if iscell(name)
|
if info
|
||||||
nn = length(name);
|
if iscell(name)
|
||||||
tex = cell(nn,1);
|
nn = length(name);
|
||||||
else
|
else
|
||||||
nn = 1;
|
nn = 1;
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for i=1:nn
|
tex = regexprep(name, '_', '\\_');
|
||||||
if info
|
|
||||||
|
if info
|
||||||
|
for i=1:nn
|
||||||
if iscell(name)
|
if iscell(name)
|
||||||
tex(i) = {name{i}};
|
texname = tex{i};
|
||||||
id = findstr(name{i},'_');
|
|
||||||
len = length(tex{i});
|
|
||||||
else
|
else
|
||||||
tex = name;
|
texname = tex;
|
||||||
id = findstr(name,'_');
|
|
||||||
len = length(tex);
|
|
||||||
end
|
end
|
||||||
if isempty(id)
|
idx = strfind(texname,'_');
|
||||||
continue
|
ndx = length(idx);
|
||||||
end
|
ntx = length(texname);
|
||||||
n = length(id);
|
if ndx
|
||||||
if id(1)==1
|
gotonextcondition = 1;
|
||||||
if iscell(name)
|
if isequal(ndx,1) && ~isequal(idx,2) && ~isequal(idx,ntx)
|
||||||
tex(i) = {['\_', tex{i}(2:end)]};
|
texname = [ texname(1:idx-2) '_{' texname(idx+1:end) '}'];
|
||||||
else
|
gotonextcondition = 0;
|
||||||
tex = ['\_', tex(2:end)];
|
|
||||||
end
|
end
|
||||||
if n>1
|
if gotonextcondition && isequal(ndx,2) && ~isequal(idx(1),2) && isequal(idx(2),ntx)
|
||||||
id = id(2:end)+1;
|
texname = [ texname(1:idx(1)-2) '_{' texname(idx(1)+1:end) '}' ];
|
||||||
n = n-1;
|
gotonextcondition = 0;
|
||||||
len = len+1;
|
|
||||||
else
|
|
||||||
continue
|
|
||||||
end
|
end
|
||||||
end
|
if gotonextcondition && isequal(ndx,2) && idx(2)<ntx
|
||||||
if id(end)==len
|
texname = [ texname(1:idx(2)-2) '_{' texname(idx(2)+1:end) '}' ];
|
||||||
if iscell(name)
|
gotonextcondition = 0;
|
||||||
tex(i) = {[tex{i}(1:end-1) '\_']};
|
|
||||||
else
|
|
||||||
tex = [tex(1:end-1) '\_'];
|
|
||||||
end
|
end
|
||||||
if n>1
|
if gotonextcondition && ndx>2
|
||||||
id = id(1:end-1);
|
if idx(end)<ntx
|
||||||
n = n-1;
|
texname = [ texname(1:idx(end)-2) '_{' texname(idx(end)+1:end) '}' ];
|
||||||
else
|
else
|
||||||
continue
|
texname = [ texname(1:idx(end-1)-2) '_{' texname(idx(end-1)+1:end) '}' ];
|
||||||
end
|
|
||||||
end
|
|
||||||
if n==1
|
|
||||||
if iscell(name)
|
|
||||||
tex(i) = {[ tex{i}(1:(id-1)) '_{' tex{i}((id+1):end) '}' ]};
|
|
||||||
else
|
|
||||||
tex = [ tex(1:(id-1)) '_{' tex((id+1):end) '}' ];
|
|
||||||
end
|
|
||||||
continue
|
|
||||||
else
|
|
||||||
for j=1:n-1
|
|
||||||
if iscell(name)
|
|
||||||
tex(i) = {[tex{i}(1:id(j)-1) '\_' tex{i}((id(j)+1):end)]};
|
|
||||||
else
|
|
||||||
tex = [tex(1:id(j)-1) '\_' tex((id(j)+1):end)];
|
|
||||||
end
|
end
|
||||||
id = id(2:end)+1;
|
|
||||||
end
|
end
|
||||||
if iscell(name)
|
if iscell(name)
|
||||||
tex(i) = {[tex{i}(1:(id-1)) '_{' tex{i}((id+1):end) '}']};
|
tex(i) = { texname };
|
||||||
else
|
else
|
||||||
tex = [tex(1:(id-1)) '_{' tex((id+1):end) '}'];
|
tex = texname;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
|
||||||
if iscell(name)
|
|
||||||
tex(i) = {strrep(name{i}, '_', '\_')};
|
|
||||||
else
|
|
||||||
tex = strrep(name, '_', '\_');
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue