2010-09-10 30 views
3

在我目前的文檔中有一些章節必須加上\chapter*命令,因爲我不希望它們成爲真正的章節(在toc中沒有條目,沒有章節號,...)。這工作正常。LaTeX:' chapter * {abc123}'自動更新' leftmark''

但在我的標題中,我想要顯示chapter-name。我使用fancyheaders\leftmark

\fancyhead[RO,LE]{\leftmark} 

的問題是,對於與\chapter* -command添加章節,\leftmark沒有更新,因此頭仍顯示前章的章名。

因此,我需要強制\chapter*自動更新\leftmark,或者我切換到\chapter-命令,但是防止其他的東西出現(輸入toc,...)。但我不知道如何!有任何想法嗎?

+1

您可能想要在http://tex.stackexchange.com/上發佈此內容。 – 2010-09-10 11:00:45

回答

0

我不知道這會工作,因爲我沒有我現在的機器上安裝了LaTeX的做...

但是你可以試試你的\章後設置\ markleft命令*命令,如下所示:

\chapter*{Chapter title goes here} 
\markleft{Chapter title goes here} % content should be added to the \leftmark 

希望這會有所幫助。

+0

感謝您的回答!但問題是,如果我手動設置了\ leftmark,稍後\ chapter-commands不會再更新它! – NATOR 2010-09-10 11:54:54

+0

似乎是有意的。有關此事的更多詳細信息,請參閱[花式標題文檔] [1]第10-11頁。 [1]:http://www.ctan.org/tex-archive/macros/latex/contrib/fancyhdr/fancyhdr.pdf – froeschli 2010-09-10 12:56:01

1

好吧,我做到了!解決方案是僅在特定塊內重新定義\ leftmark!很簡單,如果你知道這事。)

{ 
    \renewcommand{\leftmark}{ABC123} 
    \chapter*{ABC123} 

    %... and so on ... 
} 
+0

我是否正確理解:您正在爲每個\ chapter *重新定義\ leftmark。 – froeschli 2010-09-10 15:07:55

3

我不得不重新定義爲我所需要的章,節的命令,並設置\leftmark明確。章命令將無法再使用leftmark,但我不在乎,因爲我使用的整個文件

\newcommand{\nnchapter}[1]{ 
    \phantomsection 
    \addcontentsline{toc}{chapter}{#1}\renewcommand{\leftmark}{#1}\chapter*{#1} 
} 
\newcommand{\nnsection}[1]{ 
    \phantomsection 
    \addcontentsline{toc}{section}{#1}\renewcommand{\leftmark}{#1}\section*{#1} 
} 
1

在我\nnchapter\nnsection命令試試這個:

\let\oldleftmark=\leftmark 
    \chapter*{My New Leftmark} 
    \renewcommand{\leftmark}{My New Leftmark} 
     ... 
     Your text 
     ... 
    \pagebreak 
    \chapter{Next Chapter} 
    \let\leftmark=\oldleftmark 

pagebreak需要以確保使用新的lefmark

3

\chapter等命令的*形式不會調用標記命令。因此,如果您希望您的前言設置標題信息,但不能將其編號或放入目錄中,則必須自行發出\markboth命令,例如,

\chapter*{abc123\markboth{abc123}{}}