2

I have a table with lots of equations. It is ugly if all equations are typeset irregularly. I have searched about this point but non of these answers worked for me: Align equations inside tabular, Two columns of equations, aligned and just one number per column, Aligned equations in tables.

Could please help me with aligning the equations within the columns. Here is my table:

\documentclass{article}

\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}

\usepackage{array,booktabs}   % for \newcolumntype macro
\newcolumntype{L}{>{$}l<{$}} % math-mode version of "l" column type
\newcolumntype{C}{>{$}c<{$}} % math-mode version of "l" column type
\newcolumntype{R}{>{$}r<{$}} % math-mode version of "l" column type

\begin{document}

\begin{table}
\centering

\begin{tabular}{CCCC}  \hline
\lambda =0& \lambda =1& \lambda =2& \lambda =3 \\ \hline
1 & \tfrac{2}{\sqrt{\pi}} = 1.128 & \tfrac{3}{2} = 1.500 & \tfrac{4}{\sqrt{\pi}} = 2.257 \\
2 \sqrt{\tfrac{2}{3 \pi}} = 0.921 & \sqrt{\tfrac{3}{2}} = 1.225 & 4 \sqrt{\tfrac{2}{3 \pi}} = 1.843 & \tfrac{5}{2}\sqrt{\tfrac{3}{2}} = 3.062 \\
0 & - \sqrt{\tfrac{2}{3 \pi}}= -0.461 & - \sqrt{\tfrac{3}{2}} = -1.225 & - 2\sqrt{\tfrac{6}{\pi}} = -2.764 \\
\sqrt{\tfrac{3}{5}} = 0.775 & \tfrac{8}{\sqrt{15 \pi}} =  1.165 & \tfrac{\sqrt{15}}{2} = 1.936 & 8 \sqrt{\tfrac{3}{5 \pi}} = 3.496 \\
8 \sqrt{\tfrac{2}{105 \pi }} =0.623 & \sqrt{\tfrac{15}{14}}=1.035 & 8 \sqrt{\tfrac{6}{35 \pi }} = 1.869 & \tfrac{1}{2}\sqrt{\tfrac{105}{2}} = 3.623 \\
\tfrac{2}{\sqrt{15 \pi }} = 0.291 & 0 & -\tfrac{4}{\sqrt{15 \pi }} = -0.583 & -\tfrac{\sqrt{15}}{2} = -1.936 \\
1 & \tfrac{8}{3 \sqrt{\pi }} = 1.505 & \tfrac{5}{2} = 2.500 & \tfrac{8}{\sqrt{\pi }} = 4.514 \\
-\tfrac{2}{3 \sqrt{\pi }} = -0.376 & -1 & -\tfrac{4}{\sqrt{\pi }} = -2.257 & -5 \\
\tfrac{8}{3} \sqrt{\tfrac{2}{5 \pi }} = 0.951 & \sqrt{\tfrac{5}{2}} = 1.581 & 8 \sqrt{\tfrac{2}{5 \pi }} = 2.855 & \tfrac{7 }{2}\sqrt{\tfrac{5}{2}} = 5.534 \\
\sqrt{\tfrac{5}{7}} = 0.845 & \tfrac{16}{\sqrt{35 \pi }} = 1.526 & \tfrac{\sqrt{35}}{2} = 2.958 & \tfrac{64}{\sqrt{35 \pi }} = 6.103 \\
0 & -\tfrac{4}{3} \sqrt{\tfrac{2}{5 \pi }} = -0.476 & -\sqrt{\tfrac{5}{2}} = -1.581 & -12 \sqrt{\tfrac{2}{5 \pi }} = -4.282 \\
1 & \tfrac{3}{\sqrt{\pi }} = 1.693 & \tfrac{7}{2} = 3.500 & \tfrac{14}{\sqrt{\pi }} = 7.899 \\
-\sqrt{\tfrac{2}{5}} = -0.632 & -4 \sqrt{\tfrac{2}{5 \pi }} = -1.427 & -\sqrt{10} =-3.162 & -4 \sqrt{\tfrac{10}{\pi }} = -7.136 \\
-\tfrac{8}{\sqrt{35 \pi }} = -0.763 & -2 \sqrt{\tfrac{5}{7}} = -1.690 & -8 \sqrt{\tfrac{5}{7 \pi }} = -3.815 & -\tfrac{3 \sqrt{35}}{2} = -8.874 \\
\tfrac{7}{3} \sqrt{\tfrac{2}{5 \pi }} = 0.833 & \sqrt{\tfrac{5}{2}} = 1.581 & 2 \sqrt{\tfrac{10}{\pi }} = 3.568 & \tfrac{11}{2} \sqrt{\tfrac{5}{2}} = 8.696 \\
1 & \tfrac{16}{5 \sqrt{\pi }} = 1.805 & \tfrac{7}{2} = 3.500 & \tfrac{64}{5 \sqrt{\pi }} = 7.222 \\
\tfrac{16}{5} \sqrt{\tfrac{2}{7 \pi }} = 0.965 & \sqrt{\tfrac{7}{2}} = 1.871 & \tfrac{64}{5} \sqrt{\tfrac{2}{7 \pi }} = 3.860 & \tfrac{9}{2} \sqrt{\tfrac{7}{2}} = 8.419 \\
-\tfrac{8}{15 \sqrt{\pi }} = -0.301 & -1 & -\tfrac{24}{5 \sqrt{\pi }} = -2.708 & -7 \\
1 & \tfrac{128}{35 \sqrt{\pi }} = 2.063 & \tfrac{9}{2} = 4.500 & \tfrac{128}{7 \sqrt{\pi }} = 10.317 \\
-\sqrt{\tfrac{2}{7}} = -0.534 & -\tfrac{24}{5} \sqrt{\tfrac{2}{7 \pi }}  = -1.448 & -\sqrt{14} = -3.742 & -32 \sqrt{\tfrac{2}{7 \pi }} = -9.650 \\
1 & \tfrac{52}{15 \sqrt{\pi }} = 1.956 & \tfrac{9}{2} = 4.500 & \tfrac{20}{\sqrt{\pi }} = 11.284 \\ \hline
\end{tabular}
\end{table}

