2

I am using a template to write up a proposal. The only issue is when I try to have a table of Contents, it comes up numbered with a zero.

\documentclass{proposal}
\usepackage{epsfig}
\usepackage{fontspec}
\setsansfont{Roboto Condensed}
\usepackage{xcolor,lipsum}
\usepackage{titlesec}
\titleformat{name=\section}[block]
  {\sffamily\large}
  {}
  {0pt}
  {\colorsection}
\titlespacing*{\section}{0pt}{\baselineskip}{\baselineskip}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}

\pagestyle{fancy}
\fancyhf{}

\newcommand{\colorsection}[1]{%
  \colorbox{blue!20}{\parbox{\dimexpr\textwidth-2\fboxsep}{\thesection\ #1}}}


\begin{document}
\begin{titlepage}
    \begin{center}
        \vspace*{1cm}

    \Huge
    \textbf{Research Proposal}

    \vspace{1cm}
    \LARGE
    Project: ?

    \vspace{2.5cm}

    \textbf{Bla bla }

    \vspace{6cm}

    James Bond

    \vspace{0.8cm}

    \Large  A research initiative in collaboration with the .... \\

\end{center}

\end{titlepage}

\newpage

\tableofcontents



\newpage


\section{Preliminary title}

Text ....

\section{Scientific Interest}

More text.

\section{Main Research Question(s)}

More text.  Cite an example \cite[]{sample_ref}

\section{Originality}

\section{Research Methodology}

\section{Viability}

\section{Practical Relevance}

\section{Work Plan for Three Years}
\subsection{First Year}
\subsection{Second Year}
\subsection{Third Year}
\section{Education of the PhD Candidate}
\bibliography{•}


\newpage
\end{document}
2
  • 1
    Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – Johannes_B Apr 21 '14 at 11:24
  • Your titleformat calls colorsection in which the numbering is defined. – Johannes_B Apr 21 '14 at 11:32
3

The problem is that \colorsection always typesets the value for the counter; one way to prevent this is to use two \titleformats one for the numbered sections and another one with the numberless option to typeset the title for unnumbered sections; the decision is made using a conditional; something along these lines:

\documentclass{article}
\usepackage{xcolor}
\usepackage{titlesec}

\newif\ifnumbered
\titleformat{name=\section}[block]
  {\sffamily\large\numberedtrue}
  {}
  {0pt}
  {\colorsection}
\titleformat{name=\section,numberless}[block]
  {\sffamily\large\numberedfalse}
  {}
  {0pt}
  {\colorsection}
\titlespacing*{\section}{0pt}{\baselineskip}{\baselineskip}

\newcommand{\colorsection}[1]{%
  \colorbox{blue!20}{\parbox{\dimexpr\textwidth-2\fboxsep}{\ifnumbered\thesection\ \relax\fi#1}}}

\begin{document}

\tableofcontents
\section{Test numbered section}
\section*{Test unnumbered section}
\section{Another test numbered section}

\end{document}

enter image description here

With the current definition of \colorsection, the presence/absence of descendants in the title might produce inconsistent heights for the color boxes; adding \struts might prevent this:

\newcommand{\colorsection}[1]{%
  \colorbox{blue!20}{\parbox{\dimexpr\textwidth-2\fboxsep}{\ifnumbered\thesection\ \relax\fi\strut#1\strut}}}

I suppressed from my example code all information from the original question that was not relevant to the issued at hand and changed to the article document class, since I don't have proposal; the solution, however, should work with the original settings.

0

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.