Please, somebody tell me. I know its cheating, but I need this

NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
Code: Select all
\documentclass{report}
\usepackage{xcolor}
\begin{document}
text text text \colorbox{red}{text} text text
\end{document}
Code: Select all
\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{babel}
\usepackage[svgnames]{xcolor}
\newcommand{\highlight}[3][black]{{\fboxsep0.5pt\colorbox{#2}{\color{#1} #3}}}
\begin{document}
A sentence with \highlight[white]{blue!50}{some highlighted text} in the middle.
Another sentence with \highlight{green!50}{highlighted text} in another color for text and box.
\end{document}
localghost wrote:Define a command with an optional argument for the text color and a mandatory one for the color of the surrounding box...
Code: Select all
...
\newcommand{\highlight}[3][black]{{\fboxsep0.5pt\colorbox{#2}{\color{#1} #3}}}
...
Of course you are right. Just a matter of false expression. I only referred to the arguments regarding the colors and forgot the argument for the actual contents. Thanks for the hint preventing confusion.gmedina wrote:Didn't you mean with two mandatory arguments? (the box color and its contents).
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p