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}

centerenvironment. 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}{}– Paul Gessler May 14 '15 at 11:14