0

I am trying to create a LaTeX template with a specific header. Here is what I am trying to do :

  • Left odd : \subsubsection
  • Right odd : My name, I can deal with this one :)
  • Left even : \subsection
  • Right even : \chapter

For each title, I only want the title and not "Chapter 1 : chaptername".

I have used this :

\renewcommand{\subsectionmark}[1]{\markright{#1}}
\renewcommand{\subsubsectionmark}[1]{\markleft{#1}}

But it does only work for two titles, right ?

Here is my code :

\documentclass[12pt,twoside]{book}
\usepackage{fontspec}
\usepackage{lipsum}

\setmainfont{[ACaslonPro-Regular.otf]}
\newfontfamily{\acasSb}{ACaslonPro-Semibold.otf}
\newfontfamily{\acasB}{ACaslonPro-Bold.otf}
\newfontfamily{\acasR}{ACaslonPro-Regular.otf}

\newfontfamily{\frutL}{FrutigerLTStd-Light.otf}
\newfontfamily{\frutB}{FrutigerLTStd-Bold.otf}
\newfontfamily{\frutR}{FrutigerLTStd-Roman.otf}


\usepackage[paperheight=240mm,paperwidth=160mm, left=22mm, right = 20mm, top = 20mm, bottom = 22mm]{geometry}

\usepackage{fancyhdr}
\pagestyle{fancy}

\renewcommand{\subsectionmark}[1]{\markright{#1}}
\renewcommand{\subsubsectionmark}[1]{\markleft{#1}}

\fancyhead[LO]{\fontsize{8}{12} \selectfont \acasB \textsc{\rightmark}}
\fancyhead[RO]{}
\fancyhead[C]{}
\fancyhead[LE]{\fontsize{8}{12} \selectfont \acasB \rightmark}
\fancyhead[RE]{\fontsize{8}{12} \selectfont \acasB \textsc{\leftmark}}


\begin{document}

\chapter{This should be on right even}
\section{This should not appear at all}
\subsection{This should be on left even}
\subsubsection{This should be on odd left}

\lipsum[1-8]
\end{document}

Thanks for your help

1 Answer 1

0

Here is a solution I have found :

\documentclass[12pt,twoside]{book}
\usepackage{fontspec}
\usepackage{lipsum}

\setmainfont{[ACaslonPro-Regular.otf]}
\newfontfamily{\acasSb}{ACaslonPro-Semibold.otf}
\newfontfamily{\acasB}{ACaslonPro-Bold.otf}
\newfontfamily{\acasR}{ACaslonPro-Regular.otf}

\newfontfamily{\frutL}{FrutigerLTStd-Light.otf}
\newfontfamily{\frutB}{FrutigerLTStd-Bold.otf}
\newfontfamily{\frutR}{FrutigerLTStd-Roman.otf}


\usepackage[paperheight=240mm,paperwidth=160mm, left=22mm, right = 20mm, top = 20mm, bottom = 22mm]{geometry}

\usepackage{fancyhdr}
\pagestyle{fancy}

\renewcommand{\chaptermark}[1]{\markboth{#1}{}}

\let\Subsubsectionmark\subsubsectionmark
\def\subsubsectionmark#1{\def\Subsubsectionname{#1}\Subsubsectionmark{#1}}

\let\Subsectionmark\subsectionmark
\def\subsectionmark#1{\def\Subsectionname{#1}\Subsectionmark{#1}}




\fancyhead[LO]{\fontsize{8}{12} \selectfont \acasB \textsc{\Subsubsectionname}}
\fancyhead[RO]{}
\fancyhead[C]{}
\fancyhead[LE]{\fontsize{8}{12} \selectfont \acasB \Subsectionname}
\fancyhead[RE]{\fontsize{8}{12} \selectfont \acasB \textsc{\leftmark}}


\begin{document}

\chapter{This should be on right even}
\section{This should not appear at all}
\subsection{This should be on left even}
\subsubsection{This should be on odd left}

\lipsum[1-8]



\end{document}

The only drawback : it seems that I cannot use \textsc on \leftmark in order to have a small caps chapter name. If anyone knows how to deal with this, I would really appreciate !

1
  • This will occasionally fail, if the page breaking algorithm pushes a [sub]subsection to the next page, after it had already been used to set the corresponding macros. That's the reason marks were invented. Either use an extra mark with the extramarks package, or use the marks for subsection//subsubsection and put the chapter title in a macro. Jan 15, 2021 at 23:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .