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




Desired output: Something like the following:

enter image description here

  • 2
    After loading xcolor package, it works on texlive. Does it make any difference by loading it in MikTeX? – Alan Xiang Jan 15 at 5:06
  • The same is at MikTeX. – Zarko Jan 15 at 6:26
  • @AlanXiang Your suggestion worked on MikTeX, as well. It also worked with color package. – nam Jan 15 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. – David Carlisle Jan 15 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 at 15:54

To reproduce showed image, try the following:

\usepackage{xcolor} % <---

\colorbox{black}{\color{white}\textit{\LaTeX}} % <---

enter image description here

  • 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 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. – Zarko Jan 15 at 15:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.