我搜索了很多次,但还是找不到合适的解决方案。我使用 \captionof{} 来显示表格,表格位于页面底部附近。由于表格无法跨页显示(在本例中我想要的是跨页显示),因此表格被放在了下一页。我遇到的问题是标题仍然在第一页,没有正确地位于表格上方。
尽管 \parbox{} 和 \begin{minipage} 之类的东西可以工作,但它们引入的副作用是表格内的脚注不再起作用。
以下示例显示了表格标题如何保留在第 1 页,表格如何移至第 2 页,但表格中的脚注却可以正常工作。如果启用 \parbox,您将看到标题保留在表格中,但脚注不再显示。
\documentclass[12pt,a4paper]{article}
% Details for tables
\usepackage{longtable,tabu}
\tabulinesep=1.2mm
\usepackage[hidelinks]{hyperref}
\usepackage{caption}
\usepackage{footnote}
% End details for tables
\begin{document}
Lots of text to get to the bottom of the page.\\
Lots of text to get to the bottom of the page.\\
Lots of text to get to the bottom of the page.\\
Lots of text to get to the bottom of the page.\\
Lots of text to get to the bottom of the page.\\
Lots of text to get to the bottom of the page.\\
Lots of text to get to the bottom of the page.\\
Lots of text to get to the bottom of the page.\\
Lots of text to get to the bottom of the page.\\
Lots of text to get to the bottom of the page.\\
Lots of text to get to the bottom of the page.\\
Lots of text to get to the bottom of the page.\\
Lots of text to get to the bottom of the page.\\
Lots of text to get to the bottom of the page.\\
Lots of text to get to the bottom of the page.\\
Lots of text to get to the bottom of the page.\\
Lots of text to get to the bottom of the page.\\
Lots of text to get to the bottom of the page.\\
Lots of text to get to the bottom of the page.\\
Lots of text to get to the bottom of the page.\\
Lots of text to get to the bottom of the page.\\
Lots of text to get to the bottom of the page.\\
Lots of text to get to the bottom of the page.\\
Lots of text to get to the bottom of the page.\\
\noindent
% \parbox{\textwidth}{ % enable this line to get the \parbox example working, whereby the footnotes disappear, but the caption stays on the same page as the table.
\captionof{table}{Example of non-wrapping table}
\begin{tabu} to \textwidth {X[1,c,p]X[3,c,p]X[3,l,m]X[10,r,b]}
\hline
\textbf{Time End} & \textbf{Step} & \textbf{Event} & \textbf{Description} \\
\hline
12:18 & 1 & 1 & Notice how this column is defined as ``b'', causing the text on the other rows to be bottom aligned. \\
12:18 & 1 & 1\footnote{testing} & this is a description for the event \\
12:18 & 1 & 1 & this is a description for the event \\
12:18 & 1 & Here we inserted extra text. & Note how column 3 is defined as ``m'', causing other columns to be middle aligned. \\
12:18 & 1 & 1 & Column 1 = ``p''. All at the top. \\
12:18 & 1\footnote{another footnote} & 1 & this is a description for the event \\
12:18 & 1 & 1 & this is a description for the event \\
12:18 or later & 1 & 1 & this is a description for the event \\
12:18 & 1 & 1 & this is a description for the event \\
\hline
\end{tabu}
% } % enable } to get the \parbox example working, whereby the footnotes disappear, but the caption stays on the same page as the table.
\end{document}
使用 tabu 环境的原因是我还使用 longtabu,它允许我创建分页表。我希望能够在分页表和非分页表之间快速切换。
提前感谢您的建议。
马克。
==================更新==================== 根据 John 的回答,我复制/粘贴了他的 MWE(见下文)并在文档中添加了一些附加文本以及一些附加脚注。这样做会导致在 \parbox 启动之前放置脚注时出现意外行为。我的另一个观察结果是 \parbox 内脚注的超链接未链接到正确的位置。
除了使用 \parbox 之外,是否有可能强制在 \captionof 和 \begin{tabu} 行之间添加一个不间断的新行?我认为这将是一种更简单的解决方案。
\documentclass[12pt,a4paper]{article}
% Details for tables
\usepackage{longtable,tabu}
\tabulinesep=1.2mm
\usepackage[hidelinks]{hyperref}
\usepackage{caption}
% End details for tables
\newcount\savefnused
\newcount\savefndone
\newcount\maxfootnote
\newcommand{\savefootnote}[2][\empty]% #1=number (optional), #2=text
{\ifx\empty#1\footnotemark
\ifnum\value{footnote}>\maxfootnote
\global\maxfootnote=\value{footnote}%
\global\advance\savefnused by 1
\expandafter\xdef\csname savefnmark\the\savefnused\endcsname{\thefootnote}%
\expandafter\xdef\csname savefntext\the\savefnused\endcsname{#2}%
\fi
\else
\footnotemark[#1]% does not affect footnote counter
\global\advance\savefnused by 1
\expandafter\xdef\csname savefnmark\the\savefnused\endcsname{\thefootnote}%
\expandafter\xdef\csname savefntext\the\savefnused\endcsname{#2}%
\fi}
\newcommand{\flushfootnote}{\loop\ifnum\savefndone<\savefnused
\global\advance\savefndone by 1
\footnotetext[\csname savefnmark\the\savefndone\endcsname]%
{\csname savefntext\the\savefndone\endcsname}%
\global\expandafter\let\csname savefnmark\the\savefndone\endcsname\relax
\global\expandafter\let\csname savefntext\the\savefndone\endcsname\relax
\repeat
\setcounter{footnote}{\number\maxfootnote}}
\begin{document}
\rule{1pt}{20\baselineskip}\\
When I use a footnote\footnote{test footnote} on the page previous to the parbox, I observe that the footnote does not show up at the bottom of the page, but rather directly after this text.
\noindent\parbox{\textwidth}{%
\captionof{table}{Example of non-wrapping table}
\begin{tabu} to \textwidth {X[1,c,p]X[3,c,p]X[3,l,m]X[10,r,b]}
\hline
\textbf{Time} & \textbf{Step} & \textbf{Event} & \textbf{Description} \\
\hline
12:18 & 1 & 1 & Notice how this column is defined as ``b'', causing the text on the other rows to be bottom aligned. \\
12:18 & 1 & 1\savefootnote{testing} & this is a description for the event \\
12:18 & 1 & 1 & this is a description for the event \\
12:18 & 1 & Here we inserted extra text. & Note how column 3 is defined as ``m'', causing other columns to be middle aligned. \\
12:18 & 1 & 1 & Column 1 = ``p''. All at the top. \\
12:18 & 1\savefootnote{another footnote} & 1 & this is a description for the event \\
12:18 & 1 & 1 & this is a description for the event \\
12:18 or later & 1 & 1 & this is a description for the event \\
12:18 & 1 & 1 & this is a description for the event \\
\hline
\end{tabu}}
\flushfootnote
Now that we have reached the end of the table our normal text continues. In this normal text we can obviously also encounter footnotes\footnote{look here is another footnote}. These do show up properly.
Another observation is that the hyper-links for the footnotes inside the parbox seem to refer back to the previous page.
\end{document}
感谢您查看这个。
答案1
我做了一些进一步的研究,感谢约翰对需要空间包。我发现这个包有助于防止在标题和表格本身之间插入分页符。因此,无需使用 \parbox。
但是,它没有解决第一页脚注在页面上显示得太高的问题;也就是说,不在页面底部。我发现脚杂可以有效处理这个问题的包。
关于脚注超链接无法正常工作的小问题,我发现这与超链接程序包正在被加载。
以下是正常工作的 MWE,所有功能均正常工作。
\documentclass[12pt,a4paper]{article}
% Details for tables
\usepackage{longtable,tabu}
\tabulinesep=1.2mm
\usepackage{caption}
\usepackage{needspace}
\usepackage[bottom]{footmisc}
\usepackage[hidelinks]{hyperref} %location of loading this package is important!
% End details for tables
\begin{document}
\rule{1pt}{20\baselineskip}\\
When I use a footnote\footnote{first footnote} on the page previous to the table, I observe that the footnote now shows up at the bottom of the page, thanks to the footmisc package.
\needspace{5\baselineskip}
\noindent
\captionof{table}{Example of non-wrapping table}
\begin{tabu} to \textwidth {X[1,c,p]X[3,c,p]X[3,l,m]X[10,r,b]}
\hline
\textbf{Time} & \textbf{Step} & \textbf{Event} & \textbf{Description} \\
\hline
12:18 & 1 & 1 & Notice how this column is defined as ``b'', causing the text on the other rows to be bottom aligned. \\
12:18 & 1 & 1\footnote{second footnote} & this is a description for the event \\
12:18 & 1 & 1 & this is a description for the event \\
12:18 & 1 & Here we inserted extra text. & Note how column 3 is defined as ``m'', causing other columns to be middle aligned. \\
12:18 & 1 & 1 & Column 1 = ``p''. All at the top. \\
12:18 & 1\footnote{third footnote} & 1 & this is a description for the event \\
12:18 & 1 & 1 & this is a description for the event \\
12:18 or later & 1 & 1 & this is a description for the event \\
12:18 & 1 & 1 & this is a description for the event \\
\hline
\end{tabu}
\paragraph{}Now that we have reached the end of the table our normal text continues. In this normal text we can obviously also encounter footnotes\footnote{fourth footnote}. These do show up properly.
Another observation is that the hyper-links for the footnotes are now working properly.
\end{document}
答案2
我尝试了我的解决方案\parbox
(为什么 \parbox 会丢失脚注?),但每个脚注都制作了三份副本。
我修改了解决方案以忽略脚注计数器的重复值。我应该提到,此解决方案与脚注包不兼容。
\documentclass[12pt,a4paper]{article}
% Details for tables
\usepackage{longtable,tabu}
\tabulinesep=1.2mm
\usepackage{hyperref}% required
\usepackage{caption}
% End details for tables
\newcount\savefnused
\newcount\savefndone
\newcount\maxfootnote
\newcommand{\savefootnote}[2][\empty]% #1=number (optional), #2=text
{\ifx\empty#1\footnotemark
\ifnum\value{footnote}>\maxfootnote
\global\maxfootnote=\value{footnote}%
\global\advance\savefnused by 1
\expandafter\xdef\csname savefnmark\the\savefnused\endcsname{\thefootnote}%
\expandafter\xdef\csname savefntext\the\savefnused\endcsname{#2}%
\expandafter\xdef\csname savefnname\the\savefnused\endcsname{\csname Hy@footnote@currentHref\endcsname}%
\fi
\else
\footnotemark[#1]% does not affect footnote counter
\global\advance\savefnused by 1
\expandafter\xdef\csname savefnmark\the\savefnused\endcsname{\thefootnote}%
\expandafter\xdef\csname savefntext\the\savefnused\endcsname{#2}%
\expandafter\xdef\csname savefnname\the\savefnused\endcsname{\csname Hy@footnote@currentHref\endcsname}%
\fi}
\newcommand{\flushfootnote}{\loop\ifnum\savefndone<\savefnused
\global\advance\savefndone by 1
\footnotetext[\csname savefnmark\the\savefndone\endcsname]%
{\hypertarget{\csname savefnname\the\savefndone\endcsname}%
{\csname savefntext\the\savefndone\endcsname}}%
\global\expandafter\let\csname savefnmark\the\savefndone\endcsname\relax
\global\expandafter\let\csname savefntext\the\savefndone\endcsname\relax
\global\expandafter\let\csname savefnname\the\savefndone\endcsname\relax
\repeat
\setcounter{footnote}{\number\maxfootnote}}
\begin{document}
\rule{1pt}{20\baselineskip}
\noindent\parbox{\textwidth}{%
\captionof{table}{Example of non-wrapping table}
\begin{tabu} to \textwidth {X[1,c,p]X[3,c,p]X[3,l,m]X[10,r,b]}
\hline
\textbf{Time End} & \textbf{Step} & \textbf{Event} & \textbf{Description} \\
\hline
12:18 & 1 & 1 & Notice how this column is defined as ``b'', causing the text on the other rows to be bottom aligned. \\
12:18 & 1 & 1\savefootnote{testing} & this is a description for the event \\
12:18 & 1 & 1 & this is a description for the event \\
12:18 & 1 & Here we inserted extra text. & Note how column 3 is defined as ``m'', causing other columns to be middle aligned. \\
12:18 & 1 & 1 & Column 1 = ``p''. All at the top. \\
12:18 & 1\savefootnote{another footnote} & 1 & this is a description for the event \\
12:18 & 1 & 1 & this is a description for the event \\
12:18 or later & 1 & 1 & this is a description for the event \\
12:18 & 1 & 1 & this is a description for the event \\
\hline
\end{tabu}}
\flushfootnote
\end{document}