Text Formattingsimple macro or newcommand for adding comments

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
rawlins02
Posts: 22
Joined: Tue Oct 07, 2008 6:56 pm

simple macro or newcommand for adding comments

Post by rawlins02 »

I'm trying to define a simple new command to add text in bold with a yellow background. Some combination of the below or something similar.

Code: Select all

\newsavebox{\X}
\sbox{\X}{\textbf{\colorbox{yellow}{[framed black text]}}}
\usebox{\X}
or some part of:

Code: Select all

\def\comment{\colorbox{yellow}}{}
\comment{Text in yellow}
Something to enable colleagues new to LaTeX to add comments in bold w/ yellow background easily.
Last edited by cgnieder on Sat Jul 20, 2013 10:32 am, edited 1 time in total.

Recommended reading 2024:

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

NEW: TikZ book now 40% off at Amazon.com for a short time.

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

simple macro or newcommand for adding comments

Post by cgnieder »

You can do

Code: Select all

\documentclass{article}
\usepackage{xcolor}
\newcommand*\comment[1]{\colorbox{yellow}{\textbf{#1}}}
\begin{document}
\comment{bold text with yellow background}
\end{document}
Have you had a look at the packages todonotes, fixme, changes and fixmetodonotes? Maybe one of them does what you need.

Regards
site moderator & package author
rawlins02
Posts: 22
Joined: Tue Oct 07, 2008 6:56 pm

Re: simple macro or newcommand for adding comments

Post by rawlins02 »

I was unaware of those packages. Always amazes me how many things one can do with LaTex. Thanks.
Post Reply