Math & ScienceColor Theorem Environments

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
LatexNewbie
Posts: 1
Joined: Wed Nov 17, 2010 10:00 pm

Color Theorem Environments

Post by LatexNewbie »

I am trying to type my lecture notes for my courses, and I would like to create a theorem environment for theorems, examples, solutions, etc. In each environment, I would like for a particular color of text to be used. E.g., I would like to write

Ex. 1: Examine the function $f(x)=\frac{x^2-1}{x-1}$.

by typing something like:

\begin{example}
Examine the function $f(x)=\frac{x^2-1}{x-1}$.
\end{example}

Please help! I have scoured the internet, but I have had no luck! Thank you!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Color Theorem Environments

Post by frabjous »

Here's a solution using the ntheorem and xcolor packages. (The lipsum package is put in there just to produce filler text.) Read especially the ntheorem documentation for more options.

Code: Select all

\documentclass{article}
\usepackage{ntheorem,xcolor}
\usepackage{lipsum}
\theoremstyle{plain}
\theorembodyfont{\color{blue}}
\theoremseparator{:}
\newtheorem{example}{Ex.}
\begin{document}

\lipsum[1]

\begin{example}
Examine the function $f(x)=\frac{x^2-1}{x-1}$.
\end{example}

\lipsum[3]
\end{document}
blue.png
blue.png (21.26 KiB) Viewed 7204 times
Post Reply