add tag
निरंजन
Consider the following MWE. I want to print chapter names and section names there. Is it possible to do it without the labels? I tried `\chaptermark` and `\sectionmark`, but they don't seem to work. Is there any other possible way to do it?

```
\documentclass{memoir}
\usepackage{fancyhdr}
\usepackage{lipsum}
\pagestyle{fancy}
\lhead{<current chapter name>}
\rhead{<current section name>}

\begin{document}
\chapter{abcd}
\lipsum[1-1]
\section{efgh}
\lipsum
\chapter{pqrs}
\lipsum[1-1]
\section{wxyz}
\lipsum
\end{document}
```
Top Answer
samcarter
You don't need the `fancyhdr` package, memoir provides its own mechanism for headings:

```
\documentclass{memoir}
\usepackage{lipsum}

\makepagestyle{headings}
\makeevenhead{headings}{\rightmark}{}{\leftmark}
\makeoddhead{headings}{\rightmark}{}{\leftmark}

\begin{document}
\chapter{abcd}
\lipsum[1-1]
\section{efgh}
\lipsum
\chapter{pqrs}
\lipsum[1-1]
\section{wxyz}
\lipsum
\end{document}
```

![Screen Shot 2020-11-29 at 15.09.00.png](/image?hash=0dfb6c0ea11d8acde400d465c6efe9b005363d981f86d378462d876f39613a5c)

(although memoir is two sided by default, so I would suggest to switch the positions for even and odd pages)
Answer #2
marmot
You can use `\sectionmark` and `\chaptermark` to redefine `\rhead` and `\lhead` to contain, say, the title of the section or chapter, respectively.
```
\documentclass{memoir}
\usepackage{fancyhdr}
\usepackage{lipsum}
\pagestyle{fancy}
\renewcommand\chaptermark[1]{\lhead{#1}}
\renewcommand\sectionmark[1]{\rhead{#1}}
\begin{document}
\chapter{abcd}
\lipsum[1-1]
\section{efgh}
\lipsum
\chapter{pqrs}
\lipsum[1-1]
\section{wxyz}
\lipsum
\end{document}
```
![ani.gif](/image?hash=fc2a6f8a94458a473793e31630e6c30e1fde4d1d035a01894ce8a32b6ce7d0ce)

Here is an improved version with a lot of help from @samcarter. It is essentially copied from the top of p. 19 of the `fancyhdr` manual.
```
\documentclass{memoir}
\usepackage{fancyhdr}
\usepackage{lipsum}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{#1}}
\begin{document}
\chapter{pqrs}
\lipsum

\vspace{10\baselineskip}
aaaa
\section{wxyz}
\lipsum
\chapter{abcd}
\lipsum[1-1]
\section{efgh}
\lipsum
\chapter{pqrs}
\lipsum[1-1]
\section{wxyz}
\lipsum
\end{document}    
```
![ani.gif](/image?hash=29346f81e6a64f5d235ee554e5e4f638d4725a11bb72fb79417acdd1ac0a8093)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.