Giter Site home page Giter Site logo

Comments (3)

CapsLocker avatar CapsLocker commented on May 30, 2024

changing the interpreter on the legend fixes this one I think:

lh = legend('show','Location','north west');
set(lh,'Interpreter','latex')

regards

from matlab2tikz.

burkart avatar burkart commented on May 30, 2024

I wouldn't recommend that workaround unless you know what you're doing.

My goal in rewriting the string handling was to get as close a result in the matlab2tikz output to what you see in MATLAB itself. This means that m2t is "bug-compatible" with MATLAB, for instance when it comes to MATLAB interpreting "\alpha \beta" as two greek symbols with a space in between even though a proper TeX interpreter would omit the space as it is the termination of the control sequence. (If you indeed wanted to have a space, proper TeX markup would require either 2 spaces between the greek letters or the sequence "\alpha{} \beta".)

Now, the "latex" interpreter as understood by MATLAB is more true to proper (La)TeX syntax as opposed to MATLAB's "tex" interpreter -- or at least that's what's in the documentation. Judging by the examples on the MathWorks website, text that is to be interpreted by the "latex" interpreter typically, if not always, is put inside an equation environment "$$...$$". What m2t does in the function prettyPrint() is to replace both the two dollar signs at the start and at the end of the string with single dollar signs to use TeX math mode. Since the replacement uses regexprep() there's no replacement whatsoever taking place if the matching criterion "$$...$$" isn't fulfilled.

That's why your workaround works, assuming the legend entries aren't encapsulated in "$$...$$". However, MATLAB might treat them very oddly which brings us back to the original point: Make your text elements like legend entries look the way you want them to in MATLAB first. If the output generated by m2t then deviates from that, please file a bug report. That way it shouldn't be necessary to do any formatting specifically for either MATLAB or matlab2tikz -- which was the goal in rewriting the text handling to begin with.

from matlab2tikz.

burkart avatar burkart commented on May 30, 2024

First of all, the solution for the original submitter might be more or less what CapsLocker suggested, except that the "interpreter" property shouldn't be set to "latex" but to "none".

Additionally, what was discussed in conjunction with github issue #64 might solve the problem, i.e. the new m2t parameter "parseStrings". Therefore I think this issue should be closed.

from matlab2tikz.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.