arnog / mathlive

A web component for easy math input
https://cortexjs.io/mathlive
MIT License
1.57k stars 276 forks source link

Support of Latex Command to Rotate Text #946

Closed SushantGautam closed 2 years ago

SushantGautam commented 3 years ago

I have some general queries regarding the extendibility of MathLive.

  1. Is there any way to support rotating or flipping the text to some degree? (like turn or maybe rotatebox, in LATEX)? Are there any plans to do so?
  2. If we want to include some custom graphics with say "tikz", would it be possible ? Seems like the track is very difficult for this.
  3. Is it possible to include some SVG or say PNG graphics as for the template of Custom Virtual keyboard, say if someone would like to use their custom symbols?
  4. Does the "insert" section in Custom Virtual keyboard support LATEX only or other formats? Are there documentation** of those components?
arnog commented 3 years ago
  1. This is not currently supported, but it could easily be added. It would probably make sense to add all the commands from the graphics package. As a workaround, you can use the \class command to specify a CSS class that would have a transform attribute. It would probably make sense to file a feature request for this and see if there is enough interest.
  2. Supporting the complete tikz package is probably out of scope, especially if you'd want to have an editor for those graphics
  3. Yes, you can include SVG, PNG or any valid HTML markup as the value of the label property for a keycap. See the Virtual Keyboards guide (look for SVG to see an example).
  4. insert can only be use to insert Latex. However, a keycap can also have a command property which is more general and can respond in many ways. There is more detail and some examples provided in the Virtual Keyboards guide.

Could you share what did you have in mind in terms of custom symbols and how you'd like to use them with the virtual keyboard?

arnog commented 3 years ago

I forgot to mention that (1) has been discussed in #112 .

SushantGautam commented 3 years ago

Great! I managed to make it work with\class and decides my styles in the root using MathLive.makeMathField. However, after I migrated to MathfieldElement I couldn't make it work. As mentioned in the doc: "To associate a CSS stylesheet with this layer, use the styles property of the layer." and looking at the code segment: if (layer.styles) { temporaryLayer +=; } I added CSS properties like: image

But the shadow root shows these styles only: image and it didn't work. The \class property is rendered well in DOM. But since this is inside shadow root, the styles supplied at root arent obviously reflected here. image What is the correct way to supply styles?

arnog commented 3 years ago

Oopps... Yes, good point. The style property above allows you to inject a custom stylesheet to be used by the virtual keyboard. But if you're going to use custom classes in a mathfield, you need something analogous to inject the stylesheet in the shadowed element.

SushantGautam commented 3 years ago

Ok I Understood! That was just for the virtual keyboard style. Hope there will be a way (maybe another attribute besides styles for stylesheet in the shadowed element) soon.

arnog commented 3 years ago

OK, I've checked in a fix in master. You can now include a <style> tag inside the <math-field>.

<math-field>
  <style>
    .custom-class { box-shadow: 2px 2px 2px #000 };
  </style>

  \class{custom-class}{\frac{1}{x+1}}

</math-field>
SushantGautam commented 3 years ago

I think It was working when I had placed styles outside math-field too before. I am raising this problem when we use MathfieldElement through the script. Since <math-field> is created dynamically we cant use the method you mentioned isn't it?

arnog commented 3 years ago

Yes, that should work. You should be able to set the innerHTML of the MathfieldElement to “

SushantGautam commented 3 years ago

Cool! We could then set it through mfe.innerHTML =` . I tried and the style was appended to the dom as expected, but it didn't work. image

It would take time for this change to be reflected at https://unpkg.com/mathlive/dist/mathlive.min.js, right?

arnog commented 3 years ago

Yes, the change is in master, which is the branch in GitHub. You can find the status of a fix/feature by checking the changelog, which will either indicate the npm release it’s available in or “unreleased”

arnog commented 2 years ago

No activity in a while. Closing.