Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for \vspace command #3317

Open
RarityBrown opened this issue Dec 27, 2024 · 1 comment
Open

Add support for \vspace command #3317

RarityBrown opened this issue Dec 27, 2024 · 1 comment

Comments

@RarityBrown
Copy link

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.

@dpvc
Copy link
Member

dpvc commented Dec 30, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants