# [OS X TeX] Colored words

Aaron Jackson jackson at msrce.howard.edu
Sun Feb 20 18:45:31 EST 2005

On Feb 20, 2005, at 9:07 AM, Alain Schremmer wrote:

> Aaron Jackson wrote:
>
>> You most likely only need to change the C references to tex, or
>> something similar, in order to use it as is.  Then just tweek until
>> you get what you want...
>
> Awsome! Indeed, all I did was to change C to tex and Hello world to
> file.tex and there it was.
>
> Unfortunately, this does not help me. Here is my situation:
>
> In the process of a step by step instruction, I am refering within my
> own text to pieces of the TeXShop source code that a person already
> has. Using the TeXShop look and feel for these pieces of source code
> would avoid the use of quotes. Here is an example of what I am
> writing:
>
>            Say you want to Boldface the word "text". Select "text", Go
> Window > LaTeX panel > Typeface > Bold. Observe that, in the source,
> "text" is now the argument of "\textbf{ }". Typeset.
>
> Most of this is in Body Text but I would like "text" to be in
> Helvetica, "\textbf" to be in blue Helvetica with the curly braces "{
> }" in green Helvetica, rather than in Body Text between quotes.

OK.  I looked at this again and the following is the best I could do...
Maybe comp.text.tex can give better info.

Aaron

NOTE:  If you replace texcsstyle={\color{blue}} with
texcsstyle=*{\color{blue}} the leading \ of each command is also
considered part of the command, however this is a buggy feature.

\documentclass[11pt]{article}
\usepackage[pdftex]{color}
\usepackage{listings}
\newcommand{\mysyntaxp}[2]{\textcolor{blue}{\textbackslash#1}\textcolor{
green}{\{}\textsf{#2}\textcolor{green}{\}}}
\newcommand{\mysyntax}[1]{\textcolor{blue}{\textbackslash#1}}
%%
%% For computer code listings
%%
\newlength{\xleftmargin}
\settowidth{\xleftmargin}{\textbf{99999}}% width of 5 digits in the
current font.
\newlength{\numbersep}
\settowidth{\numbersep}{\textbf{99}}% width of 2 digits in the current
font.
\usepackage{listings}
\lstset{language={[latex]TeX}, keywordstyle=\color{blue},
identifierstyle=\textsf, texcsstyle={\color{blue}},
showtabs=false, columns=fullflexible, numbers=left, stepnumber=1,
numberstyle=\normalsize, numbersep=\numbersep,
breaklines, moretexcs={numbersep,xleftmargin,
ng}}
\begin{document}

\mysyntaxp{textbf}{test} \\

\mysyntax{itshape} \\

\lstinputlisting{Untitled.tex}

\end{document}

--------------------- Info ---------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
& FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Post: <mailto:MacOSX-TeX at email.esm.psu.edu>