In a document using the memoir
class, I am trying to draw a vertical line down the whole table between the page number and text.
My requirements (so far only one remains, which is the question):
- Have a Table of contents including Chapters and Sections (OK)
- Have no Chapter or Section Numbers (just the text) (OK)
- Have the page number to the left, the item text to the right (OK)
- Allow a slightly different style between Chapter and Section texts (OK)
- A vertical line between the two <= NOT OK
Basically, I'm trying to emulate the line in this table of contents:
This is what I have with my MWE:
But I have no idea how to create the vertical line in such a way as to be the exact height of the table of contents (which will potentially span more than one page)
My MWE:
\documentclass{memoir}
% Clear Chapter and Section numbers
\renewcommand\chapternumberline[1]{}
\renewcommand\numberline[1]{}
% Prepare a length to indent the lot
\newlength\ToCindent
\setlength\ToCindent{0.3\textwidth}
\makeatletter
% Put pagenumbers and item texts where they should go
\newcommand*{\l@mytocentry}[3]{%
\bigskip
\par%
\noindent\parbox[c]{\ToCindent}{\makebox[\dimexpr\ToCindent-2em][r]{\Large#2}\hfill}%
\parbox[c]{\dimexpr\textwidth-\ToCindent\relax}{#1}%
}
% Create the items (with different styles)
\renewcommand*{\l@chapter}[2]{%
\l@mytocentry{\Huge#1}{#2}{\chaptername}%
}
\renewcommand*{\l@section}[2]{%
\l@mytocentry{\Large#1}{#2}{\sectionname}%
}
\makeatother
\begin{document}
\frontmatter%
\tableofcontents*
\mainmatter%
\chapter{Welcome}
\section{A Section}
\section{Another Section}
\chapter{Hello}
\section{Yet another section}
\section{Yet another section}
\chapter{World}
\section{Yet another section}
\end{document}
enter code here
I've tried:
- Making a table with pages in one column, text in the other and a vertical line between, but I can only get each line, and don't know how to loop through them to put the page number to one side, the text to another - in any case I'm hesitant to try because I'm afraid it would be reinventing the wheel
- Inspired by this question I've gotten this far but have no idea how to do the line...
These questions helped me get this far but I haven't found one that allows this vertical line I need:
- Page number before Chapter title in the Table of Contents with memoir
- ToC showing page number and then the chapter title
Update:
The accepted answer resolved my question. For completeness, here is how I ended up implementing it to ensure the line was centered. (I added a variable to mytocentry
and added the line between my elements)
\newcommand{\vertrule}{$\smash{\rule[-2.3em]{0.2mm}{13mm}}$}
\newcommand*{\l@mytocentry}[3]{%
\bigskip
\par%
\noindent\parbox[c]{\ToCindent}{\makebox[\dimexpr\ToCindent-1em][r]{\Large#2}\hfill}%
\parbox[c]{1em}{\vertrule\hfill}%
\parbox[c]{\dimexpr\textwidth-\ToCindent\relax}{#1}%
}