6

well met!

I need some help/advice regarding how to align a table at a specific symbol - in this case, I would like to align the table at the \to symbol

Thanks for your help! Find my MWE below!

\documentclass[a4paper]{article}

\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{siunitx}
\usepackage{multirow}
\usepackage{caption}

\begin{document}

\begin{table}[!htb]
    \centering
    %   \scriptsize % sets table text size
    \captionsetup{font=scriptsize} % sets the table's caption size 
    \caption{Transformation of the Cartesian coordinates under the symmetry group $D_{2}=V$ and the corresponding transformation of the Eulerian angles}
    \begin{center}
        \label{tab:tb2}
        \begin{tabular}{ccc}
            \hline
            \small{Symmetry}          & \small{Cartesian coordinate}  & \small{Euler angle}  \\
            \small{operation}         & \small{transformation}        & \small{transformation} \\
            \hline
            \multirow{3}{*}{$E$}
            & $x'\to x$                                  & $\phi'\to \phi$                         \\
            & $y'\to y$                                  & $\theta'\to \theta$                     \\
            & $z'\to z$                                  & $\chi'\to \chi$                         \\
            \multirow{3}{*}{$C_{2}(x)$}
            & $x'\to x$                                  & $\phi'\to \pi + \phi$                   \\
            & $y'\to -y$                                 & $\theta'\to \pi - \theta$               \\
            & $z'\to -z$                                 & $\chi'\to -\chi$                        \\
            \multirow{3}{*}{$C_{2}(y)$}
            & $x'\to -x$                                 & $\phi'\to \pi + \phi$                   \\
            & $y'\to y$                                  & $\theta'\to \pi - \theta$               \\
            & $z'\to -z$                                 & $\chi'\to \pi - \chi$                   \\
            \multirow{3}{*}{$C_{2}(z)$}
            & $x'\to -x$                                 & $\phi'\to \phi$                         \\
            & $y'\to -y$                                 & $\theta'\to \theta$                     \\
            & $z'\to z$                                  & $\chi'\to \pi + \chi$                   \\
            \hline
        \end{tabular}
    \end{center}
\end{table}

\end{document}
  • 2
    unrelated but size commands do not take an argument, use \small Symmetry not \small{Symmetry} – David Carlisle May 7 '19 at 17:30
8

I took the liberty of adding a few points of space between each transformation.

Whereas the tabular builds row by row, stacks, employed here, build by the column. Since there are three equations (x,y,z) per column, associated with each transformation, the \alignCenterstack is used to stack the three equations for each transformation. The "center" part of the name indicates the result will be centered about the baseline, so that the column 1 entry will be vertically centered with respect to columns 2 and 3. Furthermore, the stack is composed of equal baselineskips for each row, rather than equal gaps between row content.

The "align" part of the name indicates that the & tabbing separator can be used to mimic the align-style environments, allowing the rows to align at a specified point midway through the line (in this case, after the \to).

Note, however, that creating unique stacks for each of the E, C_2(x), C_2(y), and C_2(z) equations may still be misaligned with respect to each other, and for this reason, I employ \phantoms to make sure each of the transformation sets takes up the same horizontal width.

Finally, the \addstackgap adds a vertical buffer above and below its argument. The default is 3pt, but I reset that to 2pt in the preamble with the \setstackgap invocation.

\documentclass[a4paper]{article}

\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{siunitx}
\usepackage{multirow}
\usepackage{caption}

\usepackage{tabstackengine}
\TABstackMath
\setstackgap{S}{2pt}
\begin{document}

