2

I have a LyX article, structured with Parts -> Sections -> Subsections, and I want to print the Part name in the document header.

I am trying to get the part name with the following command, but it prints "Part"

\fancyhead[LE,RO]{\slshape \partname}

I have also read & tried this but my document doesn't compile.

How can I simply get the part name within the LaTeX Preamble?

4
  1. In "Document settings..." under "Page Layout" change the heading style to "fancy".

  2. It seems that you want the part title in the header and not \partname, which will usually print the word "Part" or a translation of it. Hence, considering the suggested thread and correcting a typo - {part} should be {\part} - we put

    \let\Oldpart\part
    \newcommand{\parttitle}{}
    \renewcommand{\part}[1]{\Oldpart{#1}\renewcommand{\parttitle}{#1}}
    

    into the LaTeX Preamble.

  3. At the beginning of your document or from where every you want to start it as TeX code/ERT (or for global setting, in the LaTeX Preamble) we write

    \fancyhead[LE,RO]{\slshape \parttitle}
    
| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.