\end{document}

2 Answers 2

1

Here is one version, where the single numbers (not rounded from square roots) are aligned after the =. Using one of the commented lines instead will yield them centered or left-aligned. Take your pick.

\documentclass{article}
\usepackage{geometry}
\usepackage{amsmath}
% \usepackage{amsfonts} loaded by amssymb
\usepackage{amssymb}

\usepackage{array} % for \newcolumntype macro
\newcolumntype{L}{>{${}}l<{$}} % math-mode version of "l" column type with opening empty group
\newcolumntype{C}{>{$}c<{$}} % math-mode version of "c" column type
\newcolumntype{R}{>{$}r<{$}} % math-mode version of "R" column type
\usepackage{booktabs} % for nicer tables

\begin{document}

\begin{table}
\centering
\renewcommand*{\arraystretch}{2}%
\newcommand*{\dblcol}[1]{&\phantom{{}={}}{#1}}%
% alternatively:
% \newcommand*{\dblcol}[1]{\multicolumn{2}{C}{#1}}%
% \newcommand*{\dblcol}[1]{#1&}%
\begin{tabular}{*{4}{R@{}L}}
\toprule
\multicolumn{2}{C}{\lambda =0}& \multicolumn{2}{C}{\lambda =1} & \multicolumn{2}{C}{\lambda =2} & \multicolumn{2}{C}{\lambda =3} \\
\midrule
\dblcol{1} & \tfrac{2}{\sqrt{\pi}} &= 1.128 & \tfrac{3}{2} &= 1.500 & \tfrac{4}{\sqrt{\pi}} &= 2.257 \\
2 \sqrt{\tfrac{2}{3 \pi}} &= 0.921 & \sqrt{\tfrac{3}{2}} &= 1.225 & 4 \sqrt{\tfrac{2}{3 \pi}} &= 1.843 & \tfrac{5}{2}\sqrt{\tfrac{3}{2}} &= 3.062 \\
\dblcol{0} & - \sqrt{\tfrac{2}{3 \pi}}&= -0.461 & - \sqrt{\tfrac{3}{2}} &= -1.225 & - 2\sqrt{\tfrac{6}{\pi}} &= -2.764 \\
\sqrt{\tfrac{3}{5}} &= 0.775 & \tfrac{8}{\sqrt{15 \pi}} &=  1.165 & \tfrac{\sqrt{15}}{2} &= 1.936 & 8 \sqrt{\tfrac{3}{5 \pi}} &= 3.496 \\
8 \sqrt{\tfrac{2}{105 \pi }} &=0.623 & \sqrt{\tfrac{15}{14}}&=1.035 & 8 \sqrt{\tfrac{6}{35 \pi }} &= 1.869 & \tfrac{1}{2}\sqrt{\tfrac{105}{2}} &= 3.623 \\
\tfrac{2}{\sqrt{15 \pi }} &= 0.291 & \dblcol{0} & -\tfrac{4}{\sqrt{15 \pi }} &= -0.583 & -\tfrac{\sqrt{15}}{2} &= -1.936 \\
\dblcol{1} & \tfrac{8}{3 \sqrt{\pi }} &= 1.505 & \tfrac{5}{2} &= 2.500 & \tfrac{8}{\sqrt{\pi }} &= 4.514 \\
-\tfrac{2}{3 \sqrt{\pi }} &= -0.376 &  \dblcol{-1} & -\tfrac{4}{\sqrt{\pi }} &= -2.257 &  \dblcol{-5} \\
\tfrac{8}{3} \sqrt{\tfrac{2}{5 \pi }} &= 0.951 & \sqrt{\tfrac{5}{2}} &= 1.581 & 8 \sqrt{\tfrac{2}{5 \pi }} &= 2.855 & \tfrac{7 }{2}\sqrt{\tfrac{5}{2}} &= 5.534 \\
\sqrt{\tfrac{5}{7}} &= 0.845 & \tfrac{16}{\sqrt{35 \pi }} &= 1.526 & \tfrac{\sqrt{35}}{2} &= 2.958 & \tfrac{64}{\sqrt{35 \pi }} &= 6.103 \\
\dblcol{0} & -\tfrac{4}{3} \sqrt{\tfrac{2}{5 \pi }} &= -0.476 & -\sqrt{\tfrac{5}{2}} &= -1.581 & -12 \sqrt{\tfrac{2}{5 \pi }} &= -4.282 \\
\dblcol{1} & \tfrac{3}{\sqrt{\pi }} &= 1.693 & \tfrac{7}{2} &= 3.500 & \tfrac{14}{\sqrt{\pi }} &= 7.899 \\
-\sqrt{\tfrac{2}{5}} &= -0.632 & -4 \sqrt{\tfrac{2}{5 \pi }} &= -1.427 & -\sqrt{10} &=-3.162 & -4 \sqrt{\tfrac{10}{\pi }} &= -7.136 \\
-\tfrac{8}{\sqrt{35 \pi }} &= -0.763 & -2 \sqrt{\tfrac{5}{7}} &= -1.690 & -8 \sqrt{\tfrac{5}{7 \pi }} &= -3.815 & -\tfrac{3 \sqrt{35}}{2} &= -8.874 \\
\tfrac{7}{3} \sqrt{\tfrac{2}{5 \pi }} &= 0.833 & \sqrt{\tfrac{5}{2}} &= 1.581 & 2 \sqrt{\tfrac{10}{\pi }} &= 3.568 & \tfrac{11}{2} \sqrt{\tfrac{5}{2}} &= 8.696 \\
\dblcol{1} & \tfrac{16}{5 \sqrt{\pi }} &= 1.805 & \tfrac{7}{2} &= 3.500 & \tfrac{64}{5 \sqrt{\pi }} &= 7.222 \\
\tfrac{16}{5} \sqrt{\tfrac{2}{7 \pi }} &= 0.965 & \sqrt{\tfrac{7}{2}} &= 1.871 & \tfrac{64}{5} \sqrt{\tfrac{2}{7 \pi }} &= 3.860 & \tfrac{9}{2} \sqrt{\tfrac{7}{2}} &= 8.419 \\
-\tfrac{8}{15 \sqrt{\pi }} &= -0.301 & \dblcol{-1} & -\tfrac{24}{5 \sqrt{\pi }} &= -2.708 & \dblcol{-7} \\
\dblcol{1} & \tfrac{128}{35 \sqrt{\pi }} &= 2.063 & \tfrac{9}{2} &= 4.500 & \tfrac{128}{7 \sqrt{\pi }} &= 10.317 \\
-\sqrt{\tfrac{2}{7}} &= -0.534 & -\tfrac{24}{5} \sqrt{\tfrac{2}{7 \pi }}  &= -1.448 & -\sqrt{14} &= -3.742 & -32 \sqrt{\tfrac{2}{7 \pi }} &= -9.650 \\
\dblcol{1} & \tfrac{52}{15 \sqrt{\pi }} &= 1.956 & \tfrac{9}{2} &= 4.500 & \tfrac{20}{\sqrt{\pi }} &= 11.284 \\
\bottomrule
\end{tabular}
\end{table}

\end{document}

enter image description here

1

Like this?

enter image description here

With use of the array package:

\documentclass{article}
\usepackage{nccmath, amssymb}
\usepackage{array,booktabs}
\NewExpandableDocumentCommand\mcc{O{1}m}
    {\multicolumn{#1}{c}{#2}}

\begin{document}
    \[\setlength\arraycolsep{1pt}
\begin{array}{@{\ } c@{\quad} rl c@{\quad}c rl c@{\quad}c  rl c@{\quad}c rl @{\ }}  
    \toprule
x    &   \lambda & = 0 
        &&& \lambda & = 1 
            &&& \lambda & = 2 
                &&& \lambda & = 3   \\ 
    \midrule
1   & \mfrac{2}{\sqrt{\pi}} & = 1.128 
        &&& \mfrac{3}{2} & = 1.500 
            &&& \mfrac{4}{\sqrt{\pi}} & = 2.257             
                &&& &                                           \\
    \addlinespace
2   & \sqrt{\mfrac{2}{3 \pi}} & = 0.921 
        &&& \sqrt{\mfrac{3}{2}} & = 1.225 
            &&& 4\sqrt{\mfrac{2}{3 \pi}} & = 1.843 
                &&& \mfrac{5}{2}\sqrt{\mfrac{3}{2}} & = 3.062   \\
    \addlinespace
0   & - \sqrt{\mfrac{2}{3 \pi}} & = -0.461 
        &&& - \sqrt{\mfrac{3}{2}} & = -1.225 
            &&& - 2\sqrt{\mfrac{6}{\pi}} & = -2.764             
                &&& &   \\
    \addlinespace
    & \sqrt{\mfrac{3}{5}} & = 0.775 
        &&& \mfrac{8}{\sqrt{15 \pi}} & =  1.165 
            &&& \mfrac{\sqrt{15}}{2} & = 1.936 
                &&& 8 \sqrt{\mfrac{3}{5 \pi}} & = 3.496 \\
    \addlinespace
    & 8 \sqrt{\mfrac{2}{105 \pi }} & = 0.623 
        &&& \sqrt{\mfrac{15}{14}} & = 1.035 
            &&& 8 \sqrt{\mfrac{6}{35 \pi }} & = 1.869 
                &&& \mfrac{1}{2}\sqrt{\mfrac{105}{2}} & = 3.623 \\
    \addlinespace
    & \mfrac{2}{\sqrt{15 \pi }} & = 0.291 
        &&& \mcc[2]{0}
            &&& -\mfrac{4}{\sqrt{15 \pi }} & = -0.583 
                &&& -\mfrac{\sqrt{15}}{2} & = -1.936 \\
    \addlinespace
1   & \mfrac{8}{3 \sqrt{\pi }} & = 1.505 
        &&& \mfrac{5}{2} & = 2.500 
            &&& \mfrac{8}{\sqrt{\pi }} & = 4.514 
                &&& &   \\
    \addlinespace
    & -\mfrac{2}{3 \sqrt{\pi }} & = -0.376 
        &&& \mcc[2]{-1} 
            &&& -\mfrac{4}{\sqrt{\pi }} & = -2.257 
                &&& \mcc[2]{-5} \\
    \addlinespace
    & \mfrac{8}{3} \sqrt{\mfrac{2}{5 \pi }} & = 0.951 
        &&& \sqrt{\mfrac{5}{2}} & = 1.581 
            &&& 8 \sqrt{\mfrac{2}{5 \pi }} & = 2.855 
                &&& \mfrac{7 }{2}\sqrt{\mfrac{5}{2}} & = 5.534 \\
    \addlinespace
    & \sqrt{\mfrac{5}{7}} & = 0.845 
        &&& \mfrac{16}{\sqrt{35 \pi }} & = 1.526 
            &&& \mfrac{\sqrt{35}}{2} & = 2.958 
                &&& \mfrac{64}{\sqrt{35 \pi }} & = 6.103 \\
    \addlinespace
0   & -\mfrac{4}{3} \sqrt{\mfrac{2}{5 \pi }} & = -0.476 
        &&& -\sqrt{\mfrac{5}{2}} & = -1.581 
            &&& -12 \sqrt{\mfrac{2}{5 \pi }} & = -4.282 
                &&& &   \\
    \addlinespace
1   & \mfrac{3}{\sqrt{\pi}} & = 1.693 
        &&& \mfrac{7}{2} & = 3.500 
            &&& \mfrac{14}{\sqrt{\pi }} & = 7.899 
                &&& &   \\
    \addlinespace
    & -\sqrt{\mfrac{2}{5}} & = -0.632 
        &&& -4 \sqrt{\mfrac{2}{5 \pi }} & = -1.427 
            &&& -\sqrt{10} & = -3.162 
                &&& -4 \sqrt{\mfrac{10}{\pi }} & = -7.136 \\
    \addlinespace
    & -\mfrac{8}{\sqrt{35 \pi }} & = -0.763 
        &&& -2 \sqrt{\mfrac{5}{7}} & = -1.690 
            &&& -8 \sqrt{\mfrac{5}{7 \pi }} & = -3.815 
                &&& -\mfrac{3 \sqrt{35}}{2} & = -8.874 \\
    \addlinespace
    & \mfrac{7}{3} \sqrt{\mfrac{2}{5 \pi }} & = 0.833 
        &&& \sqrt{\mfrac{5}{2}} & = 1.581 
            &&& 2 \sqrt{\mfrac{10}{\pi }} & = 3.568 
                &&& \mfrac{11}{2} \sqrt{\mfrac{5}{2}} & = 8.696 \\
    \addlinespace
1   & \mfrac{16}{5 \sqrt{\pi }} & = 1.805
        &&& \mfrac{7}{2} & = 3.500 
            &&& \mfrac{64}{5 \sqrt{\pi }} & = 7.222 
                &&& &   \\
    \addlinespace
    & \mfrac{16}{5} \sqrt{\mfrac{2}{7 \pi }} & = 0.965 
        &&& \sqrt{\mfrac{7}{2}} & = 1.871 
            &&& \mfrac{64}{5} \sqrt{\mfrac{2}{7 \pi }} & = 3.860 
                &&& \mfrac{9}{2} \sqrt{\mfrac{7}{2}} & = 8.419 \\
    \addlinespace
    & -\mfrac{8}{15 \sqrt{\pi }} & = -0.301 
        &&& \mcc[2]{-1}
            &&& -\mfrac{24}{5 \sqrt{\pi }} & = -2.708 
                &&& \mcc[2]{-7}  \\
    \addlinespace
1   & \mfrac{128}{35 \sqrt{\pi }} & = 2.063 
        &&& \mfrac{9}{2} & = 4.500 
            &&& \mfrac{128}{7 \sqrt{\pi }} & = 10.317 
                &&& &   \\
    \addlinespace
    & -\sqrt{\mfrac{2}{7}} & = -0.534 
        &&& -\mfrac{24}{5} \sqrt{\mfrac{2}{7 \pi }}  & = -1.448 
            &&& -\sqrt{14} & = -3.742 
                &&& -32 \sqrt{\mfrac{2}{7 \pi }} & = -9.650     \\
    \addlinespace
1   & \mfrac{52}{15 \sqrt{\pi }} & = 1.956 
        &&& \mfrac{9}{2} & = 4.500 
            &&& \mfrac{20}{\sqrt{\pi }} & = 11.284 
                &&& &   \\ 
    \bottomrule
\end{array}
    \]
\end{document}
1
  • @meantime you select another answer ,,, anyway, you have old LaTeX installation ...
    – Zarko
    Feb 22, 2021 at 14:59

You must log in to answer this question.

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