即使使用 `|` 长表右侧仍会出现间隙

即使使用 `|` 长表右侧仍会出现间隙

我已经为此奋斗了 30 分钟,但还是搞不清原因。这张长桌子的右边缘靠近顶部有一个缺口。我不知道为什么:

Mathematica 图形

我确定|最后有一个?这里有一个 MWE 来重现它:这是一个小例子。表格本身延伸到很多页。

\documentclass{article}
\usepackage{longtable}    
\begin{document}        
\footnotesize
\begin{longtable}[c]{|p{.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
\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}

Linux 上的 TL 2019。使用以下工具编译lualatex foo.tex

答案1

请参阅以下 mwe。我添加了缺失的部分&,并添加了第二个没有垂直线的表格,我猜这个更好?

我添加了包geometry以获得更小的边距,这样表格就不会与边距重叠。查看使用geometry选项打印的打字区域和边距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}

及其结果:

结果表

答案2

离题,因为您的问题已由@Mensch 评论/回答解决(与他的第二个示例的区别用 标记$ <---):

\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}

在此处输入图片描述

红线表示页面布局。如您所见,表格超出了文本边框。您可以通过两种方式消除这种情况:

  • 增加文本宽度,例如使用geometry包(正如@Mensch 在他的回答中所建议的那样)
  • 相应地减少第三列的宽度

相关内容