Skip to content

Unwanted vertical space after aligned environment #3142

@benrbray

Description

@benrbray

Before reporting a bug

Describe the bug:

Using the aligned environment results in extra unwanted empty space at the bottom of the rendered math equations.

To Reproduce:
Steps to reproduce the behavior:

  1. Go to the KaTeX demo

  2. Enter any equation using \begin{aligned}...\end{aligned}, such as

    \begin{aligned}
    (\overline{\alpha} ; \beta)(k \otimes v)
    &= ((\otimes ; \overline{\alpha}) ; \beta)(k,v) \\
    &= (\alpha ; \beta)(k,v)
     = \beta(kv) \\
    &= 1 \otimes kv
     = k \otimes v
    \end{aligned}
    
  3. Right click on the equation and "inspect element". Hover over the span.katex-display element in the DOM tree to see the bounding box for the element. You will see something like this:

image

As you can see, this extra space is not usually present for equations not using the aligned environment:

image

As you can see from the image below, this extra space can look quite awkard in context. Paragraph spacing that normally looks fine is made asymmetric by the extra space. Worse, it's not possible to fix the problem with CSS, as there's not a simple way to detect when the aligned environment is being used to render math that appears just before a paragraph.

image

Expected behavior:

There should be no extra vertical space at the bottom of aligned environments.

Screenshots: see above

Environment (please complete the following information):

  • KaTeX Version: 0.13.13
  • Device: Desktop
  • OS: Ubuntu 20.04
  • Browser: Tested in Chrome and Firefox
  • Version: Chrome v91, Firefox v90.0

Additional context: None. Reproducible on the demo site.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions