The right-click menu
Every equation fxTeX renders has a menu of its own. Right-click one and your reader can copy it in the form they need, open it
in the equation editor, or turn it into a working graph and calculator. It is part of
fxtex.min.js and always on: there is nothing to install and nothing to configure.
fxTeX Pro can trim it to the Copy items, or turn it off — see
below.
Try it. Right-click any equation in the box below:
Try Graph on either equation, then Edit values.
Menu options
| Copy | |
|---|---|
| LaTeX | The equation's LaTeX source, to paste into a document, a message or an editor. |
| MathML | The equation as a standalone <math> element, with its namespace and without fxTeX's own attributes — ready to paste into Word, another web page, or any application that reads MathML. |
| SVG image | A vector image of the equation, as it appears on the page (inline or display). |
| PNG image | A bitmap image, pasted straight into documents, slides and chat. |
| Download | |
| The equation as a one-page vector PDF, saved as a file. | |
| Open | |
| Graph | A live graph of the equation, with a calculator beneath it. See below. |
| LaTeX Editor | Opens the equation in the online fxEditor, in a new tab, ready to change. |
Copying LaTeX and MathML happens entirely in the browser. The two images and the PDF are fetched from fxTeX Server when the item is chosen — fxTeX itself converts to MathML and draws no images. Those requests come from your page like any other equation image, so they count towards your domain's fxTeX Server allowance. They are made only when a reader asks, never while the page renders.
For an image file, rather than an image on the clipboard, link to fxTeX Server's
download format — svg.download, png.download or
pdf.download. See the API.
The menu works from the keyboard: the arrow keys move between items, Enter chooses, and Escape closes it. It appears only on equations fxTeX has rendered; other MathML on the page keeps the browser's own menu.
Graph and calculator
Graph turns an equation into something a reader can use. The equation is compiled to WebAssembly by the CodeCogs fxCode service, then run in the reader's own browser, so the graph redraws instantly as values change.
The graph. One variable goes on the x-axis —
x, t or n if the equation has one, otherwise its first
parameter — and the result is plotted against it. An equation with nothing to vary simply
shows its value.
The calculator. Edit values reveals every parameter as an input. Change one and the graph follows. Any parameter can be moved to the x-axis with its x-axis button.
Comparing. + Add line plots the equation again with different values, each line in its own colour, with a table of values beneath the graph.
Animating. The ⏱ button beside a parameter sweeps it over time; beside the x-axis it pans the window.
Display and export. Use a logarithmic y-axis when every value is positive, or choose Download PNG to save the graph.
The graph widget is a separate file, fxgraph.esm.js, fetched from beside
fxtex.min.js the first time a reader chooses Graph, so it costs nothing on pages where
nobody does. If you host fxtex.min.js yourself, host the two together, or say where
the widget is with the graphScript option below.
Opening your own instead
Before opening its graph, fxTeX raises a cancelable fxtex:graph event on the
equation. Call preventDefault() and it opens nothing, leaving the item to you:
document.addEventListener('fxtex:graph', function (e) {
e.preventDefault();
openMyCalculator(e.detail.latex); // e.detail = { latex, math }
});
Configuration
The menu needs no setup. Three addresses can be changed — for a
self-hosted fxTeX Server, say — either as
the contextMenu option to render() or at any time with
configureContextMenu():
fxTeX.configureContextMenu({
server: 'https://equations.example.com/', // where Copy as SVG / PNG fetch images
graphServer: 'https://fxcode.example.com', // where Graph compiles the equation
graphScript: '/static/fxgraph.esm.js' // where the graph widget is loaded from
});
| Option | Default |
|---|---|
server | https://fxtex.codecogs.com/ |
graphServer | https://fxcode.codecogs.com |
graphScript | fxgraph.esm.js beside fxtex.min.js |
fxTeX Pro: how much menu
With fxTeX Pro, the mode
option chooses how much of the menu your readers get. It applies to the whole page, and is set as
the page is rendered:
fxTeXPro.autoRender({ contextMenu: { mode: 'copy' } });
| Mode | The menu |
|---|---|
'full' | Every item: Copy, Download and Open. The default. |
'copy' | Only the Copy items — LaTeX, MathML, SVG image and PNG image. |
'disable' | No menu. A right-click on an equation opens the browser's own. |
render() takes the same option, and fxTeXPro.configureContextMenu({ mode })
changes it at any time. Any other value is an error, so a misspelt mode never quietly changes the
menu. The free fxTeX always shows the full menu.
More
fxTeX API — installing fxTeX and controlling how it scans a page.
Examples — more equations to try the menu on.
fxTeX Server API — the service the image items fetch from.
