如何用不同的颜色书写章节和示例,例如用蓝色书写标题
\documentclass[20pt,a4paper]{extarticle}
\usepackage[a4paper,margin=6mm]{geometry}
\usepackage{amsmath}
\usepackage{hyperref}
\title{\LaTeX\ Mathematics Examples}
\begin{document}
\maketitle
%\tableofcontents
\section{Delimiters}
See how the delimiters are of reasonable size in these examples
\begin{displaymath}
\left(a+b\right)\left[1-\frac{b}{a+b}\right]=a\,,
\end{displaymath}
\begin{displaymath}
\sqrt{|xy|}\leq\left|\frac{x+y}{2}\right|,
\end{displaymath}
even when there is no matching delimiter
\begin{displaymath}
\int_a^bu\frac{d^2v}{dx^2}\,dx
=\left.u\frac{dv}{dx}\right|_a^b
-\int_a^b\frac{du}{dx}\frac{dv}{dx}\,dx.
\end{displaymath}
\section{Spacing}
Differentials often need a bit of help with their spacing as in
\begin{displaymath}
\iint xy^2\,dx\,dy
=\frac{1}{6}x^2y^3,
\end{displaymath}
whereas vector problems often lead to statements such as
\begin{displaymath}
u=\frac{-y}{x^2+y^2}\,,\quad
v=\frac{x}{x^2+y^2}\,,\quad\text{and}\quad
w=0\,.
\end{displaymath}
\section{Theorems et al.}
\newtheorem{theorem}{Theorem}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{definition}[theorem]{Definition}
\begin{definition}[right-angled triangles] \label{def:tri}
A \emph{right-angled triangle} is a triangle whose sides of length~\(a\), \(b\) and~\(c\), in some permutation of order, satisfies \(a^2+b^2=c^2\).
\end{definition}
\begin{lemma}
The triangle with sides of length~\(3\), \(4\) and~\(5\) is right-angled.
\end{lemma}
This lemma follows from the Definition~\ref{def:tri} as \(3^2+4^2=9+16=25=5^2\).
\begin{theorem}[Pythagorean triplets] \label{thm:py}
Triangles with sides of length \(a=p^2-q^2\), \(b=2pq\) and \(c=p^2+q^2\) are right-angled triangles.
\end{theorem}
Prove this Theorem~\ref{thm:py} by the algebra \(a^2+b^2 =(p^2-q^2)^2+(2pq)^2
=p^4-2p^2q^2+q^4+4p^2q^2
=p^4+2p^2q^2+q^4
=(p^2+q^2)^2 =c^2\).
\end{document}
答案1
对于章节标题,您可以使用titlesec
并执行
\usepackage{titlesec}
\titleformat*{\section}{\color{magenta}}
\titleformat*{\subsection}{\color{Brown}}
要使用Brown
颜色,您必须将dvipsnames
选项传递给xcolor
包。
对于定理标题等,你可以这样做
\newtheorem{theorem}{\color{blue}Theorem}
\newtheorem{corollary}[theorem]{\color{blue}Corollary}
\newtheorem{lemma}[theorem]{\color{blue}Lemma}
\newtheorem{definition}[theorem]{\color{blue}Definition}
对于定理等,可能有更好的方法,但我不知道。
代码:
\documentclass[20pt,a4paper]{extarticle}
\usepackage[a4paper,margin=6mm]{geometry}
\usepackage{amsmath}
\usepackage[dvipsnames]{xcolor} %% dvipsnames has Brown colour
\usepackage{hyperref}
\usepackage{titlesec}
\titleformat*{\section}{\color{magenta}}
\titleformat*{\subsection}{\color{Brown}}
\title{\LaTeX\ Mathematics Examples}
\begin{document}
\maketitle
%\tableofcontents
\section{Delimiters}
\subsection{Some subsection}
See how the delimiters are of reasonable size in these examples
\begin{displaymath}
\left(a+b\right)\left[1-\frac{b}{a+b}\right]=a\,,
\end{displaymath}
\begin{displaymath}
\sqrt{|xy|}\leq\left|\frac{x+y}{2}\right|,
\end{displaymath}
even when there is no matching delimiter
\begin{displaymath}
\int_a^bu\frac{d^2v}{dx^2}\,dx
=\left.u\frac{dv}{dx}\right|_a^b
-\int_a^b\frac{du}{dx}\frac{dv}{dx}\,dx.
\end{displaymath}
\section{Spacing}
Differentials often need a bit of help with their spacing as in
\begin{displaymath}
\iint xy^2\,dx\,dy
=\frac{1}{6}x^2y^3,
\end{displaymath}
whereas vector problems often lead to statements such as
\begin{displaymath}
u=\frac{-y}{x^2+y^2}\,,\quad
v=\frac{x}{x^2+y^2}\,,\quad\text{and}\quad
w=0\,.
\end{displaymath}
\section{Theorems et al.}
\newtheorem{theorem}{\color{blue}Theorem}
\newtheorem{corollary}[theorem]{\color{blue}Corollary}
\newtheorem{lemma}[theorem]{\color{blue}Lemma}
\newtheorem{definition}[theorem]{\color{blue}Definition}
\begin{definition}[right-angled triangles] \label{def:tri}
A \emph{right-angled triangle} is a triangle whose sides of length~\(a\), \(b\) and~\(c\), in some permutation of order, satisfies \(a^2+b^2=c^2\).
\end{definition}
\begin{lemma}
The triangle with sides of length~\(3\), \(4\) and~\(5\) is right-angled.
\end{lemma}
This lemma follows from the Definition~\ref{def:tri} as \(3^2+4^2=9+16=25=5^2\).
\begin{theorem}[Pythagorean triplets] \label{thm:py}
Triangles with sides of length \(a=p^2-q^2\), \(b=2pq\) and \(c=p^2+q^2\) are right-angled triangles.
\end{theorem}
Prove this Theorem~\ref{thm:py} by the algebra \(a^2+b^2 =(p^2-q^2)^2+(2pq)^2
=p^4-2p^2q^2+q^4+4p^2q^2
=p^4+2p^2q^2+q^4
=(p^2+q^2)^2 =c^2\).
\end{document}