mirror of
https://github.com/folke/snacks.nvim
synced 2025-12-23 08:47:57 +00:00
fix(image): avoid nested math environments (#2345)
## Description
Inline LaTeX equation preview renders equations twice, partly on top of
each other, if you use nested math environments. Minimal reproducer:
```latex
\documentclass{article}
\begin{document}
\begin{equation}
\begin{aligned}
x_+ &= \frac{-b + \sqrt{b^2 - 4ac}}{2a} \, , \\
x_- &= \frac{-b - \sqrt{b^2 - 4ac}}{2a} \, .
\end{aligned}
\end{equation}
\end{document}
```
While, adding a test case for this to `test.tex` I also corrected a
package name such that it compiles without error.
## Screenshots
**Before**
<img width="248" height="203" alt="Screenshot 2025-10-24 at 16 22 05"
src="https://github.com/user-attachments/assets/ab55ef8c-1f04-49e5-b731-95b638ac9db7"
/>
**After**
<img width="248" height="203" alt="Screenshot 2025-10-24 at 16 23 33"
src="https://github.com/user-attachments/assets/4d3d53f6-7122-452f-b891-5a712f79fe40"
/>
This commit is contained in:
parent
2a1a001d3a
commit
66e3dc4619
4 changed files with 9 additions and 16 deletions
|
|
@ -9,7 +9,7 @@
|
|||
((math_environment
|
||||
(#set! image.ext "math.tex"))
|
||||
@image.content @image
|
||||
(#not-has-ancestor? @image "displayed_equation"))
|
||||
(#not-has-ancestor? @image "displayed_equation" "math_environment"))
|
||||
|
||||
(graphics_include
|
||||
(_ (path) @image.src)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
\relax
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {1}Image Tests}{1}{}\protected@file@percent }
|
||||
\@writefile{lof}{\contentsline {figure}{\numberline {1}{\ignorespaces Test image centered in a figure environment.}}{1}{}\protected@file@percent }
|
||||
\newlabel{fig:test_image}{{1}{1}{}{}{}}
|
||||
\newlabel{fig:test_image}{{1}{1}{}{figure.1}{}}
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {2}Some beautiful mathematical equations}{2}{}\protected@file@percent }
|
||||
\gdef \@abspage@last{4}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,5 +1,5 @@
|
|||
\documentclass{article}
|
||||
\usepackage{graphics, amsmath, amssymb, multirow}
|
||||
\usepackage{graphicx, amsmath, amssymb, multirow}
|
||||
\usepackage{geometry}
|
||||
\geometry{
|
||||
a4paper,
|
||||
|
|
@ -78,19 +78,12 @@ Fourier transform:
|
|||
Maxwell's equations:
|
||||
|
||||
\begin{equation}
|
||||
\nabla \times \textbf{E}=\frac{\rho}{\epsilon_0}
|
||||
\end{equation}
|
||||
|
||||
\begin{equation}
|
||||
\nabla \cdot \textbf{H}=0
|
||||
\end{equation}
|
||||
|
||||
\begin{equation}
|
||||
\nabla \times \textbf{E}=-\frac 1c\frac{\partial \textbf{H}}{\partial t}
|
||||
\end{equation}
|
||||
|
||||
\begin{equation}
|
||||
\nabla \times \textbf{H}=\frac 1c\frac{\partial \textbf{E}}{\partial t}
|
||||
\begin{aligned}
|
||||
\nabla \times \textbf{E}&=\frac{\rho}{\epsilon_0} \\
|
||||
\nabla \cdot \textbf{H}&=0 \\
|
||||
\nabla \times \textbf{E}&=-\frac 1c\frac{\partial \textbf{H}}{\partial t} \\
|
||||
\nabla \times \textbf{H}&=\frac 1c\frac{\partial \textbf{E}}{\partial t}
|
||||
\end{aligned}
|
||||
\end{equation}
|
||||
|
||||
Schroedinger equation:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue