TeX - LaTeX Asked by robinfaha on August 26, 2020
Is there a way of creating a clickable Table of Contents without using any of the ‘Section’ tags?
This code should be multiple times (creating the elements for the Table of Contents):
begin{center}
phantom{.}
vfill
textsc{textbf{huge Foo}}
vfill
end{center}
I know that it might be easier to use section for this but I want the elements to look like this.
You could use one of the packages mentioned in the FAQ answer https://www.texfaq.org/FAQ-secthead. But it is usually easy to redefine sectioning with the built-in @startsection
.
usepackage{hyperref}
setcounter{secnumdepth}{0}
makeatletter
renewcommandsection{@startsection
{section}{1}{0pt}{-12pt plus -1fill}{12pt plus 1fill}%
{hugescshapebfseriescentering}}
makeatother
I forget what documentation explains @startsection
-- clsguide didn't have it, but you could find it in ltsect.dtx.
Edit, based on comments: The first vfill
should not be discarded at a page break, and the regular section
command should be retained for other types of sections, like the ToC heading. So using a random name instead of "section"
usepackage{hyperref}
setcounter{secnumdepth}{0}
makeatletter
newcommandblob{@startsection
{section}{1}{0pt}{-1pt}{12pt plus 1fill}%
{hugescshapebfseriescentering mbox{}*[fill]}}
makeatother
I retained the name "section" so the ToC entries are formatted the same was as regular section
entries.
[I am still uneasy about the huge flexibility of vfill
and wonder if the part
command is closer to what appearance is desired.]
If section
or some other command using @startsection
is out of the question, then make sure your code contains phantomsection
followed by addcontentsline{toc}{section}{<the title>}
. In the original question, it would be
begin{center}
phantom{.}
vfill
phantomsectionaddcontentsline{toc}{section}{Foo}%
textsc{textbf{huge Foo}}
vfill
end{center}
You will have to use a font family that provides bold small-caps.
Correct answer by Donald Arseneau on August 26, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP