1

I have tried both \hline and \bottom rule, but for some reason I cannot get a bottom horizontal line on my table.

\documentclass{report}
\usepackage{amsmath}
\begin{document}
\begin{center}
    \captionof{table}{Table of Legendre Polynomials\label{Tab:Tcr}}
    \begin{tabular}{|l|}
    \hline
    \parbox{3cm}
    {\begin{align*}
    P_0(x) &= 1\\
    P_1(x) &= x\\
    P_2(x) &= \frac{1}{2} \left(3x^2 -1\right)\\
    P_3(x) &= \frac{1}{2} \left(5x^3 - 3x\right)\\
    P_4(x) &= \frac{1}{8} \left(35x^4 - 30x^2 + 3\right)\\
    P_5(x) &= \frac{1}{8}\left(63x^5 - 70x^3 + 15x\right)\\
    P_6(x) &= \frac{1}{16}\left(231x^6 - 315x^4 + 105x^2 -5\right)\\
    P_7(x) &= \frac{1}{16}\left(429x^7 - 693x^5 + 315x^3 - 35x\right)\\
    P_8(x) &= \frac{1}{128}\left(6435x^8 - 12012x^6 + 6930x^4 - 1260x^2 + 35\right)
    \end{align*}}\\
    \hline
    \end{tabular}
\end{center}
\end{document}

enter image description here

6
  • Welcome to TSE. Please post a Minimal Working Example, instead of a code snippet. Commented Apr 17, 2020 at 16:51
  • 1
    add a \\ after \end{align*}}.
    – CarLaTeX
    Commented Apr 17, 2020 at 16:52
  • Solved thank you! I needed the two \\ after \end{align*}}. How do I mark the question as answered?
    – Lauren
    Commented Apr 17, 2020 at 17:42
  • 1
    @CarLaTeX eill probably add an answer in a bit, but for future please check examples posted, the one above produces ! Undefined control sequence. l.5 \captionof Commented Apr 17, 2020 at 18:04
  • Recommendation: read log file. There is an error message: misplaced \noalign (\hline->\noalign...) . This means that the \hline is at bad position, it must follow the end of table row (\cr in TeX or \\ in LaTeX). The result: there wasn't end line mark \\ before \hline.
    – wipet
    Commented Apr 17, 2020 at 19:18

2 Answers 2

2

You don't need to guess the width. Use \fbox if you really want to box the table.

With \openup2\jot you get a more open look.

I removed all \left and \right that only damage the spacing.

\documentclass{report}
\usepackage{amsmath}
\usepackage{caption}

\begin{document}

\begin{table}
\centering

\caption{Table of Legendre Polynomials\label{Tab:Tcr}}

\fbox{\openup2\jot$\begin{aligned}
  P_0(x) &= 1\\
  P_1(x) &= x\\
  P_2(x) &= \frac{1}{2} (3x^2 -1)\\
  P_3(x) &= \frac{1}{2} (5x^3 - 3x)\\
  P_4(x) &= \frac{1}{8} (35x^4 - 30x^2 + 3)\\
  P_5(x) &= \frac{1}{8}(63x^5 - 70x^3 + 15x)\\
  P_6(x) &= \frac{1}{16}(231x^6 - 315x^4 + 105x^2 -5)\\
  P_7(x) &= \frac{1}{16}(429x^7 - 693x^5 + 315x^3 - 35x)\\
  P_8(x) &= \frac{1}{128}(6435x^8 - 12012x^6 + 6930x^4 - 1260x^2 + 35)
  \end{aligned}$}

\end{table}

\end{document}

enter image description here

1

The content of a table environment is not necessarily a real tabular environment.

It is much simpler to do that align* via the empheq package, which defines a box key. Needless to load amsmath in this case, since empheq loads mathtools, which loads amsmath.

Here is an example of what can be done, with a coloured frame, a better vertical spacing for this context) of the lines with the linespread environment and medium-sized fractions for numerical coefficients (these are defined in package nccmath, to be loaded before mathtools or empheq):

\documentclass{report}

\usepackage[svgnames]{xcolor}
\usepackage{nccmath}
\usepackage{empheq}
\usepackage{caption}

\newcommand*\widecolbox[1]{\fcolorbox{IndianRed}{white}{\hspace{1em}#1\hspace{1em}}}

\begin{document}

\begin{table}[!htb]
    \caption{Table of Legendre Polynomials\label{Tab:Tcr}}
   \begin{spreadlines}{1.5ex}\begin{empheq}[box=\widecolbox]{align*}
    P_0(x) &= 1\\
    P_1(x) &= x\\
    P_2(x) &= \mfrac{1}{2} \left(3x^2 -1\right)\\
    P_3(x) &= \mfrac{1}{2} \left(5x^3 - 3x\right)\\
    P_4(x) &= \mfrac{1}{8} \left(35x^4 - 30x^2 + 3\right)\\
    P_5(x) &= \mfrac{1}{8}\left(63x^5 - 70x^3 + 15x\right)\\
    P_6(x) &= \mfrac{1}{16}\left(231x^6 - 315x^4 + 105x^2 -5\right)\\
    P_7(x) &= \mfrac{1}{16}\left(429x^7 - 693x^5 + 315x^3 - 35x\right)\\
    P_8(x) &= \mfrac{1}{128}\left(6435x^8 - 12012x^6 + 6930x^4 - 1260x^2 + 35\right)
   \end{empheq}\end{spreadlines}
\end{table}

\end{document} 

enter image description here

You must log in to answer this question.

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