请问如何做到前置部分仅页脚,无页眉,主体部分有页眉(包括第一页),有页脚。

发布于 2021-06-06 18:27:22

请问如何做到?


  • 前置部分

    • 仅页脚,无页眉。
  • 主体部分

    • 有页眉(包括第一页),有页脚。

我尝试用 fancyhdr 宏包实现,但是 fancyhdr 章所在页样式默认为 plain 导致我无论怎么重新定义都无法同时满足上述两点。
以下为我的代码:


\documentclass{ctexbook}

\usepackage{fancyhdr}
\usepackage{zhlipsum}


\fancypagestyle{plain}{
    \renewcommand{\headrulewidth}{0.6pt}
    \fancyhf{}
    \chead{页眉}
    \cfoot{\thepage}
}
\fancypagestyle{onlyfoot}{
    \renewcommand{\headrulewidth}{0pt}
    \fancyhf{}
    \cfoot{\thepage}
}
\makeatletter
\renewcommand\frontmatter{%
  \if@openright
  \cleardoublepage
  \else
    \clearpage
  \fi
\@mainmatterfalse
\pagenumbering{Roman}\pagestyle{onlyfoot}
}
% 前置部分页码用罗马数字编号,仅页脚,无页眉。

\renewcommand\mainmatter{%
\if@openright
  \cleardoublepage
  \else
    \clearpage
  \fi
\@mainmattertrue
\pagenumbering{arabic}\pagestyle{plain}
}
% 主体部分页码用阿拉伯数字编号,有页脚,有页眉。
\makeatother


\begin{document}

\frontmatter
\chapter{前置部分}
\zhlipsum[1-6]

\mainmatter
\chapter{主体部分}
\zhlipsum[1-6]

\end{document}

查看更多

关注者
0
被浏览
1.3k
如果您有什么不同意见,您是对的,我是错的。
这家伙很懒,什么也没写!

\ctexset 提供的接口

\documentclass{ctexbook}

\usepackage{fancyhdr}
\usepackage{zhlipsum}


\fancypagestyle{plain}{
    \renewcommand{\headrulewidth}{0.6pt}
    \fancyhf{}
    \chead{页眉}
    \cfoot{\thepage}
}
\fancypagestyle{onlyfoot}{
    \renewcommand{\headrulewidth}{0pt}
    \fancyhf{}
    \cfoot{\thepage}
}
\makeatletter
\renewcommand\frontmatter{%
  \if@openright
  \cleardoublepage
  \else
    \clearpage
  \fi
\@mainmatterfalse
\pagenumbering{Roman}\pagestyle{onlyfoot}
\ctexset{chapter/pagestyle=onlyfoot}
}
% 前置部分页码用罗马数字编号,仅页脚,无页眉。

\renewcommand\mainmatter{%
\if@openright
  \cleardoublepage
  \else
    \clearpage
  \fi
\@mainmattertrue
\pagenumbering{arabic}\pagestyle{plain}
\ctexset{chapter/pagestyle=plain}
}
% 主体部分页码用阿拉伯数字编号,有页脚,有页眉。
\makeatother


\begin{document}

\frontmatter
\chapter{前置部分}
\zhlipsum[1-6]

\mainmatter
\chapter{主体部分}
\zhlipsum[1-6]

\end{document}
2 个回答
站长
站长 2021-06-06
这家伙很懒,什么也没写!

因为我前面新定义了一个样式 onlyfoot,所以上面答案有些乱,重新整理一下。


\documentclass{ctexbook}

\usepackage{fancyhdr}
\usepackage{zhlipsum}


\fancyhf{}
\chead{页眉}
\cfoot{\thepage}


\makeatletter
\renewcommand\frontmatter{%
  \if@openright
  \cleardoublepage
  \else
    \clearpage
  \fi
\@mainmatterfalse
\pagenumbering{Roman}\pagestyle{plain}
}
% 前置部分页码用罗马数字编号,仅页脚,无页眉。

\renewcommand\mainmatter{%
\if@openright
  \cleardoublepage
  \else
    \clearpage
  \fi
\@mainmattertrue
\pagenumbering{arabic}\pagestyle{fancy}
\ctexset{chapter/pagestyle=fancy}
}
% 主体部分页码用阿拉伯数字编号,有页脚,有页眉。
\makeatother


\begin{document}

\frontmatter
\chapter{前置部分}
\zhlipsum[1-6]

\mainmatter
\chapter{主体部分}
\zhlipsum[1-6]

\end{document}

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览