# Two issues regarding line numbers

Here are my codes.

\documentclass[12pt]{article}
\usepackage{amsmath,amsthm,amssymb,mathrsfs,lineno}
\usepackage{tikz}
\newtheorem{theorem}{Theorem}
\linenumbers
\begin{document}
In the mathematical discipline of graph theory the Tutte-
Berge formula is a characterization of the size of a maximum matching in a
graph. It is a generalization of Tutte theorem on perfect matchings, and is
named after W. T. Tutte (who proved Tutte's theorem) and Claude Berge (who
proved its generalization).

{\color{red}
\begin{theorem}
The size of a maximum matching of a graph $G=(V, E)$ equals
$$\frac{1}{2} \min _{U \subseteq V}(|U|-\operatorname{odd}(G-U)+|V|),$$
where odd $(H)$ counts how many of the connected components of the graph $H$
have an odd number of vertices.
\end{theorem}
}
\end{document}


My first question :

• why is there a significant gap in line numbers between 5 and 6 without any markings line numbers?

My second question:

• why are line numbers 5 and 6 also marked in red? I would like them to remain black.

Although I can adjust the position of {\color{red}}, but Theorem 1 in red becomes black. I wish it was red.

\begin{theorem}
{\color{red} The size of a maximum matching of a graph $G=(V, E)$ equals
$$\frac{1}{2} \min _{U \subseteq V}(|U|-\operatorname{odd}(G-U)+|V|),$$
where odd $(H)$ counts how many of the connected components of the graph $H$
have an odd number of vertices.}
\end{theorem}


First of all, $$...$$ is not supported in LaTeX documents and lineno can do nothing about this.

The manual suggests wrapping the display with linenomath*.

\documentclass[12pt]{article}
\usepackage{amsmath,amsthm}
\usepackage{lineno}
\usepackage{xcolor}

\newtheorem{theorem}{Theorem}
\AtBeginEnvironment{theorem}{\color{red!80!green}}
\renewcommand{\linenumberfont}{\normalfont\tiny\sffamily\color{black}}

\linenumbers

\begin{document}

In the mathematical discipline of graph theory the Tutte-
Berge formula is a characterization of the size of a maximum matching in a
graph. It is a generalization of Tutte theorem on perfect matchings, and is
named after W. T. Tutte (who proved Tutte's theorem) and Claude Berge (who
proved its generalization).

\begin{theorem}
The size of a maximum matching of a graph $G=(V, E)$ equals
\begin{linenomath*}
$\frac{1}{2} \min _{U \subseteq V}(|U|-\operatorname{odd}(G-U)+|V|),$
\end{linenomath*}
where $\operatorname{odd}(H)$ counts how many of the connected components of the graph $H$
have an odd number of vertices.
\end{theorem}

\end{document}


This will typeset all theorems in red. Maybe you want to define a redtheorem environment, if only some of your theorems should be in red

\newtheorem{theorem}{Theorem}% normal theorems
\newtheorem{redtheorem}[theorem]{Theorem}% red theorems
\AtBeginEnvironment{redtheorem}{\color{red!80!green}}


Note also that \operatorname{odd} must always be used and odd $(H)$ would give a very disputable output.

• Nice, do you have a solution for the color? I'd like to make both Theorem and their contents appear in red, but I don't want the line numbers to be affected. Sep 22 at 8:39
• @licheng you can ensure the line numbers always have a black font color by adding the line \renewcommand{\linenumberfont}{\normalfont\tiny\sffamily\color{black}} to your preamble. Sep 22 at 8:49
• @licheng I added support for color. Sep 22 at 9:08
• We may need to add \usepackage{etoolbox} Sep 22 at 9:30
• @licheng Only if you have an outdated version of LaTeX. Sep 22 at 9:31