\begin{table}[!htb]
    \centering
    %   \scriptsize % sets table text size
    \captionsetup{font=scriptsize} % sets the table's caption size 
    \caption{Transformation of the Cartesian coordinates under the symmetry group 
            $D_{2}=V$ and the corresponding transformation of the Eulerian angles}
    \begin{center}
      \label{tab:tb2}
      \begin{tabular}{ccc}
        \hline
        \small Symmetry    & \small Cartesian coordinate  & \small Euler angle \\
        \small operation   & \small transformation        & \small transformation\\
        \hline
        $E$ &
        \addstackgap{\alignCenterstack{x'\to& x\\y'\to& y\\z'\to& z\phantom{-}}} &
        \alignCenterstack{\phi'\to& \phi\\\theta'\to& \theta\\\chi'\to& \chi\phantom{{}-\pi}} 
\\
        $C_2(x)$ &
        \addstackgap{\alignCenterstack{x'\to& x\\y'\to& -y\\z'\to& -z}} &
        \alignCenterstack{\phi'\to& \pi+\phi\\\theta'\to& \pi-\theta\\\chi'\to& -\chi} 
\\
        $C_2(y)$ &
        \addstackgap{\alignCenterstack{x'\to& -x\\y'\to& y\\z'\to& -z}} &
        \alignCenterstack{\phi'\to& \pi+\phi\\\theta'\to& \pi-\theta\\\chi'\to& \pi -\chi} 
\\
        $C_2(z)$ &
        \addstackgap{\alignCenterstack{x'\to& -x\\y'\to& -y\\z'\to& z}} &
        \alignCenterstack{\phi'\to& \phi\\\theta'\to& \theta\\\chi'\to& \pi +\chi} 
\\
\hline
        \end{tabular}
    \end{center}
\end{table}

\end{document}

enter image description here

  • Can you explain what the commands you added do? – Alex Reinking May 8 '19 at 0:04
  • @AlexReinking I have added descriptive text. – Steven B. Segletes May 8 '19 at 0:46
3
\documentclass[a4paper]{article}


\usepackage{siunitx}

\usepackage{caption}
\usepackage{calc}
\usepackage{ragged2e}

\newlength{\columntwo}
\setlength{\columntwo}{\widthof{Cartesian coordinate}}

\newlength{\columnthree}
\setlength{\columnthree}{\widthof{transformation}}

\begin{document}

\begin{table}[!htb]
    \centering
    %   \scriptsize % sets table text size
    \captionsetup{font=scriptsize} % sets the table's caption size 
    \caption{Transformation of the Cartesian coordinates under the symmetry group $D_{2}=V$ and the corresponding transformation of the Eulerian angles}
        \label{tab:tb2}
        \begin{tabular}{c
                       >{\RaggedLeft}p{0.5\columntwo-2\tabcolsep}@{~$\to$~}
                       >{\RaggedRight}p{0.5\columntwo-2\tabcolsep}
                       >{\RaggedLeft}p{0.5\columnthree-2\tabcolsep}@{~$\to$~}
                       >{\RaggedRight}p{0.5\columnthree-2\tabcolsep}}
            \hline
            \small Symmetry          & \multicolumn{2}{c}{\small Cartesian coordinate}   & \multicolumn{2}{c}{\small Euler angle}  \\
            \small operation         & \multicolumn{2}{c}{\small transformation}        &  \multicolumn{2}{c}{\small transformation} \\
            \hline
            & $x'$ & $x$                                  & $\phi'$ & $\phi$                         \\
   $E$      & $y'$ & $y$                                  & $\theta'$ & $\theta$                     \\
            & $z'$ & $z$                                  & $\chi'$ & $\chi$                         \\
            \hline
            & $x'$ & $x$                                  & $\phi'$ & $\pi + \phi$                   \\
$C_{2}(x)$  & $y'$ &  $-y$                                 & $\theta'$ & $\pi - \theta$               \\
            & $z'$ & $-z$                                 & $\chi'$ & $-\chi$                        \\
        \end{tabular}
\end{table}




\end{document}

The exact proportions of the left and right aligned columns ight still need to be fine tuned according to the width of the contents.

enter image description here

  • Maybe you should make the right/left hand sides of the arrows considerably longer to make the alignment clearer in your MWE. – user156344 May 7 '19 at 17:58
3

This is just a side-remark. I personally would not add so much redundant/repeating information, which all the <something>\to is.

\documentclass[a4paper]{article}

\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{booktabs}
\usepackage{caption}

\begin{document}

\begin{table}[!htb]
    \centering
    %   \scriptsize % sets table text size
    \captionsetup{font=scriptsize} % sets the table's caption size 
    \caption{Transformation of the Cartesian coordinates under the symmetry group $D_{2}=V$ and the corresponding transformation of the Eulerian angles}
    \begin{center}
        \label{tab:tb2}
        \begin{tabular}{ccccccc}
            \toprule
            \small Symmetry          & \multicolumn{3}{c}{\small Cartesian
            coordinate}  &  \multicolumn{3}{c}{\small Euler angle}  \\
            \small operation         & \multicolumn{6}{c}{\small transformation}   
                \\
            & $x'$  & $y'$  & $z'$  & $\phi'$ & $\theta'$ & $\chi'$ \\
            \midrule
            $E$ & $x$ & $y$ & $z$   & $\phi$ & $\theta$ & $\chi$    \\
            $C_2(x)$ & $x$ & $-y$   & $-z$  & $\pi + \phi$ & $\pi - \theta$ & $ -\chi$  \\
            $C_2(y)$ & $-x$ & $y$   & $-z$  & $\pi + \phi$ & $\pi - \theta$ &
            $\pi-\chi$  \\
            $C_2(z)$ & $-x$ & $-y$  & $z$   & $\phi$ & $\theta$ &   $\pi+\chi$  \\
            \bottomrule
        \end{tabular}
    \end{center}
\end{table}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.