1

I would like to modify the answer that I got in this thread here such that I have the subsection numbers in the TOC but not in the text. I do not completely understand the workings of the code I was given.

Thanks

\documentclass[12pt, a4paper]{article}

**\makeatletter
\let\latexl@section\l@section
\def\l@section#1#2{\begingroup\let\numberline\@gobble\latexl@section{#1}{#2}\endgroup}
\def\@seccntformat#1{\ifcsname #1format\endcsname\else\csname the#1\endcsname\quad\fi}
\def\sectionformat{}

\makeatother**

\usepackage{hyperref}

\begin{document}
\tableofcontents
\newpage
\section{Part I}
\subsection{abc}
\subsection{def}
\end{document}

1 Answer 1

2

You have to add \def\subsectionformat{} to your example (besides removing the error-causing asterisks).

\documentclass[12pt, a4paper]{article}

\makeatletter
\let\latexl@section\l@section
\def\l@section#1#2{\begingroup\let\numberline\@gobble\latexl@section{#1}{#2}\endgroup}
\def\@seccntformat#1{\ifcsname #1format\endcsname\else\csname the#1\endcsname\quad\fi}
\def\sectionformat{}
\def\subsectionformat{}

\makeatother

\usepackage{hyperref}

\begin{document}
\tableofcontents
\newpage
\section{Part I}
\subsection{abc}
\subsection{def}
\end{document}
1
  • Thank you, worked great! I think I tried to bold some of it, hence the asterisks Jul 8, 2012 at 18:35

You must log in to answer this question.

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