0

If you will please examine pages 20, 25, 26, 31, 32, 37, and 41 of the MWE below, then you will find that considerable space intervenes between the body of text and the page number (in the footer). In all of these cases except that on page 41, this space is due to package nowidow operating while the footer stays in the same place. (On page 41, this space occurs simply because the text ends before reaching the footer.)

I would like for there to be no such considerable space intervening between the body of text and the footer, even on pages such as page 41. Is there a way to prevent such space by causing the footer to rise up to be just below the bottom of the body of text wherever necessary? (Preferably a way that is automatic and is compatible with nowidow, please.)

Setting footskip=0cm in geometry moved me closer to the desired result, but it is obviously not sufficient.

I am using XeLaTeX.

In case it is not clear, I have included a photograph of what I would like to achieve, taken from an old copy of Joyce's Portrait of the artist as a young man, in the hope that this helps. I have held the page up so that plenty of light shines through. You can see through the page that the footer number [ 232 ] is roughly a line below footer number [ 231 ], for the reason that each follows just after the body of text as closely as possible. (Not that this book has no orphans or widows.)

enter image description here

%%%%% Preamble

%%% Document class, packages

\documentclass{book} \usepackage[paperwidth=4.25in, paperheight=5.5in, footskip=0cm]{geometry} \usepackage[skip=0pt, indent=20pt]{parskip} \usepackage{fancyhdr} \usepackage{microtype} \usepackage{titlesec} \usepackage[all]{nowidow} % Eliminates orphans and widows \usepackage{lipsum}

\emergencystretch 30pt % Causes text to better heed margin

%%% Fancy headers

\fancyhf{} \pagestyle{fancy} \renewcommand\headrulewidth{0pt} \fancyfoot[CE,CO]{{\small[} \oldstylenums{\thepage} {\small]}}

%%%%% Document

\begin{document}

\lipsum[1-70]

\end{document}

Noah J
  • 515
  • One very basic way could be to put \enlargethispage{-\baselineskip} (or {-2\baselineskip}, {-3\baselineskip} etc.) on the pages where the pagenumber is separated from text by one, two, three etc. empty lines. – Iacobus1983 Jul 01 '23 at 16:22
  • Or sometimes perhaps \enlargethispage{\baselineskip}, depending on how it interacts with nowidow job... – Iacobus1983 Jul 01 '23 at 16:25
  • @Iacobus1983 I can't seem to make your suggestion work. (There is also the issue of automation, which is important since my actual document --- as opposed to the MWE --- is hundreds of pages long. I didn't originally request that the solution be automatic, but I have just edited the question to reflect this concern.) – Noah J Jul 01 '23 at 17:05
  • fancyhdr is resetting \footskip for you. You need to use \raisebox or \smash to fool it. – John Kormylo Jul 01 '23 at 17:39
  • Just saying: In a book, having page numbers anywhere other than the outer footer already greatly diminishes their usefulness; but having them in a different place on every page is folly, typographically speaking. – Ingmar Jul 01 '23 at 17:44
  • Also, normally the last baseline is even with bottom of the text area, which is not the case here (\lipsum?). Use the showframe option of geometry to see the borders. – John Kormylo Jul 01 '23 at 17:48
  • look again carefully into your copy of Joyce's book: I'm sure you will see that the page numbers are always at the same height on every page, they don't jump up and down. You can also see that it doesn't do such nonsense as preventing orphans and widows all the time. Your screenshot above shows an orphan. – Ulrike Fischer Jul 02 '23 at 09:57
  • @UlrikeFischer The numbers really do seem to be jumping up and down. I have replaced the picture with a better picture of the same thing. I agree that the Joyce book has widows and orphans. However, I am not trying to reproduce everything about the Joyce book, only the page numbers jumping up and down thing, because I don't like the look of the space. Lastly, I would love to read your thoughts on why you believe it is bad practice to eliminate all orphans and widows. Thank you! – Noah J Jul 02 '23 at 13:13
  • it is bad practice because it leads to large spaces, at least if you do it with a simple minded method. See https://tug.org/TUGboat/tb39-3/tb123mitt-widows.pdf and https://ctan.org/pkg/widows-and-orphans. You can't move the footer up automatically in LaTeX, at least not easily, the default output routine of latex attaches the footer always in the same place. – Ulrike Fischer Jul 02 '23 at 13:33
  • @UlrikeFischer Thank you! I read the article. What if I were to make the proper footer empty? Could I then achieve the page numbering I want by somehow automatically having LaTeX identify the center of the bottom line of the actual body-of-text output (after removal of widows and orphans), drop down a \baselineskip below that, and at that location punch in the page number (in my case {\small[} \oldstylenums{\thepage} {\small]})? Do you see a way to do that? – Noah J Jul 02 '23 at 14:52
  • 1
    The only way to access the last line on the page is at the point the footer is added, so this question would be the way to answer your new one. but moving the page numbers is weird, and disabling orphans without adjusting linebreaking will make poor output – David Carlisle Jul 03 '23 at 22:20

