# Using color and background color together

I'm trying to use color and background color together. But, for example, the following is not working - showing only a black box. What I may be missing here and how can it be fixed.?

Remark: I'm using MikTeX (with default installation) on my Windows-10

\documentclass{article}
\usepackage{amsmath}
\title{\LaTeX}

\begin{document}
$\colorbox{black}{\color{white}\LaTeX}$

\end{document}


Desired output: Something like the following:

• After loading xcolor package, it works on texlive. Does it make any difference by loading it in MikTeX? Jan 15, 2021 at 5:06
• The same is at MikTeX. Jan 15, 2021 at 6:26
• @AlanXiang Your suggestion worked on MikTeX, as well. It also worked with color package.
– nam
Jan 15, 2021 at 15:05
• your example does not produce a black box, it will give an undefined command error for \colorbox so your question is very misleading. Jan 15, 2021 at 15:39
• @DavidCarlisle When I use color package, following works on my MikTeX installation on Windows-10. Am I not be doing something right here?: \documentclass{article} \usepackage{amsmath} \usepackage{color} \begin{document} $\colorbox{black}{\color{white}\LaTeX}$ \end{document}
– nam
Jan 15, 2021 at 15:54

## 1 Answer

To reproduce showed image, try the following:

\documentclass{article}
\usepackage{xcolor} % <---
%\title{\LaTeX}

\begin{document}
$\colorbox{black}{\color{white}\textit{\LaTeX}} % <---$
\end{document}


• Your suggestion worked on MikTeX (thank you). I thought color package was a part of amsmath package. Obviously, I was wrong. It worked after I loaded color package. And, the same was true when I tried your suggestion of loading xcolor package. I suppose xcolor is an extension of color package.
– nam
Jan 15, 2021 at 15:00
• @nam, you are right. xcolor is is an advanced color upgrade/supersede of the color package. With option table: [table]{xcolor] also contain advanced functionality of the colortbl package. Jan 15, 2021 at 15:34