Wie richte ich Spalten in einer Tabelle mit Minuszeichen im Mathematikmodus aus?

Wie richte ich Spalten in einer Tabelle mit Minuszeichen im Mathematikmodus aus?

ich fanddiese Frage, aber das scheint speziell auf die Mitte basierend auf der Dezimalzahl zuzutreffen, und meine Tabelle enthält keine numerischen Daten. Ich versuche, die Cayley-Tabelle für die Quaternionen zu erstellen, und ein minimales funktionierendes Beispiel dafür, wie meine Tabelle aussieht, ist:

\documentclass[12pt,letterpaper]{article}
\usepackage{amsmath,amsthm,amsfonts,amssymb,amscd}

\begin{document}

\begin{table}[h]
    \begin{center}
        \begin{tabular}{l|llllllll}
            $*$&$1$&$-1$&$i$&$-i$&$j$&$-j$&$k$&$-k$\\\hline
            $1$&$1$&$-1$&$i$&$-i$&$j$&$-j$&$k$&$-k$\\
            $-1$&$-1$&$1$&$-i$&$i$&$-j$&$j$&$-k$&$k$\\
            $i$&$i$&$-i$&$-1$&$1$&$k$&$-k$&$-j$&$j$\\
            $-i$&$-i$&$i$&$1$&$-1$&$-k$&$k$&$j$&$-j$\\
            $j$&$j$&$-j$&$-k$&$k$&$-1$&$1$&$i$&$-i$\\
            $-j$&$-j$&$j$&$k$&$-k$&$1$&$-1$&$-i$&$i$\\
            $k$&$k$&$-k$&$-j$&$j$&$-i$&$i$&$1$&$-1$\\
            $-k$&$-k$&$k$&$j$&$-j$&$i$&$-i$&$-1$&$1$\\
        \end{tabular}
    \end{center}
\end{table}

\end{document}

Dies erzeugt die folgende Ausgabe.

schlechter Cayley-Tisch

Welche IDwieDamit die Tabelle folgendermaßen aussieht:

guter Cayley Tisch

Ich bin sicher, dass es auf dieser Site bereits eine ähnliche Frage gibt, aber ich konnte nichts finden, was auf nicht numerische Zellwerte zutrifft.

Antwort1

Ich bin fast hundertprozentig sicher, dass es bessere Lösungen gibt, aber Sie könnten Folgendes verwenden \phantom{-}:

\documentclass[12pt,letterpaper]{article}
\usepackage{amsmath,amsthm,amsfonts,amssymb,amscd}

\begin{document}

\begin{table}[h]
    \begin{center}
        \begin{tabular}{l|llllllll}
            $*$ & $\phantom{-}1$ & $-1$ & $\phantom{-}i$ & $-i$ & $\phantom{-}j$ & $-j$ & $\phantom{-}k$ & $-k$ \\\hline
            $\phantom{-}1$ & $\phantom{-}1$ & $-1$ & $\phantom{-}i$ & $-i$ & $\phantom{-}j$ & $-j$ & $\phantom{-}k$ & $-k$ \\
            $-1$ & $-1$ & $\phantom{-}1$ & $-i$ & $\phantom{-}i$ & $-j$ & $\phantom{-}j$ & $-k$ & $\phantom{-}k$ \\
            $\phantom{-}i$ & $\phantom{-}i$ & $-i$ & $-1$ & $\phantom{-}1$ & $\phantom{-}k$ & $-k$ & $-j$ & $\phantom{-}j$ \\
            $-i$ & $-i$ & $\phantom{-}i$ & $\phantom{-}1$ & $-1$ & $-k$ & $\phantom{-}k$ & $\phantom{-}j$ & $-j$ \\
            $\phantom{-}j$ & $\phantom{-}j$ & $-j$ & $-k$ & $\phantom{-}k$ & $-1$ & $\phantom{-}1$ & $\phantom{-}i$ & $-i$ \\
            $-j$ & $-j$ & $\phantom{-}j$ & $\phantom{-}k$ & $-k$ & $\phantom{-}1$ & $-1$ & $-i$ & $\phantom{-}i$ \\
            $\phantom{-}k$ & $\phantom{-}k$ & $-k$ & $-j$ & $\phantom{-}j$ & $-i$ & $\phantom{-}i$ & $\phantom{-}1$ & $-1$ \\
            $-k$ & $-k$ & $\phantom{-}k$ & $\phantom{-}j$ & $-j$ & $\phantom{-}i$ & $-i$ & $-1$ & $\phantom{-}1$ \\
        \end{tabular}
    \end{center}
\end{table}

\end{document}

Bildschirmfoto

In diesem Fall reicht möglicherweise sogar das bloße Ausrichten der Spalten nach rechts aus (es erzeugt jedoch nicht genau dasselbe Ergebnis):

\documentclass[12pt,letterpaper]{article}
\usepackage{amsmath,amsthm,amsfonts,amssymb,amscd}

\begin{document}

\begin{table}[h]
    \begin{center}
        \begin{tabular}{r|rrrrrrrr}
            $*$  & $1$  & $-1$ & $i$  & $-i$ & $j$  & $-j$ & $k$  & $-k$ \\\hline
            $1$  & $1$  & $-1$ & $i$  & $-i$ & $j$  & $-j$ & $k$  & $-k$ \\
            $-1$ & $-1$ & $1$  & $-i$ & $i$  & $-j$ & $j$  & $-k$ & $k$ \\
            $i$  & $i$  & $-i$ & $-1$ & $1$  & $k$  & $-k$ & $-j$ & $j$ \\
            $-i$ & $-i$ & $i$  & $1$  & $-1$ & $-k$ & $k$  & $j$  & $-j$ \\
            $j$  & $j$  & $-j$ & $-k$ & $k$  & $-1$ & $1$  & $i$  & $-i$ \\
            $-j$ & $-j$ & $j$  & $k$  & $-k$ & $1$  & $-1$ & $-i$ & $i$ \\
            $k$  & $k$  & $-k$ & $-j$ & $j$  & $-i$ & $i$  & $1$  & $-1$ \\
            $-k$ & $-k$ & $k$  & $j$  & $-j$ & $i$  & $-i$ & $-1$ & $1$ \\
        \end{tabular}
    \end{center}
\end{table}

\end{document}

Auch,Mathe-Modus in tabellarischer Form, ohne überall $...$ verwenden zu müssenkönnte interessant sein. Alles Gute!

verwandte Informationen