# Creating tables with enumeration in LaTeX

I want to create the following table:

The MWE is as follows:

\documentclass{article}
\begin{document}
\begin{tabular}{|c|c|c|c|}
\hline
% after \\: \hline or \cline{col1-col2} \cline{col3-col4} ...
Name of the Service & Description & Input & Output \\
creditAccount & To credit a bank account & \begin{enumerate}\item Account Number \item Amount \end{enumerate} & \begin{enumerate}\item Message – Whether the credit was successful or not \item Current Account Balance
\end{enumerate} \\
&  &  &  \\
&  &  &  \\
&  &  &  \\
&  &  &  \\
&  &  &  \\
\hline
\end{tabular}
\end{document}


What is wrong with my approach?

The following provides the desired layout of the table (without colour):

\documentclass{article}
\usepackage[margin=1in]{geometry}% Just for this example

\usepackage{tabularx,array,booktabs}
\newcolumntype{N}{@{}>{\stepcounter{enumi}\theenumi.~}l@{}}
\newcolumntype{M}{@{}>{\stepcounter{enumi}\theenumi.~}p{\linewidth}@{}}
\newenvironment{listenv}
{\setcounter{enumi}{0}% Reset list counter
\begin{tabular}[t]}
{\end{tabular}}

\begin{document}

\noindent
\begin{tabularx}{\textwidth}{ >{\centering\arraybackslash}X *{3}{X} }
\toprule
\textbf{Name of the Service} & \textbf{Description} & \textbf{Input} & \textbf{Output} \\
\midrule
% Credit Account =====
creditAccount & To credit a bank account & \begin{listenv}{N}
Account Number \\ Amount
\end{listenv} & \begin{listenv}{M}
Message -- Whether the credit was successful or not \\
Current Account Balance
\end{listenv} \\
% Credit Transaction Details =====
creditTransactionDetails & To get the details of the last credit transaction & \begin{listenv}{N}
Account Number
\end{listenv} &
Message -- With the amount last credited in the account \\
% Debit Account =====
debitAccount & To debit from a bank account & \begin{listenv}{N}
Account Number \\ Amount
\end{listenv} & \begin{listenv}{M}
Message -- Whether the debit was successful or not \\
Current Account Balance
\end{listenv} \\
% Debit Transaction Details =====
debitTransactionDetails & To get the details of the last debit transaction & \begin{listenv}{N}
Account Number
\end{listenv} &
Message -- With the amount last debited in the account \\
% Get Account Balance =====
getAccountBalance & To get the balance in the account & \begin{listenv}{N}
Account Number
\end{listenv} &
Message -- With the balance in the account \\
% Get Credit Card Amount =====
getCreditCardAmount & To get amount spent through credit card & \begin{listenv}{N}
Account Number
\end{listenv} &
Message -- With the amount spent with Credit Card \\
\bottomrule
\end{tabularx}

\end{document}


The enumeration is manually inserted using array's >{...} directive. listenv automates the process of resetting the enumi counter - typically used in the first level of an enumerate list.