I am trying to apply the answer to this question in Overleaf. I want to number my lines but I don't want the chapter/section titles to be numbered. I'm running into errors when applying the answer. Here is my preamble from Overleaf, this is before trying to adjust the line numbering section in the preamble to stop numbering the titles.

I'm including the majority of my preamble because I almost always forget relevant parts when submitting questions to this forum. I'm also fairly new to Latex.

% header
\fancyhead[LO,LE]{Running Title}
\fancyhead[RO,RE]{Chapter \thechapter}
% footer
% formatting for tables
\usepackage{multirow, makecell}
% front matter
% table of contents
% http://mirrors.ibiblio.org/CTAN/macros/latex/contrib/tocloft/tocloft.pdf
\renewcommand{\contentsname}{\hfill\bfseries\LARGE \MakeUppercase{Table of Contents}\hfill}   
% this is to make a command to make certain sections not appear in the TOC
% list of figures
\renewcommand{\listfigurename}{\hspace*{\fill}\bfseries\LARGE \MakeUppercase{List of Figures}}
% list of tables
\renewcommand{\listtablename}{\hspace*{\fill}\bfseries\LARGE \MakeUppercase{List of Tables}}
%\titleformat{\chapter}[display]{\filcenter\normalfont\LARGE\bfseries}{Chapter         \thechapter}{1em}{\LARGE}
\titleformat{\chapter}[display]{\filcenter\normalfont\LARGE\bfseries}{\chaptertitlename\@ \thechapter}{1em}{\LARGE}

\usepackage[mathscr]{euscript}% use for script letters
\DeclareMathOperator*{\argmax}{arg\,max}% use for argmax
% other material in the preamble

\usepackage[pagewise]{lineno}% Enable numbering of text and display math
\linenumbers\relax % Commence numbering lines

    \chapter{This is the first chapter}
        \section{This is the first section of the first chapter}

I have the lines for initiating the line numbering at the very end of my preamble. This compiles fine, but I don't want the chapter/section titles to be numbered.

The accepted answer in the question I mentioned suggests including the following in the preamble for the line numbering.

\usepackage{etoolbox,lineno}% http://ctan.org/pkg/{etoolbox,lineno}
% \patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}

Doing so gave the following errors in Overleaf...

Option clash package for etoolbox and Missing \begin{document}

It was then recommended that I adjust the first line to be


which just prevented the latex file from compiling at all.

There may be something else from my preamble conflicting with the etoolbox package. Hopefully I can get help with these errors.


The solution for that question is specifically for when titlesec nor hyperref is used, but your preamble does load titlesec.

It should be enough to add \nolinenumbers to your existing \titleformat for the chapter and sectional headings:

  {\chaptertitlename\@ \thechapter}{1em}{\LARGE}
...similarly for \subsection, \subsubsection...
  • This works, thanks. I will be adding hyperref later, will this cause problems?
    – WnGatRC456
    Sep 30 '20 at 14:44

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.