0

This code:

    Relations $r, s:$
    \[\underbrace{\begin{tabular}{||c c||}
                \hline
                A        & B \\ [0.5ex]
                \hline \hline
                $\alpha$ & 1 \\
                \hline
                $\alpha$ & 2 \\
                \hline
                $\beta$  & 1 \\
                \hline
            \end{tabular}}_{r}\] & \[\underbrace{\begin{tabular}{||c c||}
        \hline
        A        & B \\ [0.5ex]
        \hline \hline
        $\alpha$ & 2 \\
        \hline
        $\beta$  & 3 \\
        \hline
        \hline
    \end{tabular}_{aaa}\]

leads me to Misplaced alignment tab character &.LaTeX error.

If I remove &, tables are not aligned, so, uh. How can I do this?

enter image description here

Please dont make the solution overcomplicated, I only use LaTeX as a distraction while reading my lecture notes. Asking only for visual pleasure.

1 Answer 1

4

You're using displayed maths (\[...\]), those form a line of their own, so are not doing what you intend. Replace them by inline maths ($...$ or \(...\) whichever form you prefer).

The misplaced alignment tab character is the & you put between the two tabular environments. Since that's outside any alignment that's just wrong, remove it.

The : inside of $...$ in your first line gives the wrong spacing, use $r, s$: instead.

There might be other things one could visually improve, but "please don't make the solution overcomplicated", so here it is:

\documentclass{article}

\begin{document}
Relations $r, s$:

$\underbrace{\begin{tabular}{||c c||}
    \hline
    A        & B \\ [0.5ex]
    \hline \hline
    $\alpha$ & 1 \\
    \hline
    $\alpha$ & 2 \\
    \hline
    $\beta$  & 1 \\
    \hline
\end{tabular}}_{r}$ 
$\underbrace{\begin{tabular}{||c c||}
    \hline
    A        & B \\ [0.5ex]
    \hline \hline
    $\alpha$ & 2 \\
    \hline
    $\beta$  & 3 \\
    \hline
    \hline
\end{tabular}}_{aaa}$
\end{document}

enter image description here


You might also consider using array instead of tabular. The biggest difference is that in array each cell is in maths mode, so you don't need the $...$ around \alpha, etc. If you don't want the A and B turn italic (maths) you could use \mathrm{A} and \mathrm{B} instead.

\documentclass{article}

\begin{document}
Relations $r, s$:

$\underbrace{\begin{array}{||c c||}
    \hline
    A      & B \\ [0.5ex]
    \hline \hline
    \alpha & 1 \\
    \hline
    \alpha & 2 \\
    \hline
    \beta  & 1 \\
    \hline
\end{array}}_{r}$
$\underbrace{\begin{array}{||c c||}
    \hline
    A      & B \\ [0.5ex]
    \hline \hline
    \alpha & 2 \\
    \hline
    \beta  & 3 \\
    \hline
    \hline
\end{array}}_{aaa}$
\end{document}

enter image description here

1
  • Thank you! I am going for the first option as my brain prefers tabular lol. Commented Jan 7 at 14:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .