Latex 对幻想的沮丧

Latex 对幻想的沮丧,latex,tex,Latex,Tex,我有以下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{\cha

我有以下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}
可以在以下位置查看示例:

在右上角:

  • 如果没有章节,如何显示章节标题,如第2页
  • 如第4页所示,如果有活动的章节,如何使其显示章节标题,而只显示章节标题(无编号、无子章节、子章节等)
谢谢

你就快到了

以下两个标记应该可以做到这一点:

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

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

我一周前才开始处理标题,所以帮不了什么忙。您看到fancyhdr文档中的标记部分了吗?我建议您特别阅读“标记”和相关“命令”的解释。您需要对chaptermark、sectionmark和subsectionmark做一些工作,当然还有left、right mark和mark;你也可以在上面的链接中找到一些有用的PKG。这不是一个真正的答案,但我希望阅读能有所启发。我读过那本手册,但从来没有在逻辑页面上得到正确的分数。Fancyhdr应该在引擎盖下完成工作,为什么我必须反复尝试和错误修复东西?谢谢。从我这里喝杯啤酒。干杯:-)