[Tex/LaTex] LyX fancy header \thispagestyle{fancy}

header-footerlyxpreamble

I am using LyX and would like (all) my document pages to have a fancy header style that I defined. However, including

\thispagestyle{fancy}

or

\AtBeginDocument{\thispagestyle{fancy}}

doesn't work! The only way I got it to work is using the ERT command

\thispagestyle{fancy}

at the beginning of the document. Does anyone know how to get over it without using an ERT?

Best Answer

\thispagestyle only pertains to the page that you're calling it on. To make all the pages have the fancy style, you need to use \pagestyle{fancy}. In LyX, it is possible to set this via Document->Settings... and choosing the "Page Layout" tab with the "Heading style" as fancy:

enter image description here

Note that the standard document classes that contains \chapter (book or report) will still use \thispagestyle{plain} for the first page of every \chapter (this includes title pages, as well as ToC-related first-pages as well, since the latter is issued using \chapter*). To avoid this, you have to issue an explicit \thispagestyle{fancy} in an ERT after the chapter title.