1

I want to add "PREFACE" in header of the chapter preface. Because the preface is unnumbered chapter, it cannot show in header. How to show it?

\documentclass[a4paper,twoside,12pt]{book}
\usepackage[left=3cm,right=3cm,top=3cm,bottom=3cm]{geometry}
\usepackage{fancyhdr}
\usepackage{titlesec}

\titleformat{\chapter}
[display]
{\center\bfseries}
{\large\MakeUppercase{\chaptertitlename} \thechapter}{0cm}{\large}
\titlespacing{\chapter}{0cm}{-1cm}{0.5cm}
%\usepackage[utf8]{inputenc}
\titleformat{\section}
[hang]
{\bfseries}
{\bfseries\thesection}{1ex}{\bfseries}
%\titlespacing{\section}{1.5pt}{0.2cm}{-0.2cm}

\titleformat{\subsection}
[hang]
{\bfseries}
{\bfseries\thesubsection}{1ex}{\bfseries}
%\titlespacing{\subsection}{0cm}{3ex}{0ex}

\renewcommand{\thechapter}{\Roman{chapter}}
\renewcommand{\thesection}{\arabic{chapter}.\arabic{section}}
\renewcommand{\thesubsection}{\arabic{chapter}.\arabic{section}.\arabic{subsection}}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE,RO]{\thepage}
\fancyhead[RE,LO]{\leftmark}
\fancyfoot[CE,CO]{}
\fancyfoot[LE,RO]{\textbf{{\footnotesize Ongky Denny Wijaya}}}
\renewcommand{\headrulewidth}{1pt}
\renewcommand{\footrulewidth}{1pt}
\fancypagestyle{plain}{%
    \fancyhf{}%
    \fancyhead[LE,RO]{\thepage}%
    \fancyhead[RE,LO]{\leftmark}
    \fancyfoot[CE,CO]{}
    \fancyfoot[LE,RO]{\textbf{{\footnotesize Ongky Denny Wijaya}}}
}
\begin{document}
    \frontmatter
    \chapter*{PREFACE}
    ABC
    \mainmatter
    \chapter{TEST}

enter image description here

3

add manually with \markboth{PREFACE}{}:

\documentclass[a4paper,twoside,12pt]{book}
\usepackage[left=3cm,right=3cm,top=3cm,bottom=3cm]{geometry}
\usepackage{fancyhdr}
\usepackage{titlesec}

\titleformat{\chapter}
[display]
{\center\bfseries}
{\large\MakeUppercase{\chaptertitlename} \thechapter}{0cm}{\large}
\titlespacing{\chapter}{0cm}{-1cm}{0.5cm}
%\usepackage[utf8]{inputenc}
\titleformat{\section}
[hang]
{\bfseries}
{\bfseries\thesection}{1ex}{\bfseries}
%\titlespacing{\section}{1.5pt}{0.2cm}{-0.2cm}

\titleformat{\subsection}
[hang]
{\bfseries}
{\bfseries\thesubsection}{1ex}{\bfseries}
%\titlespacing{\subsection}{0cm}{3ex}{0ex}

\renewcommand{\thechapter}{\Roman{chapter}}
\renewcommand{\thesection}{\arabic{chapter}.\arabic{section}}
\renewcommand{\thesubsection}{\arabic{chapter}.\arabic{section}.\arabic{subsection}}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE,RO]{\thepage}
\fancyhead[RE,LO]{\leftmark}
\fancyfoot[CE,CO]{}
\fancyfoot[LE,RO]{\textbf{{\footnotesize Ongky Denny Wijaya}}}
\renewcommand{\headrulewidth}{1pt}
\renewcommand{\footrulewidth}{1pt}
\fancypagestyle{plain}{%
    \fancyhf{}%
    \fancyhead[LE,RO]{\thepage}%
    \fancyhead[RE,LO]{\leftmark}
    \fancyfoot[CE,CO]{}
    \fancyfoot[LE,RO]{\textbf{{\footnotesize Ongky Denny Wijaya}}}
}
\begin{document}
    \frontmatter
    \chapter*{PREFACE}
    \markboth{PREFACE}{}
    ABC
    \mainmatter
    \chapter{TEST}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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