着色定理环境

着色定理环境

我想更改定理环境,使标题和名称有颜色。我该怎么办?已经检查过执行此操作的方法(例如使用\newtheoremstyle),但效果不佳。我不想使用诸如这样的定理包amsthm,而是坚持使用基本的内置定理结构。

\documentclass[12pt]{article}
\usepackage[b5paper,body={13cm,18cm}]{geometry}
\usepackage{xcolor}  

\begin{document}

\begin{theorem}[Continuous Function]
  Let \(f\) be a function whose derivative exists in every point,
  then \(f\) is a continuous function.
\end{theorem}

\end{document}

我会在其他环境中使用\newtheorem,我希望采用与\begin{theorem}...相同的配色方案\end{theorem}

答案1

https://tex.stackexchange.com/a/17555/4427您将找到定理样式的默认值。您只需根据需要调整最后一个参数即可。

\documentclass{article}
\usepackage{amsthm}
\usepackage{xcolor}

\newtheoremstyle{colorplain}
  {\topsep}   % ABOVESPACE
  {\topsep}   % BELOWSPACE
  {\itshape}  % BODYFONT
  {0pt}       % INDENT (empty value is the same as 0pt)
  {\bfseries} % HEADFONT
  {.}         % HEADPUNCT
  {5pt plus 1pt minus 1pt} % HEADSPACE
  {%
   \thmnumber{\textcolor{red!75}{#1}}%
   \ % space
   \thmname{\textcolor{green!60!red}{#2}}%
   \thmnote{ \textcolor{blue!80!green}{#3}}%
  }

\theoremstyle{colorplain}
\newtheorem{theorem}{Theorem}

\begin{document}

\begin{theorem}
This has no theorem note.
\end{theorem}

\begin{theorem}[Note]
This has a theorem note.
\end{theorem}

\end{document}

在此处输入图片描述

但这肯定很丑。我相信你只是想要整个标题使用一种颜色。

\documentclass{article}
\usepackage{amsthm}
\usepackage{xcolor}

\newtheoremstyle{colorplain}
  {\topsep}   % ABOVESPACE
  {\topsep}   % BELOWSPACE
  {\itshape}  % BODYFONT
  {0pt}       % INDENT (empty value is the same as 0pt)
  {\color{blue!80!green}\bfseries} % HEADFONT
  {.}         % HEADPUNCT
  {5pt plus 1pt minus 1pt} % HEADSPACE
  {}

\theoremstyle{colorplain}
\newtheorem{theorem}{Theorem}

\begin{document}

\begin{theorem}
This has no theorem note.
\end{theorem}

\begin{theorem}[Note]
This has a theorem note.
\end{theorem}

\end{document}

在此处输入图片描述

答案2

尽管同时使用了amsthmthmtools环境,但是像这样吗?

(我还纠正了连续句,并将介词“in”纠正为“at”。)

\documentclass[12pt]{article}
\usepackage[b5paper,body={13cm,18cm}]{geometry}
\usepackage{xcolor}  
\usepackage{amsmath,amsthm}
\usepackage{thmtools}

\declaretheoremstyle[
  headfont={\color{red}\bfseries},
  notefont={\color{blue}},
]{thmstyle}
%
\declaretheorem[name=Theorem, style=thmstyle]{theorem}

\begin{document}

\begin{theorem}[Continuous Function]
  If \(f\) is a function whose derivative exists at every point,
  then \(f\) is a continuous function.
\end{theorem}

\end{document}

颜色定理题头及注释

相关内容