Skip to content

Commit

Permalink
Merge pull request #937 from AlbertoCuadra/develop
Browse files Browse the repository at this point in the history
Solve: error speciesLatex.m when there are two subscripts #935
Former-commit-id: 0b8be9e
  • Loading branch information
AlbertoCuadra authored Jan 26, 2024
2 parents 8f4b460 + 7724369 commit 64fb2a8
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion utils/display/species2latex.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,33 @@
% Check if ions
speciesLatex = strrep(speciesLatex, 'plus', '$^+$');
speciesLatex = strrep(speciesLatex, 'minus', '$^-$');

% Check if is there are parenthesis
[ind_start, ind_end] = regexp(speciesLatex, '(?=b)(.*?)(?=b)');
if ind_start
speciesLatex(ind_start(1)) = '(';
speciesLatex(ind_end(end) + 1) = ')';
end

% Check concatenate $$
speciesLatex = strrep(speciesLatex, '$$', '');

% Check suffix
index = regexp(speciesLatex, '_[a-zA-Z]');
speciesLatex(index) = '';

% Check long numbers
speciesLatex = strrep(speciesLatex, '}_{', '');
end

% Joining the Burcat subscript with the previous subscript
[ind_start, ind_end] = regexp(speciesLatex, '(?=_{)(.*?)(?=})', 'once');
FLAG_DOUBLE_SUBSCRIPTS = contains(speciesLatex, '_{\rm M}') && ind_start && ind_end;

if FLAG_DOUBLE_SUBSCRIPTS
% Remove _M subscript
speciesLatex = strrep(speciesLatex, '_{\rm M}', '');
% Join _M subscript with the first one
speciesLatex = [speciesLatex(1:ind_end), ', \rm{M}', speciesLatex(ind_end+1:end)];
end

end

0 comments on commit 64fb2a8

Please sign in to comment.