Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

The presence of floats appears to disrupt the setting of \marks, so that \topmark ends up with the wrong value.

For example, consider this:

\documentclass{article}
\textheight 50mm
\textwidth 50mm

\makeatletter \def\@oddhead{[\topmark/\firstmark/\botmark]} \makeatother

\def\block#1{\textbf{#1}\mark{#1}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua.
Foo bar baz.\par}

\begin{document}

\block a
\block b
\block c
\block d
%\begin{figure}\hrule width 1pt height 20mm depth 0pt \end{figure}
\block e

\end{document}

That works as it should: the page break appears in the middle of block 'c', blocks 'd' and 'e' start on page 2, and the header therefore shows '[c/d/e]'. That's correct.

If I uncomment the {figure} line, however, then the 'figure' appears on page 3, and page 2 is unchanged (page breaks within blocks 'c' and 'e'), but the header now shows '[d/d/e]'.

I am perplexed as to why this happens. I can't find anything in \@float or \@caption which touches the marks, and in general nothing in latex.ltx that uses \markboth or \markright (which are the only things in latex.ltx which call \mark). article.cls has a few things that call \@mkboth, but they're associated with \@part, and with lists of figures and the index.

What is it I'm missing?

share|improve this question
    
I'm not sure, but it is possible that LaTeX typesets a paragraph in the context of one page and then moves it to another page. Similar strange things happen when one uses margin notes on a two-sided layout where sometimes a note appears on the inside margin. (I did not post this as an answer because I'm really not sure if this is the reason.) –  Caramdir Aug 3 '10 at 13:28
    
I don't think it can be that, since TeX (the program) assigns the mark quantities at the time material is put into \box255. Having said that, at least some of the float placement algorithm takes place within the \output routine, so I can imagine something going wrong here. Perhaps the answer is that TeX's \mark isn't supported within LaTeX. –  Norman Gray Aug 3 '10 at 13:48
add comment

2 Answers

up vote 10 down vote accepted

Answering my own question...

The problem here is, bluntly, that LaTeX messes up the TeX \mark system: \firstmark and \botmark still work, but \topmark doesn't. This is because LaTeX's float algorithm, which handles \marginpar as well as figures and tables, can invoke the output routine at times other than between pages. That necessarily moves \botmark into \topmark in a way which means that \topmark is no longer the value that \botmark had at the end of the previous page.

LaTeX's \markboth system uses the TeX \mark system, but is specialised to the case of running section headings, and doesn't seem repurposable.

The multicol and fixltx2e packages (and the fixmarks package, which they both cite) address this problem for the case of multi-column pages, but not in a way which makes \topmark work in the case illustrated here.

My particular case is this: I'm setting exam papers, and want to put a [Qx cont'd] at the top of pages which start in the middle of question x. I had beeing putting \mark{x} at the beginning of each question: testing \topmark worked fine, until the paper included figures. I've got it working in a slightly clunky way. I put \mark{1x} at the beginning of each question, and \mark{0x} at the end: I can then tell by looking at the number at the beginning of \firstmark whether I'm still in a question or not.

Edit: while that's a nice idea, it turns out that the a more effective solution is to save the \botmark manually, with \xdef\my@topmark{\botmark} in the page footer. This can be examined in the following page header, where it has (exactly?) the same semantics as \topmark. There might be some pathological cases where this doesn't work, but I haven't run into them.

share|improve this answer
    
You should go ahead and accept your own answer... –  Lev Bishop Aug 28 '10 at 1:38
1  
Hah! I didn't expect I could do that! I notice that I don't get any reputation for that: good -- that would have been a bug. –  Norman Gray Nov 10 '10 at 5:04
add comment

If the question is how to use top marks, see my package titleps. See also How to add “cont.” section title to the top of pages? .

share|improve this answer
    
Thanks for this, Javier. I came across titleps when I recently came back to this question, and meant to edit in a pointer to it. But can you think of any case where manually saving \botmark, as above, wouldn't work? –  Norman Gray Jul 27 '12 at 12:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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