1

In the memoir class, is there a way to remove the part page entirely? That is, in the text there is no indication of a new part beginning. However, the part still appears in the ToC, and things like cref can still reference it (which should jump to the first chapter in that part).

I was not able to find a clean way to do this reading the user manual.

Right now I'm using a phantom section, but references like \cref{sec:intro} don't work anymore.

\documentclass[oneside]{memoir}
\usepackage{hyperref}
\usepackage{cleveref}

\begin{document}

%%% This prints a dedicated page for the part (unwanted) %%%
\part{A Real Part} \label{part:1}
\chapter{Chapter I}
\section{Test Section}

A reference to part 1 using a real part: \cref{part:1} 
% this prints "part I"

%%% BAD %%%
\cleardoublepage
\phantomsection 
\stepcounter{part}\label{part:2}
\addcontentsline{toc}{part}{\protect\partnumberline{\thepart}A Fake Part 2}

\chapter{Chatper II}

A reference to part 2 using stepcounter: \cref{part:2} 
% this prints "section 1.1", which is wrong

%%% GOOD %%%
\cleardoublepage
\phantomsection 
\refstepcounter{part}\label{part:3}
\addcontentsline{toc}{part}{\protect\partnumberline{\thepart}A Fake Part 3}

\chapter{Chatper III} \label{chapter:3}

A reference to part 3 using refstepcounter: \cref{part:3} 
% this prints "part III"

A reference to chapter III: \cref{chapter:3} 
% this link jumps to the same position as the previous one


\end{document}
3
  • What do you want \cref{sec:intro} to return?
    – Werner
    Commented Jun 6 at 4:56
  • Welcome! Can you complete your code so we can compile it but it is still minimal? Just enough to work with?
    – cfr
    Commented Jun 6 at 5:36
  • Example code added. I wanted the \cref{sec:intro} to print "part I", just like it would with a real \part{intro} \label{sec:intro}. The only thing I wanted to change was to remove the extra page with part title.
    – rileyx
    Commented Jun 6 at 18:37

1 Answer 1

1

You can get the cross-reference to resolve to something simply by using \refstepcounter rather than \stepcounter and ensuring the \label comes after the counter is stepped. But this does not mean the cross-reference resolves to anything useful. It resolves to 1, which refers to a line in your contents which doesn't obviously refer to anything ...?

\documentclass{memoir}
\usepackage{cleveref}
\begin{document}

\cleardoublepage
\phantomsection 
\refstepcounter{part}\label{sec:intro}
\addcontentsline{toc}{part}{\protect\partnumberline{\thepart}Introduction}
\cref{sec:intro}
\end{document}

You don't say what you mean by 'jump', but if you want hyperlinking, you could use something like this:

\documentclass{memoir}
\usepackage{bookmark}
\usepackage{cleveref}
\begin{document}

\cleardoublepage
\phantomsection 
\refstepcounter{part}\label{part:intro}%
\addcontentsline{toc}{part}{\protect\partnumberline{\thepart}Introduction}%
\chapter{first}\label{ch:first}
\cref{part:intro}\cref{ch:first}
\end{document}

The two cross-references do not point to the same target. Rather, the two targets are created close enough together that the links which point to them point to more-or-less the same place.

This means it is really important you don't introduce anything in between the phantom and \chapter. If you do, the chapter will end up on the page following the phantom instead.

I don't recommend doing it this way. If I wanted something akin to this, I would simply use the chapter's target. If that was inconvenient, I'd create a dummy target in the same place i.e. after the \chapter, but that seems unnecessarily involved.

1
  • thanks, I think the change to refstepcounter was what I was missing.
    – rileyx
    Commented Jun 6 at 18:42

You must log in to answer this question.

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