TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to make a document that has a large amount of sections which describe tasks. I would like to mark several of the sections as "high priority" with some kind of label, and then build up a table of contents which lists only the sections marked with this label. What is the best way to go about doing this in LaTeX?

share|improve this question
Are you interested in having a "standard ToC" with your "high priority ToC", or is it just the latter? – Werner Oct 18 '11 at 23:31
up vote 5 down vote accepted

The following is a mockup of what you might be after.

It provides a new "List of High Priority Sections" (as defined in \highpriorityname) by using \listofhpsection that prints all the starred sections in your document. New "List of"'s are possible by means of the tocloft package. Each of the starred sections are also included, with number, in the regular \tableofcontents. This is done by a redefinition of the regular \section command using xparse. Additionally, as an in-line marking mechanism, each section of "high priority" will have an asterisk in the form of \star added to the end.

So, in short, \section* commands will be typeset using the traditional section counter/number with an appended \star, but it will also be included in the new list of "high priority" sections. Sections issued using \section will be typeset in the traditional way.

enter image description here

\usepackage[titles]{tocloft}% http://ctan.org/pkg/tocloft
\usepackage{xparse}% http://ctan.org/pkg/xparse
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{letltxmacro}% http://ctan.org/pkg/letltxmacro
\newcommand{\highpriorityname}{List of High Priority Sections}

% ================ FRONTMATTER ================

% ================ REDEFINTION ================
\LetLtxMacro{\oldsection}{\section}% Store old \section macro
\RenewDocumentCommand{\section}{s o m}{%
  \setcounter{hpsection}{\value{section}}% Copy section counter
       {\oldsection[#3]{#3$^\star$}\addcontentsline{hps}{section}{\numberline{\thehpsection} #3}}% starred section \section*{<title>}
       {\oldsection[#2]{#3$^\star$}\addcontentsline{hps}{section}{\numberline{\thehpsection} #2}}% starred section \section*[<ToC>]{<title>}
       {\oldsection{#3}}% unstarred section \section{<title>}
       {\oldsection[#2]{#3}}% unstarred section \section[<ToC>]{<title>}

% ================ MAINMATTER ================
\section{First section} \lipsum[1-2]
\section*{Second section} \lipsum[3-4]
\section{Third section} \lipsum[5-6]
\section*{Fourth section} \lipsum[7-8]
\section*{Fifth section} \lipsum[9-10]
\section{Final section} \lipsum[11-12]

The document structure is such that the sectional redefinition happens between FRONTMATTER and MAINMATTER. Otherwise Contents and List of High Priority Sections would also be numbered sections.

Saving of the original \section command is done using the letltxmacro package, while lipsum provides dummy text.

share|improve this answer
Wow this is excellent. Thank you for the help! – stevejb Oct 19 '11 at 1:40
One remark for the example: when you replace lipsum with blindtext you could use \blinddocument (or \Blinddocument for a large version) to get dummy text including section headings. Disadvantage: you need also babel. – knut Oct 19 '11 at 7:01

Your Answer


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.