Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to create a macro in LaTeX to have the following effect (gray parts) on some text:

enter image description here

I would like to have something like \gray{Hello} which puts brackets and grays the text. Can someone help me?

share|improve this question
5  
With the xcolor package, \textcolor{gray}{Hello}. If you want parens about the gray text, then \textcolor{gray}{(Hello)}. This can be placed in a macro of course. Here is a full MWE: \documentclass{article} \usepackage{xcolor} \def\gray#1{\textcolor{gray}{(#1)}} \begin{document} All writers \gray{will have to} edit their prose, but \gray{the} great. \end{document} –  Steven B. Segletes Jul 15 at 16:39
    
And to put brackets, simply load the xcolor package, and edit @StevenB.Segletes macro as \textcolor{gray}{(Hello)}. You can even put in your preamble \newcommand{\gray}[1]{\textcolor{gray}{(#1)}} and in your document use \gray{Hello}. –  Clément Jul 15 at 16:41
    
@Clément We both had the same idea... I was editing my comment as you posted. –  Steven B. Segletes Jul 15 at 16:42
4  
In any case, I would strongly recommend using a more telling command name than simply \grey; perhaps \newcommand\Edit[1]{\textcolor{grey}{(#1)}}. –  Sean Allred Jul 15 at 17:02
    
The downside of \grey, as suggested by Sean Allred, is that, in case you later decide that the color is red while you could redefine the command, it woul look/feel much worse to see that \gray{hello} gives you red color. –  Manuel Jul 15 at 21:29

1 Answer 1

up vote 4 down vote accepted

Showing three possibilities: The first as you desired, the second with better semantic and the third without an extra macro, as it is not that much to type.

\documentclass{article}
\usepackage{xcolor}
\newcommand{\gray}[1]{\textcolor{gray}{#1}}
\newcommand\Edit[1]{\textcolor{gray}{(#1)}}


\begin{document}
``All writers \gray{(will have to)} edit their prose, but \gray{(the)} great

``All writers \Edit{will have to} edit their prose, but \Edit{the} great

``All writers \textcolor{gray}{(will have to)} edit their prose, but \textcolor{gray}{(the)} great
\end{document}

enter image description here

share|improve this answer
    
Thanks a lot for your time. –  minidiable Jul 18 at 11:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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