![关于行号的两个问题](https://linux22.com/image/469238/%E5%85%B3%E4%BA%8E%E8%A1%8C%E5%8F%B7%E7%9A%84%E4%B8%A4%E4%B8%AA%E9%97%AE%E9%A2%98.png)
这是我的代码。
\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}
我的第一个问题:
- 为什么第 5 行和第 6 行之间存在明显的行号差距,而没有任何行号标记?
我的第二个问题:
- 为什么行号 5 和 6 也标记为红色?我希望它们保持黑色。
虽然我可以调整的位置 {\color{red}}
,但是定理 1红色的变成了黑色。我希望它是红色的。
\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}
答案1
首先,$$...$$
LaTeX 文档不支持它,而且lineno
对此无能为力。
手册建议用 包裹显示屏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}
这将排版全部定理用红色表示。也许你想定义一个redtheorem
环境,如果只有一些定理应该用红色表示
\newtheorem{theorem}{Theorem}% normal theorems
\newtheorem{redtheorem}[theorem]{Theorem}% red theorems
\AtBeginEnvironment{redtheorem}{\color{red!80!green}}
还请注意\operatorname{odd}
必须总是被使用并且odd $(H)$
会产生非常有争议的输出。