更改定理环境编号的颜色

更改定理环境编号的颜色

在此处输入图片描述

\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}

相关内容