[Tex/LaTex] Longtable of size \textwidth exceeds right margin

marginstables

I try to create a table with the longtable package that fits into the whole text width available. Here's my code:

\documentclass{article}
\usepackage{longtable}
\usepackage{amsmath}

\title{Raccolta delle formule}
\author{}
\date{}
\begin{document}
   \maketitle
   \begin{longtable}{p{.33\columnwidth} | p{.33\columnwidth} | p{.33\columnwidth} }
      \Large Descrizione & \Large Formula & \Large Esempio\\
      \hline
      \endhead

      Prodotto di due polinomi &
      {
         \begin{align*}
            (a+b)(c+d)&=a(c+d)+b(c+d)\\
                        &=ac+ad+bc+bd 
         \end{align*}
      }&
      {
            \begin{align*}
               (2x+3)(3y-5)&=6xy-10x+9y-15
            \end{align*}
      }\\
   \end{longtable} 

\end{document}

The result is, that the table exceeds the right margin (see picture). What is wrong with the code?

enter image description here

Best Answer

Here is a possible solution, using the xltabular environment, which brings the functionalities of longtable to tabularx, playing with the value of the inter-column spacing, changing the alignment point:

\documentclass{article}
\usepackage{showframe}
\renewcommand{\ShowFrameLinethickness}{0.3pt}
\usepackage{longtable}
\usepackage{xltabular}
\usepackage{mathtools}

\title{Raccolta delle formule}
\author{Geppetto}
\date{}

\begin{document}
   \maketitle

\setlength{\tabcolsep}{4pt}
\setlength{\extrarowheight}{4pt}
\begin{xltabular}{\linewidth}{l|X|X}
      \Large Descrizione & \Large Formula & \Large Esempio\\
      \hline
      \endhead

      Prodotto di due polinomi
      & $ \begin{aligned}[t]
            (a&+b)(c+d) \\ & =a(c+d)+b(c+d)\\
                        &=ac+ad+bc+bd
         \end{aligned} $
      & $\begin{aligned}[t]
               &(2x +3)(3y-5)\\ & =6xy-10x+9y-15
            \end{aligned}$ \\
\end{xltabular}

\end{document} 

enter image description here