LyX reverses the order of geometry and fancyhdr packages

Paul Rubin parubin73 at gmail.com
Sat Nov 30 20:00:23 UTC 2024




On 11/30/24 06:41, fcanatay at gmail.com wrote:
> Greetings,
>
> I am trying to produce the following header structure:
>
>
>
>
> This is easy to do in LaTeX:
>
> \documentclass{article}
> \usepackage{geometry}
> \usepackage{fancyhdr}
> \pagestyle{fancy}
>
> \begin{document}
>
> \lhead{left}
> \chead{center}
> \rhead{right}
>
> Some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some
>
> \end{document}
>
>
> When I try to type the same document in LyX, however, the output comes out incorrect.
>
>
>
>
>
> Notice how the header dimensions are different than the text dimensions. The reason appears to be that LyX insists on loading the geometry package, which changes the default margins, after fancyhdr. The same thing happens when I import the above tex file into LyX---the order of the packages is reversed and geometry is loaded last, resulting in the incorrect output as in the second picture.
>
> Is there a way to make LyX respect the correct order of loading packages or some workaround to produce the correct output as in the first picture?
>
> Best,
>
> Fatihcan Atay (using LyX 2.4.2.1 on Mac silicon)
>
>
>
>
>
>   
>
>
>
Hi,

There is a workaround, although it is a mild PITA. Go to Document > 
Settings > Page Layout and set "Page style" to "Default". Next,
go to Document > Settings > Local Layout and add "Provides fancyhdr 1" 
(without the quotation marks). Then drop down to LaTeX Preamble and add 
"\usepackage{fancyhdr}" and "\pagestyle{fancy}".

An MWE is attached.

Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20241130/805d1dfd/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: newfile1.lyx
Type: application/x-lyx
Size: 2504 bytes
Desc: not available
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20241130/805d1dfd/attachment.bin>


More information about the lyx-devel mailing list