10

I'm using MiKTeX 2.9 and i'm new to TeX.

Simplified, I have this code:

\newcommand{\aone}{Anna}
\newcommand{\atwo}{Bob}
\newcommand{\topic}{Tpoic}
\subject{University \\ Paper}
\title{ \\topic\\ suubtitle}
\author{\aone\and \atwo}
\begin{document}
\begin{titlepage}
\maketitle
\end{titlepage}
\end{document}

Error:

There's no line here to end. \end (at \end{titlepage})

Log:

l.7 \end{titlepage}

What can be the problem? I have exclude the titlepage, all seems ok. I have no idea.

doncherry
  • 54,637
MemLeak
  • 1,247
  • 3
  • 10
  • 8

2 Answers2

7

The first \\ in \title is the source of the error. Remove it and your code becomes compilable. You should check this out for more insight into how \\ is used.

I understand that you used \\ in \title as an attempt to customise the formatting of the title on the title page. However, it's good practice to do most of the formatting of the title page by either redefining the \maketitle command "manually" (the original definition is usually found in the .cls file) or using the titling package.

Final note: as pointed out by @MartinH in his comment, a titlepage environment is already used in the definition of the \maketitle command ; therefore, there is no need to enclose \maketitle inside another titlepage environment, as you did in your code.

\documentclass{scrartcl}
\newcommand{\aone}{Anna}
\newcommand{\atwo}{Bob}
\newcommand{\topic}{Tpoic}
\subject{University \\ Paper}
\title{topic\\ suubtitle}
\author{\aone\and \atwo}
\begin{document}
\maketitle
\end{document}

enter image description here

jub0bs
  • 58,916
3

This is not directly related to the OPs question, but I had a similar issue while invoking a template file to make the cover page of my document.

If the error is generated on the line that invokes the template file, it probably means that you haven't specified/used all the fields that are specified by the template.

So when you use the file, the undefined parameters would be blank lines and their associated // line termination characters will generate a no line here to end error.

ijuneja
  • 267
  • 2
  • 13
  • 1
    Nice general answer. I'm using the apa6 document style, and had a field blank in the \twoauthors environment. You solved my problem. – FredrikH-R Nov 19 '19 at 20:40
  • @DJHellduck Glad I could help – ijuneja Nov 19 '19 at 20:56
  • 1
    This helped me too. I'm using wiley-article.cls and I was getting this error upon \end{frontmatter} which had nothing to do with the problem. As this solution states, the problem was that I had removed an earlier field (specifically, \corraddress{...}), and putting it back in fixed the problem! – MD004 Jul 26 '22 at 19:03