0

Good evening,

I'd like to ask the following problem that i was unable to solve.

Computing a math text i obtained the following error just because i omitted a point after \end{center}.

this:

\begin{center}

$f(g_{1}) = f(g_{2})$,

\end{center} \\

doesn't compute.

This does:

\begin{center}

$f(g_{1}) = f(g_{2})$, 

\end{center}. \\

I'd like to know how to fix it becaus it is quite ugly to see a nosense point in my Notes,

thank you all, any help would be appreciated

12
  • 3
    What's the purpose of \\ after \end{center} to begin with? Do you know about \[...\], which is actually what you want?
    – egreg
    Jul 15, 2018 at 21:22
  • 2
    I suppose the error you're getting is that there is no line to end. You are misusing \\ It can only be used at the end of a line with content, you can't use it at the start of a line. After the \end{center} you're at the start of a line, so you can't have \\ next. You need something in the line. Anything. It will work with . it will work with a, it will work with elementary, my dear Watson but it won't work nothing.
    – Au101
    Jul 15, 2018 at 21:25
  • 1
    But \\ is for use in tables and things, it's rarely the right thing to be used in the text, @egreg is saying you should have text text text \[ f(g_{1}) = f(g_{2}), \] text text text. He is right
    – Au101
    Jul 15, 2018 at 21:27
  • 1
    @jacopoburelli no no! Never apologise! You did nothing wrong, you did the right thing by asking. It's never too early to stop someone from misusing \\, you could have built up a really bad habit. Now you know =)
    – Au101
    Jul 15, 2018 at 21:34
  • 1
    Not to contradict what @Au101 says, but you would had done an even better thing if you had sistematically studied an introductory guide to LaTeX. Trying to learn it by asking one thing at a time makes for a very painful learning…
    – GuM
    Jul 15, 2018 at 21:40

1 Answer 1

2

The test document

\documentclass[a4paper]{article}

\begin{document}

Some text to fill a couple of lines before some displayed 
equation that is centered on a line by itself
\begin{center}
$f(g_{1})=f(g_{2})$
\end{center} \\
and some text following the display.

\end{document}

stops with the error

! LaTeX Error: There's no line here to end.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.10 a
      nd some text following the display.

that should be self-explaining: there is no line to end after \end{center}. If you go past the error by hitting return, the document is produced:

enter image description here

The same would be obtained by omitting \\.

On the other hand, this is not the preferred method for displaying equations:

\documentclass[a4paper]{article}
\usepackage{amsmath}

\begin{document}

Some text to fill a couple of lines before some displayed
equation that is centered on a line by itself
\begin{equation*}
f(g_{1})=f(g_{2}) 
\end{equation*} 
and some text following the display.

\end{document}

enter image description here

Instead of \begin{equation*}...\end{equation*} you can use \[...\] (but the former is more convenient if you later decide to number your equation and just removing * is sufficient).

There are some subtle differences in the output, but the main one is that no page break can happen before the display. Remember not to leave a blank line before the display itself.

And remember that \\ is not the method of choice to end paragraphs, for which a blank line should be used.

Please, make sure to read an introductory guide to LaTeX: see Where do I start LaTeX programming?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .