0

I need to make a layout in which the section headers are colored and appear in the ToC. So far no problem. The next requirement is to skip numbering. My attempt in luaLaTeX:

\documentclass[a4paper,11pt]{article}
\usepackage{hyperref}
\usepackage{titlesec}
\usepackage{xcolor}
\definecolor{coi_gray}{RGB}{136,155,169}
\titleformat*{\section}{\normalsize\bfseries\color{coi_gray}}
\usepackage{lipsum}  

\setcounter{secnumdepth}{0} % <---- https://tex.stackexchange.com/a/30225/48642
\begin{document}
\tableofcontents % prints Table of Contents
\newpage

\section{Introduction}
\lipsum[2-14]
\section{First long text}
\lipsum[8-20]
\section{Second long text}
\lipsum[8-20]

\end{document}

I tried to follow the solutions but now I'm facing that the ToC link incorrectly - either to page 1 or some random page. The other solutions like \addcontentsline suffer the same problem and \renewcommand{\thesection}{} has odd spacing in the section.

Using titlesec from 2016-03-21.

Bernard
  • 271,350
LeO
  • 1,451
  • 2
    couple of remarks: hyperref should be loaded as the last package (very few exceptions – most notable cleveref). Present version of titlesec is 2.13, dated from 2019/10/16. – Bernard Mar 11 '20 at 15:21
  • What is not clear is whether you want sections to be unnumbered in text and in the table of contents, or only in table of contents? – Bernard Mar 11 '20 at 15:26
  • ahaaa... loading the hyperref after the titlesec solves the issue. Thx. I want the unnumbered section in ToC and in the text. – LeO Mar 11 '20 at 15:31
  • Nevertheless, you should update titlesec (and perhaps other packages, if you haven't done it for a long tme). – Bernard Mar 11 '20 at 15:33
  • 1
    @Bernard one of you could formulate this into an answer, so that LeO can mark the question as answered. – Tim Hilt Mar 12 '20 at 15:46

0 Answers0