0

How convert the following table to longtable with the same setting. I have problem with enumerate and correct size row and {tabular} not working in longtable

\documentclass{article}

\usepackage{longtable}
\usepackage{array}

\title{A longtable example}

\begin{document}
\begin{table}[ht]
\caption{scene}
\label{table:econ:programmers}
\begin{tabular}{| >{\raggedright}p{0.20\linewidth} 
          | >{\raggedright}p{0.28\linewidth} 
          | >{\raggedright}p{0.28\linewidth} 
          | >{\raggedright\arraybackslash}p{0.12\linewidth}|}
 \hline
 question & step & result & yes/no \\
 \hline
 Ask-1 & \begin{enumerate}
        \item[1)] some change 1;
        \item[2)] some change 2;
    \end{enumerate}
     & message & Yes \\

 \hline
 Ask-2 & \begin{enumerate}
        \item[1)] some change 1;
        \item[2)] some change 2;
    \end{enumerate}
     & message & Yes \\

 \hline
 Ask-3 & \begin{enumerate}
        \item[1)] some change 1;
        \item[2)] some change 2;
    \end{enumerate}
     & message & Yes \\

 \hline
 \end{tabular}
 \end{table}

 \end{document}

I have many more lines in this table.

Ok, I edited code to longtable, but caption and label not working now. Error: LaTeX Error: \caption outside float. See code:

\documentclass{article}

\usepackage{longtable}
\usepackage{array}

\title{A longtable example}

\begin{document}
\caption{scene\label{table:econ:programmers}}\\
\begin{longtable}{| >{\raggedright}p{0.20\linewidth} 
              | >{\raggedright}p{0.28\linewidth} 
              | >{\raggedright}p{0.28\linewidth} 
              | >{\raggedright\arraybackslash}p{0.12\linewidth}|}
\hline
question & step & result & yes/no \\
\hline
Ask-1 & \begin{enumerate}
            \item[1)] some change 1;
            \item[2)] some change 2;
        \end{enumerate}
         & message & Yes \\

\hline
Ask-2 & \begin{enumerate}
            \item[1)] some change 1;
            \item[2)] some change 2;
        \end{enumerate}
         & message & Yes \\

\hline
Ask-3 & \begin{enumerate}
            \item[1)] some change 1;
            \item[2)] some change 2;
        \end{enumerate}
         & message & Yes \\

\hline
\end{longtable}

\end{document}
2
  • Welcome to TeX.SX! Please provide a compilable document, not just fragments. What's the problem with enumerate?
    – user31729
    May 8, 2016 at 10:55
  • I'm so sorry. I edited source code, Thanx
    – ximet
    May 8, 2016 at 12:05

1 Answer 1

1

It is best to make examples complete documents that can be tested but just delete \begin{table}[ht] and change tabular to longtable then move the \caption inside longtable as a row: \caption{scene\label{table:econ:programmers}}\\

2
  • Thanx, I edited code to longtable(see new attach), but caption not working now.
    – ximet
    May 8, 2016 at 12:11
  • And second column not correct display position. must be left and top position
    – ximet
    May 8, 2016 at 12:14

You must log in to answer this question.

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