5

I'm setting a table of logarithms. I'm using longtable, and it works well. Every line of the table has a markboth reference, like so:

\textbf{1.03}\markboth{1.03}{1.03} & .01284 & .01326 & ...
\textbf{1.04}\markboth{1.04}{1.04} & .01703 & .01745 & ...
\textbf{1.05}\markboth{1.05}{1.05} & .02119 & .02160 & ...

My headings are generated using:

\makeatletter
\def\@oddhead{\thepage\qquad\textsc{Decimal Logarithms}\hfill
  \rightmark{} -- \leftmark}
\def\@evenhead{\rightmark{} -- \leftmark \hfill
  \textsc{Decimal Logarithms}\qquad\thepage}
\makeatother

The text in the running head is correct for most of the table: 1.00 – 1.47, 1.48 – 1.96, ... except the last page, which just displays 9.99 – 9.99, when it should be 9.81 – 9.99. The last page isn't quite filled by the table.

I've tried the methods suggested in Indexing an interval of words on top of every page, which only results in the last page having a single header of 9.99. My TeX is a bit rusty; haven't used it seriously in over a decade. Any assistance appreciated.

Update: Here's a test case just long enough to generate a page throw:

\documentclass{article}
\usepackage{longtable}
\pagestyle{headings}

\begin{document}

% page headings
\makeatletter
\def\@oddhead{\thepage{} \hfill \rightmark{} -- \leftmark{}}
\def\@evenhead{\rightmark{} -- \leftmark{} \hfill \thepage{}}
\makeatother

\begin{longtable}{|*{4}{c|}}
  & 0 & 1 & 2 \\ \hline \endhead
\hline \endfoot
 1.00\markboth{1.00}{1.00} & .00000 & .00043 & .00087 \\
 1.01\markboth{1.01}{1.01} & .00432 & .00475 & .00518 \\
 1.02\markboth{1.02}{1.02} & .00860 & .00903 & .00945 \\
 1.03\markboth{1.03}{1.03} & .01284 & .01326 & .01368 \\
 1.04\markboth{1.04}{1.04} & .01703 & .01745 & .01787 \\
 1.05\markboth{1.05}{1.05} & .02119 & .02160 & .02202 \\
 1.06\markboth{1.06}{1.06} & .02531 & .02572 & .02612 \\
 1.07\markboth{1.07}{1.07} & .02938 & .02979 & .03019 \\
 1.08\markboth{1.08}{1.08} & .03342 & .03383 & .03423 \\
 1.09\markboth{1.09}{1.09} & .03743 & .03782 & .03822 \\
 1.10\markboth{1.10}{1.10} & .04139 & .04179 & .04218 \\
 1.11\markboth{1.11}{1.11} & .04532 & .04571 & .04610 \\
 1.12\markboth{1.12}{1.12} & .04922 & .04961 & .04999 \\
 1.13\markboth{1.13}{1.13} & .05308 & .05346 & .05385 \\
 1.14\markboth{1.14}{1.14} & .05690 & .05729 & .05767 \\
 1.15\markboth{1.15}{1.15} & .06070 & .06108 & .06145 \\
 1.16\markboth{1.16}{1.16} & .06446 & .06483 & .06521 \\
 1.17\markboth{1.17}{1.17} & .06819 & .06856 & .06893 \\
 1.18\markboth{1.18}{1.18} & .07188 & .07225 & .07262 \\
 1.19\markboth{1.19}{1.19} & .07555 & .07591 & .07628 \\
 1.20\markboth{1.20}{1.20} & .07918 & .07954 & .07990 \\
 1.21\markboth{1.21}{1.21} & .08279 & .08314 & .08350 \\
 1.22\markboth{1.22}{1.22} & .08636 & .08672 & .08707 \\
 1.23\markboth{1.23}{1.23} & .08991 & .09026 & .09061 \\
 1.24\markboth{1.24}{1.24} & .09342 & .09377 & .09412 \\
 1.25\markboth{1.25}{1.25} & .09691 & .09726 & .09760 \\
 1.26\markboth{1.26}{1.26} & .10037 & .10072 & .10106 \\
 1.27\markboth{1.27}{1.27} & .10380 & .10415 & .10449 \\
 1.28\markboth{1.28}{1.28} & .10721 & .10755 & .10789 \\
 1.29\markboth{1.29}{1.29} & .11059 & .11093 & .11126 \\
 1.30\markboth{1.30}{1.30} & .11394 & .11428 & .11461 \\
 1.31\markboth{1.31}{1.31} & .11727 & .11760 & .11793 \\
 1.32\markboth{1.32}{1.32} & .12057 & .12090 & .12123 \\
 1.33\markboth{1.33}{1.33} & .12385 & .12418 & .12450 \\
 1.34\markboth{1.34}{1.34} & .12710 & .12743 & .12775 \\
 1.35\markboth{1.35}{1.35} & .13033 & .13066 & .13098 \\
 1.36\markboth{1.36}{1.36} & .13354 & .13386 & .13418 \\
 1.37\markboth{1.37}{1.37} & .13672 & .13704 & .13735 \\
 1.38\markboth{1.38}{1.38} & .13988 & .14019 & .14051 \\
 1.39\markboth{1.39}{1.39} & .14301 & .14333 & .14364 \\
 1.40\markboth{1.40}{1.40} & .14613 & .14644 & .14675 \\
 1.41\markboth{1.41}{1.41} & .14922 & .14953 & .14983 \\
 1.42\markboth{1.42}{1.42} & .15229 & .15259 & .15290 \\
 1.43\markboth{1.43}{1.43} & .15534 & .15564 & .15594 \\
 1.44\markboth{1.44}{1.44} & .15836 & .15866 & .15897 \\
 1.45\markboth{1.45}{1.45} & .16137 & .16167 & .16197 \\
 1.46\markboth{1.46}{1.46} & .16435 & .16465 & .16495 \\
 1.47\markboth{1.47}{1.47} & .16732 & .16761 & .16791 \\
 1.48\markboth{1.48}{1.48} & .17026 & .17056 & .17085 \\
 1.49\markboth{1.49}{1.49} & .17319 & .17348 & .17377 \\
 1.50\markboth{1.50}{1.50} & .17609 & .17638 & .17667 \\
 1.51\markboth{1.51}{1.51} & .17898 & .17926 & .17955 \\
 1.52\markboth{1.52}{1.52} & .18184 & .18213 & .18241 \\
 1.53\markboth{1.53}{1.53} & .18469 & .18498 & .18526 \\
 1.54\markboth{1.54}{1.54} & .18752 & .18780 & .18808 \\
 1.55\markboth{1.55}{1.55} & .19033 & .19061 & .19089 \\
 1.56\markboth{1.56}{1.56} & .19312 & .19340 & .19368 \\
 1.57\markboth{1.57}{1.57} & .19590 & .19618 & .19645 \\
 1.58\markboth{1.58}{1.58} & .19866 & .19893 & .19921 \\
 1.59\markboth{1.59}{1.59} & .20140 & .20167 & .20194 \\
