function tex = name2tex(name, info) % --*-- Unitary tests --*-- % Converts plain text name into tex name. % Copyright (C) 2013 Dynare Team % % This file is part of Dynare. % % Dynare is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation, either version 3 of the License, or % (at your option) any later version. % % Dynare is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . if nargin<2 info = 0; end if info if iscell(name) nn = length(name); else nn = 1; end end tex = regexprep(name, '_', '\\_'); if info for i=1:nn if iscell(name) texname = tex{i}; else texname = tex; end idx = strfind(texname,'_'); ndx = length(idx); ntx = length(texname); if ndx gotonextcondition = 1; if isequal(ndx,1) && ~isequal(idx,2) && ~isequal(idx,ntx) texname = [ texname(1:idx-2) '_{' texname(idx+1:end) '}']; gotonextcondition = 0; end if gotonextcondition && isequal(ndx,2) && ~isequal(idx(1),2) && isequal(idx(2),ntx) texname = [ texname(1:idx(1)-2) '_{' texname(idx(1)+1:end) '}' ]; gotonextcondition = 0; end if gotonextcondition && isequal(ndx,2) && idx(2)2 if idx(end)