I think that you already have half of the work with this plugin, that is awsome. Didnât know aboutâŚ
Now you only need to build this keyboard and connect each button to a specific text of this plugin in order to have, as the final result, the equation.
If the users clicks the button â/â, you need to write â\overâ. And the result will be â3 \over 5â.
I added an HTML Visual Element to my page with this piece of code:
<!DOCTYPE html>
<html>
<head>
<title>Math Field with Hidden Menu</title>
<script defer src="//unpkg.com/mathlive"></script>
<style>
.container {
display: flex;
justify-content: left;
align-items: top;
}
math-field {
font-size: 16px; /* Adjust the size of your math field if needed */
border: none; ;
}
/* Hide the menu toggle button */
math-field::part(menu-toggle) {
display: none;
}
math-field::part(virtual-keyboard-toggle) {
display: none;
}
</style>
</head>
<body>
<div class="container">
<math-field id="my-math-field">f(x) = \sin(x+\pi)</math-field>
</div>
</body>
</html>
This basically allows you to add a math field to your page. Please note that I have personalised mine to hide the menu that normally comes with it, hide the math keyboard, hide the border, and justify to the left.
You can change those settings by updating the code that I provided above. All personalisation options are described in the CortexJS documentation.
If youâre a newbie to JS and HTML like me, I recommend asking ChatGPT to help you make changes and by mentioning CortexJS in your prompt. It worked really well. I barelly had to edit this code manually.