make4ht icon indicating copy to clipboard operation
make4ht copied to clipboard

make4ht longtable issue, captions that should appear in footer appear in header, and they appear twice

Open cjohn001 opened this issue 2 years ago • 0 comments

Below code results in the issue. Expected is that the caption should be set below the table on each page (if table spans multiple pages)

\begin{longtable}[!ht]{|>{\centering\arraybackslash}p{0.3\linewidth}|>{\raggedright\arraybackslash}p{0.3\linewidth}|>{\raggedright\arraybackslash}p{0.31\linewidth}|}
	\hline \multicolumn{1}{|c|}{\textbf{Nutrient}} & \multicolumn{1}{c|}{\textbf{Function}} & \multicolumn{1}{c|}{\textbf{Nutrient Source}} \\  \hline
	\endfirsthead
	\hline \multicolumn{1}{|c|}{\textbf{Nutrient}} & \multicolumn{1}{c|}{\textbf{Function}} & \multicolumn{1}{c|}{\textbf{Nutrient Source}} \\  \hline
	\endhead
	\caption{Footer caption 1}
	\endfoot
	\caption{Footer caption}
	\label{tab:fats}
	\endfirstfoot

	test        \newline(\some text)    & text                                   & test                                          \\ \hline
	test        \newline(\some text)    & text                                   & test oil                                      \\ \hline
\end{longtable}
Bildschirm­foto 2023-03-07 um 18 18 32

The problem also arises without \endfirstfoot. \endfirstfoot is defined as below:

\makeatletter
\newbox\LT@firstfoot
\def\endfirstfoot{\LT@end@hd@ft\LT@firstfoot}
\newdimen\LT@footdiff
\def\LT@start{%
	\let\LT@start\endgraf
	\endgraf\penalty\z@
	\vskip\LTpre\endgraf
	\LT@footdiff-\ht\LT@foot
	\advance\LT@footdiff\ht\LT@firstfoot
	\dimen@\pagetotal
	\advance\dimen@ \ht\ifvoid\LT@firsthead\LT@head\else\LT@firsthead\fi
	\advance\dimen@ \dp\ifvoid\LT@firsthead\LT@head\else\LT@firsthead\fi
	\advance\dimen@ \ht\ifvoid\LT@firstfoot\LT@foot\else\LT@firstfoot\fi
	\dimen@ii\vfuzz
	\vfuzz\maxdimen
	\setbox\tw@\copy\z@
	\setbox\tw@\vsplit\tw@ to \ht\@arstrutbox
	\setbox\tw@\vbox{\unvbox\tw@}%
	\vfuzz\dimen@ii
	\advance\dimen@ \ht
	\ifdim\ht\@arstrutbox>\ht\tw@\@arstrutbox\else\tw@\fi
	\advance\dimen@\dp
	\ifdim\dp\@arstrutbox>\dp\tw@\@arstrutbox\else\tw@\fi
	\advance\dimen@ -\pagegoal
	\ifdim \dimen@>\z@\vfil\break\fi
	\global\@colroom\@colht
	\ifvoid\LT@firstfoot
		\ifvoid\LT@foot
		\else
			\advance\vsize-\ht\LT@foot
			\global\advance\@colroom-\ht\LT@foot
			\dimen@\pagegoal\advance\dimen@-\ht\LT@foot\pagegoal\dimen@
			\maxdepth\z@
		\fi
	\else
		\advance\vsize-\ht\LT@firstfoot
		\global\advance\@colroom-\ht\LT@firstfoot
		\dimen@\pagegoal\advance\dimen@-\ht\LT@firstfoot\pagegoal\dimen@
		\maxdepth\z@
	\fi
	\ifvoid\LT@firsthead\copy\LT@head\else\box\LT@firsthead\fi\nobreak
	\output{\LT@output}%
}
\def\LT@output{%
	\ifnum\outputpenalty <-\@Mi
		\ifnum\outputpenalty > -\LT@end@pen
			\LT@err{floats and marginpars not allowed in a longtable}\@ehc
		\else
			\setbox\z@\vbox{\unvbox\@cclv}%
			\ifdim \ht\LT@lastfoot>\ht\LT@foot
				\dimen@\pagegoal
				\advance\dimen@-\ht\LT@lastfoot
				\ifdim\dimen@<\ht\z@
					\setbox\@cclv\vbox{\unvbox\z@\copy\LT@foot\vss}%
					\@makecol
					\@outputpage
					\setbox\z@\vbox{\box\LT@head}%
				\fi
			\fi
			\global\@colroom\@colht
			\global\vsize\@colht
			\vbox
			{\unvbox\z@\box\ifvoid\LT@lastfoot\LT@foot\else\LT@lastfoot\fi}%
		\fi
	\else
		\ifvoid\LT@firstfoot
			\setbox\@cclv\vbox{\unvbox\@cclv\copy\LT@foot\vss}%
			\@makecol
			\@outputpage
			\global\vsize\@colroom
		\else
			\setbox\@cclv\vbox{\unvbox\@cclv\box\LT@firstfoot\vss}%
			\@makecol
			\@outputpage
			\global\advance\@colroom\LT@footdiff
			\global\vsize\@colroom
		\fi
		\copy\LT@head\nobreak
	\fi
}
\makeatother

cjohn001 avatar Mar 07 '23 17:03 cjohn001