I'm using LyX.
The code \end{nolinenumbers} is not working for Table of Contents.
Who can help?
% Quellcode vorschauen
%% LyX 2.0.8.1 created this file. For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[12pt,ngerman]{extarticle}
\usepackage[T1]{fontenc}
\usepackage[utf8x]{inputenc}
\usepackage[a4paper]{geometry}
\geometry{verbose,tmargin=2cm,bmargin=2cm,lmargin=3cm,rmargin=3cm}
\usepackage{color}
\usepackage{babel}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{setspace}
\onehalfspacing
\usepackage[unicode=true,pdfusetitle,
bookmarks=true,bookmarksnumbered=false,bookmarksopen=false,
breaklinks=true,pdfborder={0 0 0},backref=false,colorlinks=true]
{hyperref}
\makeatletter
\@ifundefined{date}{}{\date{}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{etoolbox}\usepackage{lineno}% http://ctan.org/pkg/{etoolbox,lineno}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\setlength{\linenumbersep}{10pt}
\renewcommand{\linenumberfont}{\normalfont\tiny\sffamily\color{gray}}
% \patchcmd{}{}{}{}{}
\patchcmd{\@startsection}{\@ifstar}{\nolinenumbers\@ifstar}{}{}
\patchcmd{\@xsect}{\ignorespaces}{\linenumbers\ignorespaces}{}{}
\linenumbers
\usepackage{xcolor}\usepackage{lscape}
\usepackage{tocstyle}\usepackage{enumitem}\usepackage{mathabx}\usepackage{color}\usepackage{soulutf8}\usepackage{microtype}
\renewcommand{\labelenumi}{\arabic{enumi}.}
\renewcommand{\labelenumii}{\labelenumi\arabic{enumii}.}
\renewcommand{\labelenumiii}{\labelenumii\arabic{enumiii}}
\renewcommand{\labelenumiv}{\alph{enumiv})}
\newtocstyle[KOMAlike][leaders]{chapterwithdot}{
\settocfeature{pagenumberbox}{\makebox[1em][r]}% Platz für Seitenzahl
\settocfeature[-1]{leaders}{\hfill}% keine Punkte bei part
\settocfeature[-1]{pagenumberbox}{\phantom}% keine Seitenzahl bei part
}
\usetocstyle{chapterwithdot}
\renewcommand{\arraystretch}{0.9}
\makeatother
\begin{document}
\newpage{}\begin{nolinenumbers} \tableofcontents{}\end{nolinenumbers}
\clearpage\pagenumbering{arabic}
\setcounter{page}{6}\newpage{}
\section{weijfwoijfewfe}
\subsection{wefijwoijfeoiwfe}
\begin{quote}
\begin{singlespace}
\noindent joiwjeoiwjfoiwjfe\end{singlespace}
\end{quote}
\subsection{wfejwojfeowijfowf}
woiujfeoiwjfeoiwjfeoiwfe
\end{document}


\documentclass{article} \usepackage{lineno} \begin{document} \linenumbers \begin{nolinenumbers} \tableofcontents{} \end{nolinenumbers} \section{aaaa}xxxxx\section{bbbb}zzzz \end{document}– Fran Sep 10 '18 at 23:01\makeatletteras in the code that yourself have posted whenever you add something to the preamble with Document > Settings > Latex Preamble, but that command is in the non visible part of the preamble. To be clear, the preamble that you can edit is only the part between that\makeatletterand the\makeatother(that also is invisible). – Fran Sep 11 '18 at 18:46\usepackage{etoolbox}is between\makeatletterand\makeatother. Moving the package just before of just after that commands solve the problem. Unfortunately, editing the preamble in LyX only allow put packages in that\makeatletter ... \makeatotherzone but you have a solution here. – Fran Sep 11 '18 at 19:01