我想将页面样式的页脚居中,而不是相对于页面边距,而是相对于实际纸张的宽度。我专门为标题页创建了一个页面样式。我以为该\makerunningwidth
线会正确计算页面的中心,但是,正如您所看到的,页码与其余文本不对齐(其余文本相对于纸张的中心绝对对齐)。
该文档生成于
\documentclass{memoir}
\copypagestyle{INRSDocExamTitle}{plain}
\makerunningwidth{INRSDocExamTitle}{\paperwidth}
\makeoddfoot{INRSDocExamTitle}{}{\thepage}{}
\makeevenfoot{INRSDocExamTitle}{}{\thepage}{}
\begin{document}
\thispagestyle{INRSDocExamTitle}
\newlength{\centeradjust}
\calccentering{\centeradjust} % Calculate center length and stores in centeradjust
\begin{adjustwidth*}{\centeradjust}{-\centeradjust} % Adjust center
\begin{adjustwidth}{-1cm}{-1cm}
\begin{center}
\begin{OnehalfSpace}
\vspace*{3\baselineskip}
{\Large Centered text using adjustwidth (as per the \texttt{memoir} manual)}
\vfill
{\large This foooter is not centered with respect to the page,\\
but with respect to the type block. \\
$\downarrow$
}
\vspace*{3\baselineskip}
\end{OnehalfSpace}
\end{center}
\end{adjustwidth}
\end{adjustwidth*}
\end{document}
有没有办法使页脚相对于页面而不是边距居中?
答案1
这个想法是通过偏移页码来弥补不均匀的页边距。
\documentclass{memoir}
\copypagestyle{INRSDocExamTitle}{plain}
\makeoddfoot{INRSDocExamTitle}{}{\thepage\offset}{}
\makeevenfoot{INRSDocExamTitle{}{\thepage\offset}{}
\newcommand{\offset}% center page number in text area
{\ifodd\value{page}\hspace{\dimexpr 2in+2\oddsidemargin+\textwidth-\paperwidth}%
\else\hspace{\dimexpr 2in+2\evensidemargin+\textwidth-\paperwidth}%
\fi}
\usepackage{tikzpagenodes}% used only to show center of page
\begin{document}
\pagestyle{INRSDocExamTitle}
\begin{tikzpicture}[remember picture,overlay]
\draw[red] (current page.north) -- (current page.south);
\end{tikzpicture}
odd page
\newpage
\begin{tikzpicture}[remember picture,overlay]
\draw[red] (current page.north) -- (current page.south);
\end{tikzpicture}
even page
\end{document}
答案2
我认为最简单的方法是手动编码这个特定的页面样式:
\makeatletter
\@namedef{ps@INRSDocExamTitle}{%
\@namedef{@oddfoot}{%
\hspace{-\spinemargin}%
\parbox[b]{\paperwidth}{%
\strut\hfill \thepage \hfill\strut%
}%
}%
}
\makeatother
只是为了展示效果
\documentclass[a4paper]{memoir}
\setlrmarginsandblock{1cm}{4cm}{*}
\checkandfixthelayout
\makeatletter
\@namedef{ps@INRSDocExamTitle}{%
\@namedef{@oddfoot}{%
\hspace{-\spinemargin}%
\parbox[b]{\paperwidth}{%
\strut\hfill \thepage \hfill\strut%
}%
}%
}
\makeatother
\begin{document}
\thispagestyle{INRSDocExamTitle}
\newlength{\centeradjust}
\calccentering{\centeradjust} % Calculate center length and stores in centeradjust
\begin{adjustwidth*}{\centeradjust}{-\centeradjust} % Adjust center
\begin{adjustwidth}{-1cm}{-1cm}
\begin{center}
\begin{OnehalfSpace}
\vspace*{3\baselineskip}
{\Large Centered text using adjustwidth (as per the \texttt{memoir} manual)}
\vfill
This foooter is not centered with respect to the page,\\
but with respect to the type block.
$\downarrow$
\noindent
test\hfill\smash{%
\rule[-3.7cm]{0.4pt}{4cm}%
}\hfill test%
\vspace*{3\baselineskip}
\end{OnehalfSpace}
\end{center}
\end{adjustwidth}
\end{adjustwidth*}
\end{document}