2

I was trying to customize my header by using \begin{center} ... \end{center}, however it results in the header ruler skipping a line and ending up in text.

How can I make it stay right underneath the header?

If you remove the \begin{center} ... \end{center} from the \makeoddhead command in the minimal example below, you can see where the header ruler is supposed to be.

\documentclass[12pt,a4paper,onecolumn,oneside,final]{memoir}
\usepackage[english]{babel}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{newcent}
\usepackage[utf8x]{inputenc}
\usepackage[marginparwidth=3cm,textwidth=15cm,textheight=23cm,footskip=2cm]{geometry}
\usepackage{etoolbox}
\usepackage{lipsum}

\setheadfoot{1cm}{1.5cm}

\makepagestyle{HDR}
\makepsmarks{HDR}{\nouppercaseheads 
    \createmark{chapter}{left}{nonumber}{}{\space}
    \createmark{section}{right}{nonumber}{}{\space} 
} 
\makeoddhead{HDR}{\begin{center}\small\normalfont\mdseries\textsc{\leftmark}\hskip.3cm\vrule\hskip.3cm\bfseries\rightmark\end{center}}{}{}
\makeheadrule{HDR}{\textwidth}{\normalrulethickness}

\begin{document}

\clearpage
\pagestyle{HDR}
\OnehalfSpacing

\chapter{Chapter title}
\lipsum
\section{Section Title}
\lipsum
\end{document}
2
  • 1
    Drop the center environment. Simply put your definition into the next argument (currently empty) which is used for the center position. Like this: \makeoddhead{HDR}{}{\small\normalfont\mdseries\textsc{\leftmark}\hskip.3cm\vrule\hskip.3cm\bfseries\rightmark}{} May 14, 2015 at 11:14
  • Thank you very much! That's what I get for not taking the time to fully understand the commands I use. :0)
    – Faergen
    May 14, 2015 at 11:17

1 Answer 1

3

The problem is that the center environment adds spacing around itself, which is not wanted inside a header. You can see more details at When should we use \begin{center} instead of \centering?

From texdoc memoir, we can look for the documentation of the \makeoddhead command, which says this:

\makeoddhead{ <style> }{ <left> }{ <center> }{ <right> }

So, for centered header content, use the third argument instead of the second:

\makeoddhead{HDR}{}{\small\normalfont\mdseries\textsc{\leftmark}\hskip.3cm\vrule\hskip.3cm\bfseries\rightmark}{}

enter image description here

1
  • Also, you might want to rethink your code for the header here: things look a little unbalanced on the beginning pages of a chapter, where no \section has yet been issued. May 14, 2015 at 11:29

You must log in to answer this question.

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