Generalbackground color?

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
suluclac
Posts: 8
Joined: Sat Jan 24, 2009 7:00 am

background color?

Post by suluclac »

I would like to have some background color applied to the following. I've tried \colorbox with no success. Been googling and looking for solution in docs, but no luck yet.
Thanks!
\begin{center}
\textbf{Sign Conventions for Mirrors}
\end{center}
\begin{itemize}
\item Both \textbf{R} and \textbf{f} are + if the center of curvature for the \textbf{R} is in front of the mirror.
\item Both \textbf{R} and \textbf{f} are - if the center of curvature for the \textbf{R} is in back of the mirror.
\end{itemize}

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

marco_d
Posts: 57
Joined: Tue Jan 20, 2009 7:49 pm

background color?

Post by marco_d »

Hello,

in the environent colorbox you can not use linebreaks. So you must use a parbox or a minipage. Here an example where I produce my own colorbox:

Code: Select all

\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{xcolor}
\usepackage{calc}
\usepackage{blindtext}
\newsavebox{\MYRAM}
\newenvironment{mycolorbox}{\par\noindent\begin{lrbox}{\MYRAM}\begin{minipage}{\textwidth-2\fboxsep}}
{\end{minipage}\end{lrbox}\colorbox{yellow}{\color{black}\usebox{\MYRAM}}\par}
\begin{document}
\blindtext
\begin{mycolorbox}
	\begin{center}
	\textbf{Sign Conventions for Mirrors}
	\end{center}
	\begin{itemize}
	\item Both \textbf{R} and \textbf{f} are + if the center of curvature for the \textbf{R} is in front of the mirror.
	\item Both \textbf{R} and \textbf{f} are - if the center of curvature for the \textbf{R} is in back of the mirror.
	\end{itemize}
\end{mycolorbox}

\blindtext

\end{document}
regards
Marco
i am German. I can not use difficult words. :-)
suluclac
Posts: 8
Joined: Sat Jan 24, 2009 7:00 am

Re: background color?

Post by suluclac »

Thanks Marco!
I'll give this a shot. Seems so complicated for something apparently simple ...
Post Reply