gpt4 book ai didi

latex - 对fancyhdr 感到沮丧

转载 作者:行者123 更新时间:2023-12-01 09:09:20 25 4
gpt4 key购买 nike

我有以下 tex 文档:

\documentclass[a4paper,11pt,oneside]{book}
\usepackage[usenames,dvipsnames]{color}
\usepackage[T1]{fontenc}
\usepackage[utf8x]{inputenc}
\usepackage{lipsum}
\usepackage[left=2cm,top=3cm,right=1.5cm,bottom=2cm]{geometry}

\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{#1}{}}
\renewcommand{\subsectionmark}[1]{\markright{\thesubsection}{}}

\usepackage[Lenny]{fncychap}
\usepackage{thumbpdf}
\usepackage[colorlinks]{hyperref}
\setlength\marginparwidth{1cm}
\usepackage{fancyhdr}

\pagestyle{fancy}
\fancyhead[LO,L]{Book template}
\fancyhead[RO,R]{\rightmark}
\fancyfoot[CO,C] {\thepage}

\begin{document}
\chapter{Chapter Intro}
\lipsum
\chapter{Chapter with subsections}
\section{section foo}
\lipsum
\subsection{subsection bar}
\lipsum
\end{document}

可以在 http://www.mediafire.com/?0m5mnka32kj 查看示例

右上角:

  • 如果没有章节,如何让它显示章节标题,如第 2 页?
  • 如果有事件部分,如何让它显示部分标题,而只显示部分标题(没有数字、没有小节、小小节等),就像第 4 页上的情况一样?

谢谢

最佳答案

你快到了!

以下两个标记应该可以解决问题:

\renewcommand{\chaptermark}[1]{\markright{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{#1}{}}

确保将它们移动到 \pagestyle{fancy} 之后的位置。另外请务必删除自定义 \subsectionmark,除非您想在标题中使用某些小节信息。

关于latex - 对fancyhdr 感到沮丧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3032972/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com