![更改定理环境编号的颜色](https://linux22.com/image/346179/%E6%9B%B4%E6%94%B9%E5%AE%9A%E7%90%86%E7%8E%AF%E5%A2%83%E7%BC%96%E5%8F%B7%E7%9A%84%E9%A2%9C%E8%89%B2.png)
\documentclass[a4paper]{article}
\usepackage{amsmath}
\usepackage{ntheorem}
\usepackage{thmtools,xcolor}
\makeatletter
\renewtheoremstyle{plain}{
{\item[\hskip\labelsep \theorem@headerfont ##1\\red ##2\theorem@separator]}
{\item[\hskip\labelsep \theorem@headerfont ##1\\red ##2\\blue(##3)\theorem@separator]}
}
\makeatother
\setlength{\theorempreskipamount}{7mm}
\setlength{\theorempostskipamount}{7mm}
\theoremstyle{plain}
\theorembodyfont{\normalfont}
\theoremheaderfont{\scshape\large}
\newtheorem{ejemplo}{Ejemplo}
\newtheorem{defi}{Definición}
\begin{document}
\chapter{Resol}
\begin{defi}[Polinomio característico]
Si $A$ es una matriz cuadrada de orden $n$, al polinomio
\end{defi}
\end{document}
答案1
使用thmtools
,这相当简单:
\documentclass{article}
\usepackage{amsthm,mathpazo}
\usepackage{thmtools,xcolor}
\usepackage[utf8]{inputenc}
\colorlet{theoremnamecolor}{blue!30!black}
\colorlet{theoremnumbercolor}{red!80!black}
\declaretheoremstyle[
spaceabove = 7mm,
spacebelow = 7mm,
headfont = \color{theoremnamecolor}\normalfont\bfseries,
notefont = \color{theoremnamecolor}\normalfont\mdseries,
notebraces = {(}{)},
headformat = \NAME{} \textcolor{theoremnumbercolor}{\NUMBER}\NOTE,
headpunct = {},
bodyfont = \normalfont\itshape
]{plain}
\theoremstyle{plain}
\newtheorem{defi}{Definición}[section]
\begin{document}
\section{A section}
\begin{defi}[Polinomio característico]
Si $A$ es una matriz cuadrada de orden $n$, al polinomio
\end{defi}
\end{document}