MathJax icon indicating copy to clipboard operation
MathJax copied to clipboard

Add support for `\vspace` command

Open RarityBrown opened this issue 1 year ago • 1 comments

Is your feature request related to a problem? Please describe.

MathJax currently lacks support for the \vspace command. This makes it difficult to adjust vertical spacing in equations, particularly for negative spacing. While \hspace is supported, there's no direct equivalent for vertical space.

For example, consider trying to create a diagram, such as:

image
\begin{align}
    \hspace{4cm}      Y                 \\
    \hspace{4cm}      \rule{0.1em}{2cm} \\
    % \vspace{-1em}
    X  \hspace{0.2em} \rule{3.5cm}{0.1em}
\end{align}

$$ \begin{align} \hspace{4cm} Y \ \hspace{4cm} \rule{0.1em}{2cm} \ % \vspace{-1em} X \hspace{0.2em} \rule{3.7cm}{0.1em} \end{align} $$

Without \vspace, it is impossible to introduce the desired negative vertical spacing.

Describe the solution you'd like

Add support for the \vspace command in MathJax, allowing users to add vertical space (both positive and negative) using syntax like \vspace{1em} or \vspace{-1em}.

Describe alternatives you've considered

The workaround \rule{0pt}{#1em} can add positive vertical space but cannot create negative vertical space.

RarityBrown avatar Dec 27 '24 13:12 RarityBrown

Because MathJax converts the LaTeX to MathML internally, there are some limitations on what MathJax can support. Alignments are implemented as tables, and MathML does not have a means of vertically backspacing within a table, so MathJax can't support the negative \vspace that you are suggesting without a complete rewrite of how alignments are handled.

On the other hand, you don't need negative spacing to do what you are looking for here. For example,

\begin{align}
    Y \\
    X  \hspace{0.2em}
       \raise.1em{\small\blacktriangleleft}\!
       \rule[.25em]{3.5cm}{0.1em} \rule[.25em]{0.1em}{2cm}\>\,
\end{align}

produces

axes

which seems to be what you are looking for.

Also, note that the \\ macro can be followed by an optional argument that gives space to use between the lines of an alignment or array. That can be used to add extra space, or to remove a small amount of space, but only the extra space that is being inserted between the rows, so it can't make the rows overlap.

dpvc avatar Dec 30 '24 15:12 dpvc