2

I'm trying to add a page number at the bottom center. I want the text in the fancy footer to come up one line, so that the page number is not on the same line as the words. Right now, the number is colliding with the words. What's the best way to fix this?

\documentclass[A4paper,10pt,openany]{book}

%PACKAGES
\usepackage{fontspec}
\usepackage{libertine}
\usepackage{titlesec}
\usepackage{multicol}
\usepackage[autocompile]{gregoriotex}
\usepackage{fancyhdr}
\usepackage{verse}
\usepackage{enumitem}
\usepackage{longtable}
\usepackage{xurl}
\usepackage{hanging}
\usepackage{blindtext}

\pagestyle{fancy}
\fancyhf{} % clear all headers and footers
\fancyfoot[CE,CO]{\thepage} 
\renewcommand{\headrulewidth}{0pt} % remove rule between header and text
\setlength{\headheight}{14.5pt}% header height adjust to remove warning

\fancypagestyle{firststyle}{%
   \fancyhead{}%
   \fancyfoot[LE,LO]{very very  very very very very very very very very very very very verylong very long very long amount of text}%
}

\begin{document} 
\thispagestyle{firststyle}

\blindtext


\end{document}
1
  • Use short headers
    – hesham
    Mar 18, 2020 at 22:26

2 Answers 2

1

You can raise the letters a bit using either \raisebox{\baselineskip}{\parbox{\linewidth}{<text>}}, or set it in a p-width tabular. Here is an approach using the latter, with an additional blank line (containing \strut) at the bottom of the tabular; you can also just use \\[\normalbaselineskip] instead of the \strut:

enter image description here

\documentclass{book}

\usepackage{fancyhdr}
\usepackage{blindtext}

\pagestyle{fancy}
\fancyhf{} % clear all headers and footers
\fancyfoot[CE,CO]{\thepage} 
\renewcommand{\headrulewidth}{0pt} % remove rule between header and text
\setlength{\headheight}{14.5pt}% header height adjust to remove warning

\fancypagestyle{firststyle}{%
  \fancyhead{}%
  \fancyfoot[LE,LO]{\begin{tabular}[b]{@{} p{\linewidth} @{}}
    very very very very very very very very very very very very very verylong very 
      long very long amount of text \\
    \strut
  \end{tabular}}%
}

\begin{document} 

\thispagestyle{firststyle}

\blindtext

\end{document}
8
  • An alternative would be to place the page number as part of the "very long text."...
    – Werner
    Mar 18, 2020 at 22:27
  • How would I move the text up one more line, so that the number is not on the same line as the text? Mar 19, 2020 at 6:45
  • You probably should use \begin{tabular}[b]{... Mar 19, 2020 at 15:43
  • @JohnKormylo: Thanks; forgot that.
    – Werner
    Mar 19, 2020 at 15:58
  • @R.B.Jawad: I've updated my answer to use \begin{tabular}[b]{..}, which improves the layout and is probably more inline with what you want.
    – Werner
    Mar 19, 2020 at 15:59
0

Just for fun, this adds the text using everypage instead of fancyhdr, making the added text independent of the pagestyle.

\documentclass{book}
%PACKAGES
%\usepackage{fontspec}
%\usepackage{libertine}
\usepackage{titlesec}
\usepackage{multicol}
%\usepackage[autocompile]{gregoriotex}
%\usepackage{fancyhdr}
\usepackage{verse}
\usepackage{enumitem}
\usepackage{longtable}
\usepackage{xurl}
\usepackage{hanging}
\usepackage{blindtext}
\usepackage{everypage}
\usepackage{showframe}

\addtolength{\footskip}{\baselineskip}

\AddThispageHook{\ifodd\value{page}\let\margin=\oddsidemargin
  \else \let\margin=\evensidemargin
  \fi
  \rlap{\hskip\margin
    \raisebox{\dimexpr \normalbaselineskip-\topmargin-\headheight-\headsep-\textheight-\footskip}%
    [0pt][0pt]{\parbox[b]{\textwidth}%
    {very very  very very very very very very very very very very very very
      long very long very long amount of text}}}}

\thispagestyle{plain}
\begin{document} 

\blindtext

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .