0

From here, I have the fakesection, like this

\newcommand{\fakesection}[1]{%
  \par\refstepcounter{section}% Increase section counter
  \sectionmark{#1}% Add section mark (header)
  \addcontentsline{toc}{section}{\protect\numberline{\thesection}#1}% Add section to ToC
  % Add more content here, if needed.
}

which servers the purpose of not having the section tile.

MWE

\documentclass[a4paper,12pt]{article}


\usepackage{hyperref}

\newcommand{\fakesection}[1]{%
  \par\refstepcounter{section}% Increase section counter
  %\sectionmark{#1}% Add section mark (header)
  \addcontentsline{toc}{section}{\protect\numberline{\thesection}#1}% Add section to ToC
  % Add more content here, if needed.
}


\begin{document}

\tableofcontents

\part{ Basic }
\fakesection{My section 08}
\fakesection{My section 09}
\fakesection{My section 10}
\fakesection{My section 11}

\part{ Intermediate }
\fakesection{My section 08}
\fakesection{My section 09}
\fakesection{My section 10}
\fakesection{My section 11}

\part{ Advanced }
\fakesection{My section 08}
\fakesection{My section 09}
\fakesection{My section 10}
\fakesection{My section 11}

\end{document}

How can I remove the section counters in the toc too? (keeping the title)

enter image description here That is, the table of contents page should look like this, without the 1,2,3,4,etc...

Thanks.

  • As always on this site please post a full minimal example others can copy and work from. Btw what do you think the \protect\numberline{....}, play with it. – daleif Jul 29 '18 at 16:04

1 Answers1

1

As suggested by @daleif in the comment,

\newcommand{\fakesection}[1]{%
  \par\refstepcounter{section}% Increase section counter
  %\sectionmark{#1}% Add section mark (header)
  \addcontentsline{toc}{section}{ #1}% Add section to ToC
  % Add more content here, if needed.
}

worked like a charm.

  • 1
    Remember to remove the space in from of #1, also, you probably don't need the \refstepcounter – daleif Jul 29 '18 at 16:11
  • @daleif Tried it. I do need it, as I want the hyper link to work in the bookmarks. Removing it would result them all being linked to the first section. So the whole document only has one section. – Chen Stats Yu Jul 29 '18 at 16:17
  • 1
    One word: \phantomsection, provides the necessary anchor – daleif Jul 29 '18 at 16:24