有些页面没有为我编号 - 让\ clearpage \ relax

问题描述 投票:0回答:1

我使用\ let \ clearpage \ relax在一页上保留两章,这导致上一页上的页码不显示。

有没有办法可以撤消文档中的命令,并且仍然保留两个章节?

提供更多细节。

\documentclass[12pt,a4paper]{report}
\usepackage[left=3cm,right=3cm,top=-2cm,bottom=4cm]{geometry}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{placeins}
\usepackage{tocloft}
\usepackage{ifthen}
\usepackage{fancyhdr}
\usepackage{lipsum}
\usepackage{float}
\floatstyle{plaintop}
\restylefloat{table}
\usepackage{caption} 
\captionsetup[table]{skip=10pt}
\pagestyle{fancy}
\usepackage{setspace}
\makeatletter

% addition for not showing 'Chapter 1'
\def\@makechapterhead#1{%
  \vspace*{50\p@}%
  {\parindent \z@ \raggedright \normalfont
    \interlinepenalty\@M
    \Huge \bfseries
    \ifnum \c@secnumdepth >\m@ne
      \thechapter\nobreakspace
    \fi
    #1\par\nobreak
    \vskip 40\p@
  }}


\@ifundefined{chapter}%
   {}%
     {\renewcommand{\chaptermark}[1]{%
            \ifthenelse{\value{chapter} < 1}%
                {\markboth{#1}{}}%
                {\markboth{\thechapter\ #1}{}}
        }}


\addtolength{\headheight}{\baselineskip}
\renewcommand{\headrulewidth}{0.4pt} %% thin line under header
%\renewcommand{\headrulewidth}{0pt} %% no line under header
\renewcommand{\footrulewidth}{0pt}
\fancyhf{}                            %% Clear all fields.
%\fancyhead[LE,RO]{\sffamily\thepage}
%\fancyhead[LO,RE]{\sffamily\nouppercase{\leftmark}}
\fancyhead[R]{\sffamily\thepage}
\fancyhead[L]{\sffamily\nouppercase{\leftmark}}

\fancypagestyle{plain}{%
    \fancyhf{} % clear all header and footer fields
    \fancyfoot[C]{\sffamily\thepage} % except the center
    \renewcommand{\headrulewidth}{0pt}
    \renewcommand{\footrulewidth}{0pt}
}
\makeatother
latex
1个回答
1
投票

问题是由两个因素共同造成的:

  • 您的文档为章节页面和普通页面使用不同的页面样式。在章节页面上,页码位于底部中央,在普通页面上有一个带章节标题和页码的页眉
  • 你使用的geometry包装有一个较大的负上边距。这会将正常页面的标题推离页面,您不再看到它们上的页码。

建议的解决方案:

  • 使用合理的页面几何值,例如\usepackage[left=3cm,right=3cm,top=2cm,bottom=4cm]{geometry} 这也有一个好处,就是你可以删除你的数字和表格中的大部分硬代码\vspaces
  • 如果您要删除标题并将页码移动到所有普通页面的底部中心,可以使用以下定义: \fancyhf{} % clear all header and footer fields \fancyfoot[C]{\sffamily\thepage} % except the center \renewcommand{\headrulewidth}{0pt} \renewcommand{\footrulewidth}{0pt}
© www.soinside.com 2019 - 2024. All rights reserved.