I wanted TOC not to have section numbers displayed. So instead of using the star version of sections, found that simply adding \setcounter{secnumdepth}{0} does that.
But then I found that once package titlesec was added, links inside the pdf no longer work.
Here is MWE, which generates 10 sections and some subsection. Clicking on links in the PDF does nothing. Once titlesec is removed, all links work fine.
\documentclass[12pt]{article}
\usepackage{hyperref}
\usepackage{titlesec}
\usepackage{lipsum}
\usepackage{luacode}
\begin{luacode*}%this so I do not have to type 10 sections by hand
function generateFewSections(n)
local i
for i = 1, n do
s="\\section{section " .. i .. "}\n \\lipsum[1]\n "
.. "\\subsection{subsection 1}\n \\lipsum[1]\n "
.. "\\subsection{subsection 2}\n \\lipsum[1]\n "
tex.print(s)
end
end
\end{luacode*}
\newcommand\generateFewSections[1]{\directlua{generateFewSections(#1) }}%
\begin{document}
\setcounter{secnumdepth}{0}
\setcounter{tocdepth}{1}
\tableofcontents
\generateFewSections{10}
\end{document}
Compiled on Linux using lualatex C.tex this shows pdf links do not work. i.e. clicking on link does not jump to the section in the pdf.
Removing titlesec links work OK now.
This only happens when adding \setcounter{secnumdepth}{0}. Removing this, then now titlesec does not cause any issue.
If this by design or is there a bug here? Can I use \setcounter{secnumdepth}{0} and also use titlesec?
TL 2025, updated about 2-3 weeks ago.

