I'm trying to add a table of contents to a template which I found on Sharelatex.com, but upon adding \tableofcontents, I obtain the error "! LaTeX Error: There's no line here to end."

Anyone has a clue as to what went wrong? Thanks in advance!


%linkcolor=blue,urlcolor=blue,citecolor=blue,% PDF VIEW
linkcolor=black,urlcolor=black,citecolor=black,% PRINT

\fontseries{b}\fontsize{80}{100}\selectfont}{\fontseries{b}\fontsize{100}{130}\selectfont \textcolor{gray75}\thechapter\hsp}{0pt}{\\ \Huge\bfseries}[]



%   due to variety of titlepage schemes it is probably better to make titlepage manually



Thesis title: may be long or short


Your name


A thesis submitted in partial fulfillment for the\\
degree of Doctor of Philosophy\\[1em]
in the\\[1em]
Faculty Name\\
University Name


Supervisor: Prof. Joe Doe


May 2013






\section{First section}


  • 1
    Welcome to TeX.SX! \titleformat{\chapter}[hang]{\flushright \fontseries{b}\fontsize{80}{100}\selectfont}{\fontseries{b}\fontsize{100}{130}\selectfont \textcolor{gray75}\thechapter\hsp}{0pt}{\\ \Huge\bfseries}[] is causing the error. – Bobyandbob Jun 24 '18 at 9:27

The code to format chapter titles has an error – \\ in the last mandatory argument. Furthermore it is much too complicated. With the tools provided by titlesec, you obtain the correct result (a small difference in the height placement of the chapter number, which can be taken care of with \titlespacing if necessary):


enter image description here

  • Thank you! I am able to run the code to achieve the required format now. :) – Stoner Jun 24 '18 at 10:25

the error means you have mis-used \\ and in this case

{\\ \Huge\bfseries}[]

You can not start a title with a line break as, as the error says, there is no line to end at that point.

  • Thank you for the help! It works fine now :) As @Bernard has solved the main issue of having the required format (chapter number above chapter title), I will mark his as the solution to my question. Really sorry about that.. – Stoner Jun 24 '18 at 10:25
  • 1
    @Stoner don't worry, we both have enough points that 15 here or there will not ruin our day:-) – David Carlisle Jun 24 '18 at 10:26

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.