当表格确实很长时,如何更改长表的页脚?

当表格确实很长时,如何更改长表的页脚?

我正在使用以下代码创建基于 longtable 的自定义环境:

\documentclass[openany,12pt]{book}

\usepackage{longtable}

\newcommand{\LORD}{\textsc{Lord}}
\let\Lord\LORD

\newif\ifnewspread\newspreadfalse
\newlength{\psalmindent}
\setlength{\psalmindent}{0.7cm}

\newenvironment{sungpsalm}[2]
{%
    \def\antiphon{#1}%
    \def\tone{#2}
    \newcommand{\pause}{\\*\hspace{\psalmindent}}%
    \newcommand{\side}[1]{\\}%
    \newcommand{\stanza}{\\\noalign{\penalty-50\vspace{\parskip}}}%
    \begin{longtable}[l]{l}%
        \antiphon\\*
        #2\endfirsthead
        %for some reason the ifood conditional is working backwards
        \ifodd\thepage\tone\newspreadtrue\else\relax\fi\endhead
        \ifodd\thepage\textit{\small Continued next page}\fi\endfoot
        \ifnewspread\antiphon\else\textit{\small Repeat Antiphon}\fi\endlastfoot
}
{%
    \end{longtable}%
}

\begin{document}
%test\pagebreak


\begin{sungpsalm}{Antiphon test}{tone test}
\side{2} O \Lord, my God, I take refuge in you.\pause
Save and rescue me from all my pursuers,
\side{3} lest they tear me apart like a lion,\pause
and drag me off with no one to rescue me.
\stanza
\side{4} If I have done this, O \Lord, my God,
\side{5} if I have paid back evil for good,\pause
I who saved my unjust oppressor:
\side{6} then let my foe pursue my soul and seize me;\pause
let him trample my life to the ground,\pause
and lay my honor in the dust.
\stanza
\side{7} O \Lord, rise up in your anger;\pause
be exalted against the fury of my foes.\pause
Awake, my God, to enact \pause
the justice you ordered.
\side{8} Let the company of peoples gather round you,\pause
as you take your seat above them on high.
\stanza
\side{9} The \Lord\ is judge of the peoples.\pause
Give judgment for me, O \Lord,\pause
for I am just and blameless of heart.
\stanza
\side{10} Put an end to the evil of the wicked!\pause
Make the just man stand firm;\pause
it is you who test mind and heart,\pause
O God of justice!
\stanza
\side{11} God is a shield before me,\pause
who saves the upright of heart.
\side{12} God is a judge, just and powerful and patient,\pause
not exercising anger every day.
\stanza
\side{13} Against someone who does not repent,\pause
God will sharpen his sword;\pause
he bends his bow and makes ready.
\side{14} For such a one he prepares deadly weapons;\pause
he barbs his arrows with fire.
\stanza
\side{15} Here is one who conceives iniquity;\pause
pregnant with malice, he gives birth to lies.
\side{16} He digs a pit and bores it deep;\pause
and in the trap he has made he falls.
\side{17} His malice recoils on his head;\pause
on his own skull his violence falls.
\stanza
\side{18} I thank the \Lord\ for his justice,\pause
singing to the name of the \Lord, the Most High.\pause

\end{sungpsalm}


\end{document}

现在,由于在实际用例中,我的环境的两个参数将是\includegraphics指向音乐图片的命令,我试图通过每两页仅打印一次每首音乐(否则打印一个简单的文本引用)来节省空间。上面的代码对于第二个参数(最终以\tone)很好地完成了这项工作,但对于第一个参数(最终以\antiphon)却不然。条件\ifnewspread似乎总是假的。我怀疑这是因为\endlastfoot将最后的页脚放入一个框中,并且该\ifnewspread子句是在框填充时而不是在打印时进行评估的。但是,即使我将该子句移到一个单独的函数(\terminate)中,然后说\expandafter\terminate\endlastfoot\noexpand\terminate\endlastfoot事情仍然不起作用(前者显示与MWE相同的行为,后者根本无法打印最后一个页脚)。

是否有一些特殊的咒语可以让我这样做,以便最后的页脚在打印时而不是之前评估该条件?

答案1

\newspreadtrue本地(在表格单元格中)进行评估,因此不会影响外部世界。因此请使用\global\newspreadtrue。然后它就可以正常工作。

而且,一旦设置为 true,它就永远不会再变为 false。这是你想要的吗?也许\newspreadfalse应该将初始化移到环境的开头sungpsalm

相关内容