/ simulated_instruments / cymbal2
Sign in
simulated_instruments / cymbal2
cymbal2 / webapp / src / tutorial / math.tsx
28 lines · 954 BCodeBlameHistory
17959acInteractive tutorial on the theory and the solverJeremy Magland 1// KaTeX wrappers for the tutorial. M renders inline math, Eq a display
2// equation with an optional right-aligned tag, conventionally the equation
3// number of Samejima (2021) so the tutorial can be read beside the paper.
5import katex from 'katex';
6import 'katex/dist/katex.min.css';
7import { useMemo } from 'react';
9export function M({ children }: { children: string }) {
10 const html = useMemo(
11 () => katex.renderToString(children, { throwOnError: false }),
12 [children],
13 );
14 return <span dangerouslySetInnerHTML={{ __html: html }} />;
17export function Eq({ children, tag }: { children: string; tag?: string }) {
18 const html = useMemo(
19 () => katex.renderToString(children, { throwOnError: false, displayMode: true }),
20 [children],
21 );
22 return (
23 <div className="tut-eq">
24 <div className="tut-eq-body" dangerouslySetInnerHTML={{ __html: html }} />
25 {tag && <div className="tut-eq-tag">{tag}</div>}
26 </div>
27 );
↑↓ move↵openescclose