我正在尝试输入笔记。我发现许多讲义在不同环境中使用不同的颜色。例如,定理是蓝色,定义是黄色等。谁能告诉我怎么做?
谢谢。
答案1
类似下面的东西,加载etoolbox
和xcolor
包?
请注意,该yellow
材料相当难以注意到——更不用说阅读和理解了。考虑使用其他颜色,例如orange
或magenta
。
\documentclass{article}
\usepackage{amsthm} % or: "\usepackage{ntheorem}"
% Set up some theorem-like environments:
\newtheorem{theorem}{Theorem}
\newtheorem{defn}{Definition}
\newtheorem{exmp}{Example}
\usepackage{xcolor,etoolbox}
\AtBeginEnvironment{theorem}{\begingroup\color{blue}}
\AtEndEnvironment{theorem}{\endgroup}
\AtBeginEnvironment{defn}{\begingroup\color{yellow}}
\AtEndEnvironment{defn}{\endgroup}
\AtBeginEnvironment{exmp}{\begingroup\color{green}}
\AtEndEnvironment{exmp}{\endgroup}
\begin{document}
\begin{theorem}[When] blu blu blu \end{theorem}
\begin{defn}[What] bly bly bly \end{defn}
\begin{exmp}[Why] blg blg blg \end{exmp}
\end{document}