Texmaker \color or \textcolor: no line to end error

I'm new to LaTeX and I don't get where my error is. I'm running on Windows under Texmaker. I only recieve this message : "! LaTeX Error: There's no line here to end."

\documentclass[12pt,a4paper]{article}
\usepackage[top=1cm,bottom=1cm,left=1cm,right=1cm]{geometry}
\usepackage{calc,multido,ifthen,bm}
\usepackage{graphics}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{stmaryrd}
\usepackage{setspace}
\usepackage{dsfont}
\usepackage{enumitem}
\usepackage{natbib}
\usepackage{mathtools, amssymb,amsthm}
\usepackage{xcolor}
\title{Sujet 4}
\begin{document}
\section {Exercice 4 :} Soit $P(x) = x^3 - x + 1$.
\\
txt
\\
\textcolor{blue} {On sait que $\alpha$, $\beta$, $\overline{\beta}$ sont les 3 racines du polynômes P. Donc P peut s'ecrire sous forme scindée :
$$P(x)=(x-\alpha)(x-\beta)(x-\overline{\beta})$$
$P(x)=(x^2-\beta x-\alpha x+\alpha \beta)(x-\overline{\beta})$ en développant
$$P(x)=x^3-\beta x^2 - \alpha x^2 +\alpha \beta x -\overline{\beta} x^2 +\beta \overline{\beta} x + \alpha \overline{\beta} x - \alpha \beta \overline{\beta}$$
Par identification, on obtient notamment :
$-\alpha \beta \overline{\beta} = 1 \lvert \alpha \beta \overline{\beta} \rvert = 1 \lvert \alpha \rvert \lvert \beta \rvert \lvert \overline{\beta} \rvert = 1 \lvert \alpha \rvert \lvert \beta \rvert^2 = 1 \lvert \beta \rvert=\frac{1}{\lvert \alpha \rvert}$
or $\alpha <-1$ donc $\lvert \alpha \rvert>1$
donc $\lvert \beta \rvert<1$}
\end{document}

There, I've done what you have said. I tried to run it but I had the same error in the same line.

Thank you for your help !

• (i) in preamble remove all double loaded packages, (ii) instead of $$...$$ use $...$, (iii) merge both code sniped into one (small) document that we can test it. welcome to tex.se! – Zarko Oct 17 '17 at 8:30

let me elaborate my comment (as supplement to samcarter answer): \textcolor{<color>}{.....} doesn't work over more paragraphs (as is your case). instead you should rather use switch \color{<color>} and after end of colored part of document switch back with \color{black}:

\documentclass[12pt,a4paper]{article}
\usepackage[top=1cm,bottom=1cm,left=1cm,right=1cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{natbib}
\usepackage[french]{babel}
\usepackage{calc,multido,ifthen,bm}
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{stmaryrd}
\usepackage{setspace}
\usepackage{dsfont}
\usepackage{enumitem}
\usepackage{mathtools, amssymb, amsthm}
\usepackage{xcolor}
\title{Sujet 4}

\begin{document}
\section {Exercice 4 :} Soit $P(x) = x^3 - x + 1$.
\\
txt
\\
\color{blue}
On sait que $\alpha$, $\beta$, $\overline{\beta}$ sont les 3 racines du polynômes P. Donc P peut s'ecrire sous forme scindée :
$P(x)=(x-\alpha)(x-\beta)(x-\overline{\beta})$
$P(x)=(x^2-\beta x-\alpha x+\alpha \beta)(x-\overline{\beta})$ en développant
$P(x)=x^3-\beta x^2 - \alpha x^2 +\alpha \beta x -\overline{\beta} x^2 +\beta \overline{\beta} x + \alpha \overline{\beta} x - \alpha \beta \overline{\beta}$
Par identification, on obtient notamment :
\begin{align*}
-\alpha \beta \overline{\beta}
& = 1  \\
\lvert \alpha \beta \overline{\beta} \rvert
& = 1\\
\lvert \alpha \rvert \lvert \beta \rvert \lvert \overline{\beta} \rvert
& = 1\\
\lvert \alpha \rvert \lvert \beta \rvert^2
& = 1\\
\lvert \beta \rvert
& =\frac{1}{\lvert \alpha \rvert}
\end{align*}
or $\alpha <-1$ donc $\lvert \alpha \rvert>1$
donc $\lvert \beta \rvert<1$

\color{black}
some text
\end{document}

by the way, Textmaker have nothing with your problem. it is only editor for latex.

• Thank you Zarko ! What does " & = 1 \\" stand for ? – Sin Oct 17 '17 at 9:10
• & is anchor to which equations are aligned. – Zarko Oct 17 '17 at 9:14

The error message you got was caused by the misuse of \\ to denote linebreaks, leave an empty line instead, see Best choice between using \\ or leaving space after each paragraph to end the paragraph

• same for graphicx, you don't need to load graphics then
• $$...$$ should not be used, please use $...$ instead, see Why is $...$ preferable to $$...$$?
• natbib has to be loaded before babel (there should have been a warning to tell you this)
• while \textcolor{blue}{...} works in this case, my personal preference would be to use \color{blue} for larger portions or the document and switch back to black afterwards (\color{blue} .... \color{black}). This is just my personal taste.

\documentclass[12pt,a4paper]{article}

\usepackage[top=1cm,bottom=1cm,left=1cm,right=1cm]{geometry}
\usepackage{calc,multido,ifthen,
%color,
bm}
%\usepackage{graphics}
%\usepackage[french]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{stmaryrd}
\usepackage{setspace}
\usepackage{dsfont}
\usepackage{enumitem}
%\usepackage[utf8]{inputenc}
%\usepackage[T1]{fontenc}

\usepackage{natbib}% before babel!
\usepackage[french]{babel}

\usepackage{graphicx}
\usepackage{mathtools, amssymb,amsthm}
\usepackage{xcolor}
\title{Sujet 4}
\begin{document}
\section {Exercice 4 :}
Soit $P(x) = x^3 - x + 1$.
%\\

\begin{enumerate}[label=(\arabic*)]
\item   Montrer que P admet une unique racine reelle que l'on notera $\alpha$. Verifier que $\alpha < -1$.
\item Montrer que P admet deux autres racines $\beta$ et $\gamma$ verifiant $\beta = \bar{\gamma}$.
\item Montrer que $\vert \beta \vert < 1$.
\item On pose pour tout $n \in \mathbb{N}$ : $u_n = \alpha^n + \beta^n + \gamma^n$. Calculer $u_0$, $u_1$, $u_2$.
\item Montrer que $\forall n \in \mathbb{N}$,$u_{n+3} - u_{n+1} + u_n = 0$.
\item Montrer que $\forall n \in \mathbb{N}$,$u_n \in \mathbb{Z}$.
\item Determiner $\lim_{n \to +\infty} = \vert \alpha\vert^n$.
\item Determiner (si elle existe) $\lim_{n \to +\infty} = \sin( \pi\alpha^n)$.
\end{enumerate}
%\\

\color{blue} On sait que $\alpha$, $\beta$, $\overline{\beta}$ sont les 3 racines du polynomes P. Donc P peut s'ecrire sous forme scindee :
$P(x)=(x-\alpha)(x-\beta)(x-\overline{\beta})$
$P(x)=(x^2-\beta x-\alpha x+\alpha \beta)(x-\overline{\beta})$ en développant
$P(x)=x^3-\beta x^2 - \alpha x^2 +\alpha \beta x -\overline{\beta} x^2 +\beta \overline{\beta} x + \alpha \overline{\beta} x - \alpha \beta \overline{\beta}$
Par identification, on obtient notamment :
$-\alpha \beta \overline{\beta} = 1$
$\lvert \alpha \beta \overline{\beta} \rvert = 1$
$\lvert \alpha \rvert \lvert \beta \rvert \lvert \overline{\beta} \rvert = 1$
$\lvert \alpha \rvert \lvert \beta \rvert^2 = 1$
$\lvert \beta \rvert=\frac{1}{\lvert \alpha \rvert}$
or $\alpha <-1$ donc $\lvert \alpha \rvert>1$
donc $\lvert \beta \rvert<1$
\color{black}

\end{document}
• Thank you !! Just, why do we need to put "\usepackage{natbib}" before babel ? – Sin Oct 17 '17 at 8:48
• @Sin Because the package tells you to do so :) – samcarter_is_at_topanswers.xyz Oct 17 '17 at 8:49
• Fair enought =P Thank you very much. I'll be more careful nest time =) – Sin Oct 17 '17 at 8:51

You don't need to switch the color back if you enclose the whole expression in two curly brackets:

{{\color{blue} blue text }}

will print "blue text" in blue, then pop back to the original color.