2 Answers2

1

This shows how to raise the footer more than fancyhdr will allow.

\documentclass{book}
\usepackage[paperwidth=4.25in, paperheight=5.5in, footskip=\baselineskip,showframe]{geometry}
\usepackage[skip=0pt, indent=20pt]{parskip}
\usepackage{fancyhdr}
\usepackage{microtype}
\usepackage{titlesec}
\usepackage[all]{nowidow} % Eliminates orphans and widows
\usepackage{lipsum}

\emergencystretch 30pt % Causes text to better heed margin

%%% Fancy headers

\fancyhf{} \pagestyle{fancy} \renewcommand\headrulewidth{0pt} \fancyfoot[CE,CO]{\raisebox{\dp\strutbox}[0pt]{{\small[} \oldstylenums{\thepage} {\small]}}}

%%%%% Document

\begin{document}

\vspace*{\fill}Normal text positioning (baseline).\pagebreak

\lipsum[1-70]

\end{document}

John Kormylo
  • 79,712
  • 3
  • 50
  • 120
  • Thank you for your response. I'm sorry, but I don't believe I understand entirely -- would you please say a little more? Why have you turned off nowidow, for example? – Noah J Jul 01 '23 at 22:18
  • That was just an experiment. I forgot to restore it. There is no point in reducing \footskip smaller than \baselineskip since fancyhdr will ignore it (but it looks wierd using showframe). The key is using \raisebox, both to move the contents up and to convince fancyhdr that it wasn't raised (first optional argument). – John Kormylo Jul 02 '23 at 00:10
1

Although fancyhdr is doing something strange (it seems that it typesets a box with at least a \baselineskip plus something else in the footer), I hacked the following:

  1. hide the height of the text in the footer;
  2. unskip the baseline (but that leaves a 3.6pt extra that I do not know where they come from)
  3. now you can play with the footskip parameter to move the footer.
\documentclass{book}
\usepackage[paperwidth=4.25in, paperheight=5.5in, footskip=8pt, showframe]{geometry}
\usepackage[skip=0pt, indent=20pt]{parskip}
\usepackage{fancyhdr}
\usepackage{microtype}
\usepackage{titlesec}
\usepackage[all]{nowidow} % Eliminates orphans and widows
\usepackage{lipsum}

\emergencystretch 30pt % Causes text to better heed margin

%%% Fancy headers \usepackage{adjustbox} \fancyhf{} \pagestyle{fancy} \renewcommand\headrulewidth{0pt} \fancyfoot[CE,CO]{\raisebox{0pt}[0pt][0pt]{% {\small[} \oldstylenums{\thepage} {\small]} }% \par\vspace*{-\baselineskip}}

%%%%% Document

\begin{document}

\lipsum[1-70]

\end{document}

enter image description here

Rmano
  • 40,848
  • 3
  • 64
  • 125