Re: Fancyhdr e intestazione capitoli

#7152
lorenzo.pantieri
Partecipante
    Up
    0
    Down
    ::


    Ciao, senza nessuna pretesa, ti suggerisco di dare un’occhiata a questo codice (che ho trovato su Una mica tanto breve intro a LaTeX, con qualche correzione suggerita dallo staff del forum). Forse può esserti utile, a me funziona egregiamente.

    La struttura del documento (relativamente alla parte che ti interessa) è la seguente:

    `\documentclass[a4paper,11pt]{book}

    \usepackage[ansinew]{inputenc}
    \usepackage[italian]{babel}
    \usepackage[T1]{fontenc}
    \usepackage{fancyhdr}

    \makeatletter
    \def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
    \hbox{}
    \vspace*{\fill}
    \vspace{\fill}
    \thispagestyle{empty}
    \newpage
    \if@twocolumn\hbox{}\newpage\fi\fi\fi}
    \makeatother

    \pagestyle{fancy}
    \renewcommand{\chaptermark}[1]{\markboth{#1}{}}
    \renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
    \fancyhf{}
    \fancyhead[LE,RO]{\scshape\thepage}
    \fancyhead[LO]{\scshape\footnotesize\nouppercase{\rightmark}}
    \fancyhead[RE]{\scshape\footnotesize\nouppercase{\leftmark}}
    \renewcommand{\headrulewidth}{0.5pt}
    \renewcommand{\footrulewidth}{0pt}
    \addtolength{\headheight}{1.6pt}

    \begin{document}
    \frontmatter
    \include{frontespizio}
    \include{ringraziamenti}
    \tableofcontents \listoffigures
    \mainmatter
    \include{introduzione}
    \include{capitolo1}
    \include{capitolo2}
    \include{conclusioni}
    \backmatter
    \include{bibliografia}
    \end{document}`

    dove i file ringraziamenti.tex, introduzione.tex e conclusioni.tex hanno rispettivamente gli incipit:

    `\chapter*{Ringraziamenti}
    \markboth{Ringraziamenti}{}`

    `\chapter*{Introduzione}
    \markboth{Introduzione}{}
    \addcontentsline{toc}{chapter}{Introduzione}%
    \setcounter{page}{1}`

    `\chapter*{Conclusioni}
    \markboth{Conclusioni}{}%
    \addcontentsline{toc}{chapter}{Conclusioni}%`

    Buon fancyhdr!
    L.

    Go to top