3

Is there a way to add a label / property / anything to a title so that in the contents page it will show up with a symbol / the word NEW / highlighting somewhere, so it's obvious?

A little asterisk to the left of the section number or something?

Essentially i'm writing a library, and documenting it as i go, and distributing it regularly. I'd like to be able to add flags to the titles (or even better a "date added" field, and then have the contents generate the symbols automatically for anything after a provided date) so that people getting the new documentation can quickly see the new additions.

Sure i could have a "new" section at the beginning and put links in there, but i'd quite like to have the new entries added in the contents page.

example:

\documentclass[a4paper]{article}

\usepackage[a4paper, left=15mm, right=15mm, top=25mm, bottom=25mm]{geometry}

\usepackage{color}
\usepackage{graphicx}
\usepackage[usenames,dvipsnames,svgnames,x11names]{xcolor}

\usepackage{hyperref}
\hypersetup{
    colorlinks,
    citecolor=DodgerBlue4,
    filecolor=Firebrick4,
    linkcolor=Cyan4,
    urlcolor=DeepSkyBlue1
}

\title{title}

\begin{document}

\maketitle

\setcounter{tocdepth}{3}
\tableofcontents

\section{sec1}
\subsection{subsec11}
\subsection{subsec12}
\subsection{subsec13} % i want to make this section display some sort of symbol in the contents.
\subsection{subsec14}

\end{document}
  • please add a minimal example of your code we need to know the class packages (related to toc) do you use. – touhami Nov 19 '15 at 13:50
  • @touhami there you go. – will Nov 19 '15 at 13:56
2

A trick is by redefining \numberline command or similar. One add \mtnew befor each new section

\documentclass{article}
\def\mtnew{%
\addtocontents{toc}{%
\let\protect\oldnumberline\protect\numberline%
\def\protect\numberline{%
\global\let\protect\numberline\protect\oldnumberline
\protect\llap{*New* }\protect\oldnumberline}}}


\begin{document}
\tableofcontents
\section{First}
\subsection{Foo}
\mtnew
\subsection{Bar}
\section{Second}
\mtnew
\section{New section}
\section{Last section}
\end{document}

Update Here is a solution that fill your need. A new command \newsec is defined to be used

\newsec[level]{heading}

level is section(default) subsection ....

\documentclass[a4paper]{article}

\usepackage[left=15mm, right=15mm, top=25mm, bottom=25mm]{geometry}

\usepackage{graphicx}
\usepackage[usenames,dvipsnames,svgnames,x11names]{xcolor}

\usepackage{hyperref}
\hypersetup{
    colorlinks,
    citecolor=DodgerBlue4,
    filecolor=Firebrick4,
    linkcolor=Cyan4,
    urlcolor=DeepSkyBlue1
}


\makeatletter
\newcommand{\newsec}[2][section]{%
\def\@seccntformat##1{\protect\llap{\normalfont\normalsize*New* }\csname the#1\endcsname\quad}%
\addtocontents{toc}{%
\let\protect\mtnumberline\protect\numberline%
\def\protect\numberline{%
\hskip-\parindent%
\global\let\protect\numberline\protect\mtnumberline%
\protect\llap{\normalfont\normalsize*New* }%
\hskip\parindent\protect\mtnumberline}}%
\csname #1\endcsname{#2}%
\def\@seccntformat##1{\csname the#1\endcsname\quad}}
\makeatother

\title{title}
\author{me}

\begin{document}
\maketitle

\setcounter{tocdepth}{3}
\tableofcontents

\section{sec1}
\subsection{subsec11}
\subsection{subsec12}
\newsec{sec2}                   % here new section
\subsection{subsec21}
\section{sec3}
\newsec[subsection]{subsec31}   % here new subsection
\subsection{subsec32}
\end{document}

enter image description here

  • nearly works - i don't get it showing in front of the section heading, only in the contents. – will Nov 19 '15 at 14:31
  • you want the (new) symbol even in the body at left of section heading, this is? – touhami Nov 19 '15 at 14:43
  • in your example the symbol shows in the margin next to the section headings. for me it does not. Though just being in the contents is good enough for my purposes. – will Nov 19 '15 at 15:05
  • it's not clear for me where do you want the symbol: at left of the number? after the number at left of the headinf? – touhami Nov 19 '15 at 15:35
  • there are two things. Firstly, i would like to see it next to the section heading, as well as in the contents. It is in both in your example, but for some reason it's not for me. I need to work out why - that is my problem though. Secondly, could you make it sit in the margin, rather than to the left of the item? so that it is always in the same place? – will Nov 19 '15 at 16:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.