alignmentkatex

\multicolumn alternative in KaTeX


I want to be able to align a single cell's contents differently from the rest. I've found that this can be done using \multicolumn in LaTeX however, I have yet to find an alternative that works in KaTeX. Below is roughly what my current table looks like. Say that I want to align the cell with "Hello" to the right, how would I go about that in KaTeX?

\begin{array}{|l|}
    \hline
    \text{Hi} \\
    \hline
    \text{Good Morning} \\
    \hline
    \text{Hello} \\
    \hline
    \text{Howdy} \\
    \hline
\end{array}

Solution

  • Indeed in KaTeX you can't do all that you can do in LaTeX, even using a tabular environment is not trivial.

    As long as your array or table must only conain text, I would rely on html <table> tag and CSS style:

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Array?</title>
    <style>
    table,td{border:1px solid black;border-collapse:collapse}
    td.cellle,td.cellri{padding:5px}
    td.cellri{text-align:right}
    </style>
    </head>
    
    <body>
    <table>
    <tr><td class="cellle">Hi</td></tr>
    <tr><td class="cellle">Good Morning</td></tr>
    <tr><td class="cellri">Hello</td></tr>
    <tr><td class="cellle">Howdy</td></tr>
    </table>
    </body>
    </html>
    

    table,td{border:1px solid black;border-collapse:collapse}
    td.cellle,td.cellri{padding:5px}
    td.cellri{text-align:right}
    <table>
    <tr><td class="cellle">Hi</td></tr>
    <tr><td class="cellle">Good Morning</td></tr>
    <tr><td class="cellri">Hello</td></tr>
    <tr><td class="cellle">Howdy</td></tr>
    </table>

    Also, if it is needed, you can then use the KaTeX inline math delimiters within any single cell, whose alignment you control by the CSS.