Skip to content

Instantly share code, notes, and snippets.

@egawata
Created March 19, 2026 12:07
Show Gist options
  • Select an option

  • Save egawata/fe28a58324c470ed100349e352d22471 to your computer and use it in GitHub Desktop.

Select an option

Save egawata/fe28a58324c470ed100349e352d22471 to your computer and use it in GitHub Desktop.
KaTeX mathml's position problem
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>KaTeX Scroll Issue Demo</title>
<link rel="stylesheet" href="dist/katex.min.css">
<script defer src="dist/katex.min.js"></script>
<script defer src="dist/contrib/auto-render.min.js"
onload="renderMathInElement(document.body)"></script>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
}
h1 { font-size: 1.4rem; margin-bottom: 16px; }
h2 { font-size: 1.1rem; margin: 0 0 8px; }
.container {
display: flex;
gap: 24px;
}
.panel {
flex: 1;
background: #fff;
border: 1px solid #ccc;
border-radius: 4px;
overflow: hidden;
}
.panel-header {
padding: 8px 12px;
font-weight: bold;
border-bottom: 1px solid #ccc;
}
.scroll-area {
max-height: 50vh;
overflow: auto;
padding: 12px;
}
.content-block {
margin-bottom: 12px;
line-height: 1.8;
}
</style>
</head>
<body>
<h1>KaTeX Scroll Issue Demo</h1>
<div class="container">
<div class="panel">
<div class="scroll-area">
<div class="content-block">
<h2>Probability Distributions</h2>
<p>Probability mass function of the binomial distribution: $$P(X = k) = \binom{n}{k} p^k (1-p)^{n-k}$$</p>
<p>The expected value is $$E[X] = np$$ and the variance is $$\text{Var}(X) = np(1-p)$$.</p>
</div>
<div class="content-block">
<h2>Fundamental Equations of Physics</h2>
<p>Einstein's mass-energy equivalence: $$E = mc^2$$</p>
<p>Schr&ouml;dinger equation: $$i\hbar\frac{\partial}{\partial t}\Psi = \hat{H}\Psi$$</p>
<p>Maxwell's equation: $$\nabla \cdot \mathbf{E} = \frac{\rho}{\varepsilon_0}$$</p>
</div>
<div class="content-block">
<h2>Integrals</h2>
<p>Gaussian integral: $$\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}$$</p>
<p>Euler's formula: $$e^{i\theta} = \cos\theta + i\sin\theta$$</p>
</div>
<div class="content-block">
<h2>Probability Distributions</h2>
<p>Probability mass function of the binomial distribution: $$P(X = k) = \binom{n}{k} p^k (1-p)^{n-k}$$</p>
<p>The expected value is $$E[X] = np$$ and the variance is $$\text{Var}(X) = np(1-p)$$.</p>
</div>
<div class="content-block">
<h2>Fundamental Equations of Physics</h2>
<p>Einstein's mass-energy equivalence: $$E = mc^2$$</p>
<p>Schr&ouml;dinger equation: $$i\hbar\frac{\partial}{\partial t}\Psi = \hat{H}\Psi$$</p>
<p>Maxwell's equation: $$\nabla \cdot \mathbf{E} = \frac{\rho}{\varepsilon_0}$$</p>
</div>
<div class="content-block">
<h2>Integrals</h2>
<p>Gaussian integral: $$\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}$$</p>
<p>Euler's formula: $$e^{i\theta} = \cos\theta + i\sin\theta$$</p>
</div>
<div class="content-block">
<h2>Probability Distributions</h2>
<p>Probability mass function of the binomial distribution: $$P(X = k) = \binom{n}{k} p^k (1-p)^{n-k}$$</p>
<p>The expected value is $$E[X] = np$$ and the variance is $$\text{Var}(X) = np(1-p)$$.</p>
</div>
<div class="content-block">
<h2>Fundamental Equations of Physics</h2>
<p>Einstein's mass-energy equivalence: $$E = mc^2$$</p>
<p>Schr&ouml;dinger equation: $$i\hbar\frac{\partial}{\partial t}\Psi = \hat{H}\Psi$$</p>
<p>Maxwell's equation: $$\nabla \cdot \mathbf{E} = \frac{\rho}{\varepsilon_0}$$</p>
</div>
<div class="content-block">
<h2>Integrals</h2>
<p>Gaussian integral: $$\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}$$</p>
<p>Euler's formula: $$e^{i\theta} = \cos\theta + i\sin\theta$$</p>
</div>
<div class="content-block">
<h2>Probability Distributions</h2>
<p>Probability mass function of the binomial distribution: $$P(X = k) = \binom{n}{k} p^k (1-p)^{n-k}$$</p>
<p>The expected value is $$E[X] = np$$ and the variance is $$\text{Var}(X) = np(1-p)$$.</p>
</div>
<div class="content-block">
<h2>Fundamental Equations of Physics</h2>
<p>Einstein's mass-energy equivalence: $$E = mc^2$$</p>
<p>Schr&ouml;dinger equation: $$i\hbar\frac{\partial}{\partial t}\Psi = \hat{H}\Psi$$</p>
<p>Maxwell's equation: $$\nabla \cdot \mathbf{E} = \frac{\rho}{\varepsilon_0}$$</p>
</div>
<div class="content-block">
<h2>Integrals</h2>
<p>Gaussian integral: $$\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}$$</p>
<p>Euler's formula: $$e^{i\theta} = \cos\theta + i\sin\theta$$</p>
</div>
</div>
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment