Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In the following example, I've hacked the numbering of sections in the memoir class so that I can use "sections" as "chapters". This makes them show up nicely in the table of contents. However, numbering for \label and \ref is off by one. Can this be fixed without massively revising my code?

\documentclass[article, a4paper, 12pt, oneside]{memoir}

\setlrmarginsandblock{23mm}{63mm}{*}
\setulmarginsandblock{23mm}{28mm}{*}
\setheadfoot{\onelineskip}{2\onelineskip}
\setheaderspaces{*}{1mm}{*}
\chapterstyle{plain}
\checkandfixthelayout

\setsecnumformat{\addtocounter{section}{-1} \addtocounter{chapter}{1}}

\renewcommand*\thesection{\arabic{chapter}}

\begin{document}

\tableofcontents

\section{Introduction} \label{beginning}
Beginning.  Just wait til you see the end, that's in Chapter \ref{end}.

\section{Conclusion} \label{end}
End.  Hopefully you read the beginning! (Chapter \ref{beginning})

\end{document}

Numbers appear differently

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

There's no need to play with counters. If you have to "promote" only sections, the following will work:

\documentclass[article, a4paper, 12pt, oneside]{memoir}

\setlrmarginsandblock{23mm}{63mm}{*}
\setulmarginsandblock{23mm}{28mm}{*}
\setheadfoot{\onelineskip}{2\onelineskip}
\setheaderspaces{*}{1mm}{*}
% \chapterstyle{plain} % needed?
\checkandfixthelayout

\renewcommand{\thesection}{\arabic{section}}
\makeatletter
\let\l@section\l@chapter
\makeatother

\begin{document}

\tableofcontents

\section{Introduction} \label{beginning}
Beginning.  Just wait til you see the end, that's in Chapter \ref{end}.

\section{Conclusion} \label{end}
End.  Hopefully you read the beginning! (Chapter \ref{beginning})

\end{document}

If you have to promote also subsections, then

\renewcommand{\thesection}{\arabic{section}}
\renewcommand{\thesubsection}{\thesection.\arabic{subsection}}
\makeatletter
\let\l@subsection\l@section
\let\l@section\l@chapter
\makeatother

The strategy is to use for an entry in the table of contents the setting for the upper level (so we have to work from bottom up). The macro

\l@<sectional unit>

is responsible for typesetting the table of contents entry for that sectional unit.

enter image description here

Of course \tableofcontents* should be used, in order to avoid that the table of contents is listed in itself, which makes little sense anyway.

share|improve this answer
add comment

If you only want to change the formatting for the chapter entries in the ToC, memoir offers you built-in commands to easily do so without redefining counters, nor changing the "natural" meaning of the sectional units:

\documentclass[article, a4paper, 12pt, oneside]{memoir}

\setlrmarginsandblock{23mm}{63mm}{*}
\setulmarginsandblock{23mm}{28mm}{*}
\setheadfoot{\onelineskip}{2\onelineskip}
\setheaderspaces{*}{1mm}{*}
\chapterstyle{plain}
\checkandfixthelayout

\cftsetindents{chapter}{1.5em}{2.3em}
\renewcommand\cftchapterfont{\normalfont}
\renewcommand\cftchapterleader{\cftdotfill{\cftsectiondotsep}}
\renewcommand\cftchapterpagefont{\normalfont}
\renewcommand\cftchapterafterpnum{\par\vskip-10pt}

\begin{document}

\tableofcontents*

\chapter{Introduction} \label{beginning}
Beginning.  Just wait til you see the end, that's in Chapter \ref{end}.

\chapter{Conclusion} \label{end}
End.  Hopefully you read the beginning! (Chapter \ref{beginning})

\end{document}

enter image description here

share|improve this answer
    
Hi Gonzalo: This seems for all intents and purposes a "better" answer than the one from egreg, but I'm going to mark his answer as "accepted", since after trying yours, it seemed I would need to do further configuration to get the TOC to look right, whereas his solution "just works". Despite changing the look of the TOC, it looks good without any tweaking. Also, I don't have to rewrite the \section etc. commands in my document. But thank you for the answer, I'll likely use this next time! –  Joe Corneli Oct 14 '12 at 13:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.