Problem 1860. Remove TeX from string

Solution 1584814

Submitted on 16 Jul 2018 by J. S. Kowontan
  • Size: 17
  • This is the leading solution.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
texStr = '\beta'; txt = 'beta'; assert(isequal(tex2txt(texStr),txt))

2   Pass
texStr = ['\fontsize{16}black {\color{magenta}magenta '... '\color[rgb]{0 .5 .5}teal \color{red}red} black again']; txt = 'black magenta teal red black again'; assert(isequal(tex2txt(texStr),txt))

3   Pass
texStr = {'We need to work with cells, too' '(for {\bfmultiline} labels) and' 'return strings with newline characters.'}; txt = sprintf(['We need to work with cells, too\n' ... '(for multiline labels) and\n' ... 'return strings with newline characters.']); assert(isequal(tex2txt(texStr),txt))

4   Pass
texStr = '\slRemove {\bfall} \itof \rmthese.'; txt = 'Remove all of these.'; assert(isequal(tex2txt(texStr),txt))

5   Pass
txt = 'variable_i^2/pi'; texStr = texlabel(txt); assert(isequal(tex2txt(texStr),txt))

Suggested Problems

More from this Author4

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!