Skip to content

feat: add support for \smash command#211

Merged
OrangeX4 merged 1 commit intomitex-rs:mainfrom
Shichien:feat/smash-cmd
Dec 24, 2025
Merged

feat: add support for \smash command#211
OrangeX4 merged 1 commit intomitex-rs:mainfrom
Shichien:feat/smash-cmd

Conversation

@Shichien
Copy link
Contributor

Support \smash Command

It was noted in #43 that the \smash command is included in the roadmap. But the current version triggers:
error: unknown command: \smash.

this PR provides a basic implementation.

  • Note: Optional arguments [t] and [b] are currently not supported.
  • The command renders the content as a math formula using $#it$ by default.

Typst Preview

#table(
  columns: (1.5fr, 2fr, 2fr),
  inset: 8pt,
  align: horizon + center,
  table.header([Scenario], [Unbalanced], [Smashed]),

  [Square Root],
  [#mi(`$\sqrt{x} + \sqrt{y} + \sqrt{T} + \sqrt{\sum}$`)],
  [#mi(`$\sqrt{\smash{x}} + \sqrt{\smash{y}} + \sqrt{\smash{T}} + \sqrt{\smash{\sum}}$`)],

  [Underline Alignment],
  [#mi(`$\underline{x} + \underline{y} + \underline{a}$`)],
  [#mi(`$\underline{\smash{x}} + \underline{\smash{y}} + \underline{\smash{a}}$`)],

  [Line Height Protection],
  [Text #mi(`$A_{2_2^{2^2}}$`) expands line height],
  [Text #mi(`$A_{\smash{2_2^{2^2}}}$`) maintains line height],

  [Compact Overline],
  [#mi(`$\overline{\frac{1}{2}}$`)],
  [#mi(`$\overline{\smash{\frac{1}{2}}}$`)],

  [Compact Underline],
  [#mi(`$\underline{\frac{1}{2}}$`)],
  [#mi(`$\underline{\smash{\frac{1}{2}}}$`)],
)
image

LaTeX Preview

image
\begin{table}[h]
    \centering
    \Large
    \renewcommand{\arraystretch}{1.8}
    \begin{tabularx}{\textwidth}{|>{\centering\arraybackslash}m{5cm}|>{\centering\arraybackslash}X|>{\centering\arraybackslash}X|}
        \hline
        \textbf{Scenario}      & \textbf{Unbalanced}                             & \textbf{Smashed}                                                               \\
        \hline
        Square Root            & $\sqrt{x} + \sqrt{y} + \sqrt{T} + \sqrt{\sum}$  & $\sqrt{\smash{x}} + \sqrt{\smash{y}} + \sqrt{\smash{T}} + \sqrt{\smash{\sum}}$ \\
        \hline
        Underline Alignment    & $\underline{x} + \underline{y} + \underline{a}$ & $\underline{\smash{x}} + \underline{\smash{y}} + \underline{\smash{a}}$        \\
        \hline
        Line Height Protection & Text $A_{2_2^{2^2}}$ expands line height        & Text $A_{\smash{2_2^{2^2}}}$ maintains line height                             \\
        \hline
        Compact Overline       & $\overline{\frac{1}{2}}$                        & $\overline{\smash{\frac{1}{2}}}$                                               \\
        \hline
        Compact Underline      & $\underline{\frac{1}{2}}$                       & $\underline{\smash{\frac{1}{2}}}$                                              \\
        \hline
    \end{tabularx}
\end{table}

@OrangeX4 OrangeX4 merged commit ee351fe into mitex-rs:main Dec 24, 2025
4 checks passed
@OrangeX4
Copy link
Member

Thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants