25.6.11

How to color the characters in LaTeX2e logo?


You can use the \textcolor command from the xcolor package to give a color to each character of the logo. Running
texdef -t latex LaTeXe
in a terminal, you can get the implememtation of the LaTeX2e logo:
\mbox {\m@th
  \if b\expandafter \@car \f@series \@nil \boldmath \fi
  \LaTeX \kern .15em2$_{\textstyle \varepsilon }$}
Since the \LaTeXe command is built upon the \LaTeX command which, in its turn, uses the\TeX command (you can use texdef to see their definition), I defined three commands\ClrTeX\ClrLaTeX, and \ClrLaTeXe to assign a color to each character of the three logos:
\documentclass{article}
\usepackage{xcolor}
\makeatletter
\newcommand*\ClrTeX[3]{%
  \textcolor{#1}{T}\kern-.1667em%
  \lower.5ex\hbox{\textcolor{#2}{E}}\kern-.125em\textcolor{#3}{X}\@}
\newcommand*\ClrLaTeX[5]{%
  \textcolor{#1}{L}\kern-.36em%
  {\sbox\z@ T%
     \vbox to\ht\z@{\hbox{\check@mathfonts
    \fontsize\sf@size\z@
    \math@fontsfalse\selectfont
    \textcolor{#2}{A}}%
    \vss}%
  }%
  \kern-.15em%
  \ClrTeX{#3}{#4}{#5}}
\newcommand*\ClrLaTeXe[7]{%
  \mbox{\m@th
    \if b\expandafter\@car\f@series\@nil\boldmath\fi
    \ClrLaTeX{#1}{#2}{#3}{#4}{#5}\kern.15em%
    \textcolor{#6}{2}$_{\textstyle\textcolor{#7}{\varepsilon}}$}}
\makeatother
\begin{document}
\TeX\quad
\ClrTeX{red}{green}{blue}
\LaTeX\quad
\ClrLaTeX{red}{green}{blue}{gray}{magenta}
\LaTeXe\quad
\ClrLaTeXe{red}{green}{blue}{gray}{magenta}{olive}{purple}
\end{document}

No hay comentarios:

Publicar un comentario