Page LayoutSloppypar and Fancyhdr - No header on last page

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
yurtle
Posts: 4
Joined: Tue Feb 15, 2022 9:43 pm

Sloppypar and Fancyhdr - No header on last page

Post by yurtle »

Howdy,

I have noticed that I do not have a header on the last page of my report. I have tracked this down to an interaction between fancyhdr and sloppypar. I am using sloppy par because without it, LaTex has a few sentences that noticeably stick out beyond the margins. Check out the following:

Code: Select all

\documentclass{report}

\usepackage{lipsum}
\usepackage{fancyhdr}

\title{Your Paper}
\author{You}

\begin{document}
\maketitle

\begin{sloppypar}

\clearpage
\pagestyle{fancy}

\fancyhf{}

    \renewcommand{\headrulewidth}{0pt}
    \fancyhead[R]{\scshape{\fontsize{9pt}{11pt}\selectfont Section Name Here}}
    \fancyfoot[C]{\thepage}
    \setlength{\headheight}{14pt}
    
\chapter{Introduction}

\lipsum[1-10]

\appendix

\chapter{References}

\lipsum[1-12]

\end{sloppypar}

\end{document}
I have the header declarations after the beginning of the document. In my report, I would like slightly different headers in the appendices than the main report. However, honestly, I find fancyhdr and its documentation very difficult to get my head around.

So, what should I do to get a header on that last page? Thanks in advance.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
yurtle
Posts: 4
Joined: Tue Feb 15, 2022 9:43 pm

Sloppypar and Fancyhdr - No header on last page

Post by yurtle »

I was able to ditch sloppypar and things looked okay now. Might be because I changed the font from what I was using before. Now, I have a header on the last page and things look fine. Gonna just go with it, although this is an interesting interaction between sloppypar and fancyhdr.
User avatar
Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

Sloppypar and Fancyhdr - No header on last page

Post by Ijon Tichy »

You've changed things relevant for fancyhdr inside a group (almost every environments are groups). All (or at least most) of these changes are local to the group. You've closed the group before ending the last page. So the changes are not longer valid, when the last page is output.

BTW: sloppypar should not be used for more than one paragraphs. If you want more than one paragraph to be sloppy use the command \sloppy. You can switch sloppy mode off using \fuzzy. Note: Using \sloppy or sloppypar can result in worse typesetting even for paragraphs that can be typeset perfectly without. For example it can result in more hyphenation than needed and usage of more horizontal space than needed. This is not always the case, but it can happen. So I would recommend to use only sloppypar for only those paragraphs that cannot be typeset without overfull \hboxes.
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
yurtle
Posts: 4
Joined: Tue Feb 15, 2022 9:43 pm

Sloppypar and Fancyhdr - No header on last page

Post by yurtle »

Hey Ijon,

Thanks for your reply. Initially, I was having a fair amount of trouble with LaTeX doing a bad job of choosing line breaks. It looked decidedly strange with some sentences sticking out rather noticeably at the right. Sloppypar fixed that. I am not sure what I did in the intervening time that allowed me to remove that environment, but I am happy I no longer need to use it. Thanks also for the info on sloppypar, sloppy, and fuzzy.

Just for my own education, could you clarify what I would need to do if I wanted or needed to use sloppy? Would I end sloppy after the \end{document} command?
User avatar
Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

Sloppypar and Fancyhdr - No header on last page

Post by Ijon Tichy »

\sloppy ends within the group in which it is used. So if you do use it inside \begin{document}…\end{document} but not inside an additional environment or group, it does not really end before termination of TeX, because document is an environment, that does not start and end a group.
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
Post Reply