Katex: vertical alignment for \rule seems off

Created on 25 Jan 2017  路  2Comments  路  Source: KaTeX/KaTeX

When a \rule has a height argument, its vertical alignment seems to be off:

image

You can see the issue without \frac or \color, I just used them to highlight the issue.

Here is a similar expression in latex:

image

rendered with:

\documentclass{article}
\usepackage{color}
\begin{document}
$$
\frac{\textcolor{blue}{\rule{2em}{2em}}}{2}
$$
\end{document}

The katex screenshot was taken from the katex homepage today, and I've seen the same thing running version 0.7.1 (I'm not sure if the github pages has the most up to date version).

I'd love to help fix this if possible, but my fear is that it's a very subtle and complicated CSS issue. My guess is to look at the rule for \rule in the buildHTML? Specifically, I thought this function might be important:

https://github.com/Khan/KaTeX/blob/master/src/buildHTML.js#L1319

I don't know if this is a known issue, I couldn't find it searching, so sorry if this is a duplicate.

bug

Most helpful comment

I believe that this issue was resolved by PR #768.
rule

All 2 comments

I think the fix might be to set the style.marginTop property to -(height - shift) and to not set style.bottom.

I believe that this issue was resolved by PR #768.
rule

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pvnr0082t picture pvnr0082t  路  4Comments

oddhack picture oddhack  路  3Comments

pyramation picture pyramation  路  4Comments

OisinMoran picture OisinMoran  路  4Comments

trollanfer picture trollanfer  路  5Comments