\end{longtable}

\end{document} 
6

There's a possibility that longtable is dropping the mark while handing back control of the page breaking to the main latex output routine. Not seen that before, but anything is possible. If you can't make a test case small enough to post here and you think it's a LT bug, you could post it to the latex bug address latex latexbug and follow the instructions (LT bugs should be category "tools".

UPDATE from test case:

This is similar to the "marks in two column mode" fixed by fixltx2e package. \topmark is set by the final iteration of the LT output routine, but not passed on to the standard routine. The standard routine would just pick up the mark again as the final table section is re-considered by the page breaker, but to make sure that you don't get bad edge effects with the standard output routine breaking the table (but not adding the table foot, LT leaves the final table segment in a vbox so it won't break. However it means it also won't expose any marks. A 20 year old bug.

It could be fixed as in fixltx2e by saving the marks "by hand" in the LT output routine and re-setting \topmark and \firstmark if needed, but a simpler fix which works in your case is omit boxing the final table segment and simply put the table unboxed back into the main vertical list so the marks affect the next page as usual.

So short answer is: Sorry, add a % to line 404 of longtable.sty

  %\vbox
    {\unvbox\z@\box\ifvoid\LT@lastfoot\LT@foot\else\LT@lastfoot\fi}%

If you do this please change the ProvidesPackage line

\ProvidesPackage{longtable}
          [2004/02/01 v4.11 Multi-page Table package (DPC) + mark fix]

Let me know if it works on your real case. I suspect that the safer fix might be the reinsert marks version, but that would take a bit more thought (It's a long time since I wrote this stuff;-)

6
  • @scruss, answer updated with fix (I hope:-) Feb 4 '12 at 22:06
  • @DavidCarlisle I tried your "short answer" in my case (tex.stackexchange.com/a/277344) but this generated new trouble: unwanted page breaks out of nowhere. Do you have any idea on how to solve this?
    – Dominik
    Nov 9 '15 at 19:06
  • @DavidCarlisle Could you please explain what you mean saying "saving the marks "by hand" in the LT output routine and re-setting \topmark and \firstmark" or provide an example of how to do this? Since the easier method does not work for me, I would like to try this solution...
    – Dominik
    Nov 9 '15 at 21:24
  • @Dominik not in a comment no (it means re-implementing a large part of longtable, which I've not done and probably too long to explain in a comment if I had) If you have a test case where removing the vbox does the wrong thing, that would be useful. (no need to make it into a minimal example, you could just email me the zip, google my name for my email address) Nov 10 '15 at 8:09
  • @DavidCarlisle I just emailed you. I am looking forward to your response...
    – Dominik
    Nov 10 '15 at 13:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.