花式页脚文本加页码

花式页脚文本加页码

我正在尝试在底部中央添加页码。我希望花式页脚中的文本向上一行,这样页码就不会与文字在同一行。现在,页码与文字冲突了。解决这个问题的最佳方法是什么?

\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

您可以使用 或-width\raisebox{\baselineskip}{\parbox{\linewidth}{<text>}}来稍微抬高字母。以下是使用后者的方法,在 底部有一个额外的空白行(包含 );您也可以直接使用来代替:ptabular\struttabular\\[\normalbaselineskip]\strut

在此处输入图片描述

\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}

答案2

只是为了好玩,这使用 everypage 而不是 fancyhdr 添加文本,使得添加的文本独立于 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}

相关内容