我使用 \usepackage{fancyhdr} 来设置标题和页码的位置。我在一个页面上报告了几个图表,因为我想让这些图表足够大,所以我使用了 \newgeometry 来调整页边距。但是,现在页码不再位于底部,也不在中间。我试过 \adjustwidth,但没有成功。你们知道我如何既能调整页边距,又能保持页码的位置与以前相同吗?任何帮助都将不胜感激。非常感谢你们的时间和帮助!
\documentclass[a4paper,12pt,openright]{book}
\usepackage[left=30mm,right=35mm,top=35mm, bottom=30mm]{geometry}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[ngerman,english]{babel}
\usepackage{epsfig,amsfonts,amsmath,amsthm,amsbsy,amssymb,calc,longtable,url,rotating,graphicx,graphics,lscape,tabularx,xtab,eurosym}
\usepackage[flushleft]{threeparttable}
\usepackage[font=footnotesize, labelfont=footnotesize, labelformat=empty, position=top]{subcaption}
\usepackage[font=small,skip=0pt]{caption}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{}
\fancyhf{}
\fancyhead[LO]{\rightmark}
\fancyhead[RE]{\leftmark}
\fancyfoot{}
\fancyfoot[CE, CO]{\thepage}
\renewcommand{\headrulewidth}{0pt}
\usepackage{tabularray}
\begin{document}
\chaptermark{}
\setcounter{footnote}{0}
\section{1}
Example page with correct position of page number
\newgeometry{left=20mm,right=25mm}
\begin{figure}
\caption{Threshold in 2004}
\vspace*{1em}
\centering
\makebox[20pt]{\raisebox{100pt}{\rotatebox[origin=c]{90}{Full Sample}}}%
\begin{subfigure}[b]{0.475\textwidth}
\caption*{Eligible} \vspace{-0.6em}%
\includegraphics[clip, trim=0cm 0cm 0cm 0.5cm, width=\textwidth]{Graph_1.pdf}
\end{subfigure}\hspace{0.01cm}\vspace{-0.5em}%
\begin{subfigure}[b]{0.475\textwidth}
\caption*{Not Eligible} \vspace{-0.6em}%
\includegraphics[clip, trim=0cm 0cm 0cm 0.5cm, width=\textwidth]{Graph_2.pdf}
\end{subfigure}
\makebox[20pt]{\raisebox{100pt}{\rotatebox[origin=c]{90}{Sub-Sample}}}%
\begin{subfigure}[b]{0.475\textwidth}
\includegraphics[clip, trim=0cm 0cm 0cm 0.3cm, width=\textwidth]{Graph_3.pdf}
\end{subfigure}\hspace{0.01cm}\vspace{-0.5em}%
\begin{subfigure}[b]{0.475\textwidth}
\includegraphics[clip, trim=0cm 0cm 0cm 0.3cm, width=\textwidth]{Graph_4.pdf}
\end{subfigure}
\vspace*{-0.25cm}
\caption*{\footnotesize The graphs shows XXX...}
\end{figure}
\restoregeometry
\end{document}
答案1
\fancyfootoffset{0pt}
之后执行 \newgeometry
会导致fancyhdr
重新计算页眉和页脚。
之后就不需要了\restoregeometry
。
\documentclass[a4paper,12pt,openright]{book}
\usepackage[left=30mm,right=35mm,top=35mm, bottom=30mm]{geometry}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[ngerman,english]{babel}
\usepackage{epsfig,amsfonts,amsmath,amsthm,amsbsy,amssymb,calc,longtable,url,rotating,graphicx,graphics,lscape,tabularx,eurosym}
\usepackage[flushleft]{threeparttable}
\usepackage[font=footnotesize, labelfont=footnotesize, labelformat=empty, position=top]{subcaption}
\usepackage[font=small,skip=0pt]{caption}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{}
\fancyhf{}
\fancyhead[LO]{\rightmark}
\fancyhead[RE]{\leftmark}
\fancyfoot{}
\fancyfoot[CE, CO]{\thepage}
\renewcommand{\headrulewidth}{0pt}
\usepackage{tabularray}
\usepackage{showframe} % ONLY to show the margins <<<<<<<<<<<
\begin{document}
\chaptermark{}
\setcounter{footnote}{0}
\section{1}
Example page with correct position of page number
\newgeometry{left=20mm,right=25mm}
\fancyfootoffset{0pt} % added <<<<<<<<<<<<<<<<
\begin{figure}
\caption{Threshold in 2004}
\vspace*{1em}
\centering
\makebox[20pt]{\raisebox{100pt}{\rotatebox[origin=c]{90}{Full Sample}}}%
\begin{subfigure}[b]{0.475\textwidth}
\caption*{Eligible} \vspace{-0.6em}%
\includegraphics[clip, trim=0cm 0cm 0cm 0.5cm, width=\textwidth]{example-image}
\end{subfigure}\hspace{0.01cm}\vspace{-0.5em}%
\begin{subfigure}[b]{0.475\textwidth}
\caption*{Not Eligible} \vspace{-0.6em}%
\includegraphics[clip, trim=0cm 0cm 0cm 0.5cm, width=\textwidth]{example-image}
\end{subfigure}
\makebox[20pt]{\raisebox{100pt}{\rotatebox[origin=c]{90}{Sub-Sample}}}%
\begin{subfigure}[b]{0.475\textwidth}
\includegraphics[clip, trim=0cm 0cm 0cm 0.3cm, width=\textwidth]{example-image}
\end{subfigure}\hspace{0.01cm}\vspace{-0.5em}%
\begin{subfigure}[b]{0.475\textwidth}
\includegraphics[clip, trim=0cm 0cm 0cm 0.3cm, width=\textwidth]{example-image}
\end{subfigure}
\vspace*{-0.25cm}
\caption*{\footnotesize The graphs shows XXX...}
\end{figure}
\restoregeometry
Some text.
\end{document}