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.

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}
share|improve this question

1 Answer 1

up vote 2 down vote accepted

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}
share|improve this answer
    
Thank you, worked great! I think I tried to bold some of it, hence the asterisks –  Mike Stumpf Jul 8 '12 at 18:35

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.