Search code examples
latexequationtabular

Extra alignment in tabular array


I am trying to center one of the columns in a table and It says I have an extra column. The table also doesnt look correct i.e.

What it looks like:

F(t) F(s)
     u(t)
1/s
e    1/(s-a)

What I expect:

F(t) F(s)
u(t) 1/s
e    1/(s-a)

I think it is because I'm trying to insert an equation in the table but I'm not sure.

Here is the code

\documentclass[12pt, letterpaper, fleqn]{article}
\usepackage{array}

\begin{document}
\begin{table}
  % \setlength{\tabcolsep}{6pt}
  % \renewcommand{\arraystretch}{1}
  \begin{tabular}{p{0.225\textwidth}  >{\centering}p{0.15\textwidth}}
    \textbf{F(t)} & \textbf{F(s)} \\
    \(u(t)\) & \(\frac{1}{s}\) \\ 
    \(e^{at}\) & \(\frac{1}{s-a}\) \\
  \end{tabular}
\end{table}
\end{document}

Solution

  • Your use of \centering to centre the column works, but it screws up the way \\ is interpreted. A correction is included in the array package documentation after using alignment switches (like \centering, \raggedright, \raggedleft, etc) using \arraybackslash:

    enter image description here

    \documentclass{article}
    
    \usepackage{array}
    
    \begin{document}
    
    \begin{tabular}{ p{0.225\textwidth} >{\centering\arraybackslash}p{0.15\textwidth} }
      $\mathbf{F(t)}$ & $\mathbf{F(s)}$ \\
      $u(t)$          &    $1 / s$      \\
      $e^{at}$        & $1 / (s - a)$
    \end{tabular}
    
    \end{document}