Gap shows up on right side of long table even after using `|`

Please see the following mwe. I added the missing & and I added an second table without vertical lines, the better one I guess?

I added package geometry to get smaller margins so that the table does not overlap the margin. See the typing area and margin printed with geometry option showframe ...

\documentclass{article}

\usepackage[showframe,margin=1cm]{geometry} % <=========================
\usepackage{longtable}


\begin{document}

\footnotesize
\begin{longtable}[c]{|p{0.25in}|p{.3in}|p{2in}|p{0.525in}|p{0.3in}|p{0.525in}|p{0.3in}|p{.35in}|p{.35in}|}
\caption{Miscellaneous PDE's breakdown of results. Time in seconds}\\\hline
\#&PDE&description&\multicolumn{2}{|c|}{Mathematica}&\multicolumn{2}{|c|}{Maple}&solved?&animated?\\ 
\cline{4-7}
  &   &           &result   &  time                 & result  &  time           &       &          \\\hline
%                                                                                       ^^ missed!
\endfirsthead
%
\multicolumn{9}{|c|}{\tablename\ \thetable{} -- Miscellaneous PDE's. Continued from previous page} \\\hline 
\#&PDE&description&\multicolumn{2}{|c|}{Mathematica}&\multicolumn{2}{|c|}{Maple}&hand solved?&animated?\\ \cline{4-7}
&&&result&time&result&time&\\\hline
\endhead
%
\multicolumn{9}{|r|}{Continued on next page} \\\hline 
\endfoot \hline 
%
\endlastfoot
1&A&Transport equation $u_t+ u_x = 0$&OK&0.003&OK&0.079&OK&{}\\ \hline
2&B&$3 u_x + 5 u_y = x$&OK&0.004&OK&0.01&OK&{}\\ \hline
3&C&$x u_y + y u_x = -4 x y u$ and $u(x,0)=e^{-x^2}$&OK&0.011&OK&0.114&OK&{}\\ \hline
4&D&$u_t + u_x = 0$ and $u(x,0)=\sin x$ and $u(0,t)=0$&OK&0.052&OK&0.28&OK&{}\\ \hline
\end{longtable}

Better version?

\footnotesize
\begin{longtable}[c]{p{0.25in}p{.3in}p{2in}p{0.525in}p{0.3in}p{0.525in}p{0.3in}p{.35in}p{.35in}}
\caption{Miscellaneous PDE's breakdown of results. Time in seconds}\\\hline
\#&PDE&description&\multicolumn{2}{c}{Mathematica}&\multicolumn{2}{c}{Maple}&solved?&animated?\\ 
\cline{4-7}
  &   &           &result   &  time                 & result  &  time           &       &          \\\hline
%                                                                                       ^^ missed!
\endfirsthead
%
\multicolumn{9}{c}{\tablename\ \thetable{} -- Miscellaneous PDE's. Continued from previous page} \\\hline 
\#&PDE&description&\multicolumn{2}{c}{Mathematica}&\multicolumn{2}{c}{Maple}&hand solved?&animated?\\ \cline{4-7}
&&&result&time&result&time&\\\hline
\endhead
%
\multicolumn{9}{r}{Continued on next page} \\\hline 
\endfoot \hline 
%
\endlastfoot
1&A&Transport equation $u_t+ u_x = 0$&OK&0.003&OK&0.079&OK&{}\\ %\hline
2&B&$3 u_x + 5 u_y = x$&OK&0.004&OK&0.01&OK&{}\\ %\hline
3&C&$x u_y + y u_x = -4 x y u$ and $u(x,0)=e^{-x^2}$&OK&0.011&OK&0.114&OK&{}\\ %\hline
4&D&$u_t + u_x = 0$ and $u(x,0)=\sin x$ and $u(0,t)=0$&OK&0.052&OK&0.28&OK&{}\\ %\hline
\end{longtable}

\end{document}

and its result:

resulting tables


off-topic, since your problem is solved by @Mensch comment/answer (difference to his second example are marked with$ <---):

\documentclass{article}
\usepackage{booktabs, longtable, multirow}

%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}

\begin{document}
\footnotesize
\setlength\tabcolsep{5pt}
\begin{longtable}{@{} cc p{2in}*{6}{p{0.3in}} @{}}
\caption{Miscellaneous PDE's breakdown of results. Time in seconds} \\
    \toprule
\multirow{2}{*}{\#}                                             % <---
    & \multirow{2}{*}{PDE}                                      % <---
        & \multirow{2}{*}{description}
            & \multicolumn{2}{c}{Mathematica}                   % <---
                    & \multicolumn{2}{c}{Maple}
                            & \multirow{2}{=}{sol\-ved?}        % <---
                                & \multirow{2}{=}{anima\-ted?}  % <---
      \cmidrule(r){4-5}\cmidrule(lr){6-7}                       % <---
    &   &   & result
                & time
                    & result
                        & time 
                            &   &                               \\
    \midrule
\endfirsthead
%
\multicolumn{9}{c}{\tablename~\thetable  -- Miscellaneous PDE's. Continued from previous page} \\
    \toprule
\multirow{2}{*}{\#}                                             % <---
    & \multirow{2}{*}{PDE}                                      % <---
        & \multirow{2}{*}{description}
            & \multicolumn{2}{c}{Mathematica}                   % <---
                    & \multicolumn{2}{c}{Maple}
                            & \multirow{2}{=}{sol\-ved?}        % <---
                                & \multirow{2}{=}{anima\-ted?}  % <---
                                                                \\
    \cmidrule(r){4-5}\cmidrule(lr){6-7}                         % <---
    &   &   & result
                & time
                    & result
                        & time &                               \\
    \midrule
\endhead
%
\multicolumn{9}{r}{Continued on next page}                     % <---
                                                               \\ 
    \endfoot 
%
    \bottomrule
\endlastfoot
1   & A & Transport equation $u_t+ u_x = 0$
            & OK & 0.003 & OK & 0.079 & OK &        \\ 
    \addlinespace
2   & B & $3 u_x + 5 u_y = x$
            & OK    & 0.004 & OK    & 0.01  & OK    &   \\ 
    \addlinespace
3   & C & $x u_y + y u_x = -4 x y u$ and $u(x,0)=e^{-x^2}$ 
            & OK    & 0.011 & OK    & 0.114 & OK    &   \\ 
    \addlinespace
4   & D & $u_t + u_x = 0$ and $u(x,0)=\sin x$ and $u(0,t)=0$
            & OK    & 0.052 & OK    & 0.28  & OK    &   \\ 
\end{longtable}

\end{document}

enter image description here

Red lines indicate page layout. As you can see, your table spill out of text border. This you can eliminate on two ways:

  • increase text width, for example with use of the geometry package (as suggested @Mensch in his answer)
  • accordingly reduce the width of the third columns

Tags:

Longtable