我想获得 LaTeX2e 徽标,但每个字符都有不同的颜色。我知道这\LaTeXe
会产生徽标,但我该如何为每个字符赋予颜色?
答案1
您可以使用包\textcolor
中的命令xcolor
为徽标的每个字符赋予颜色。运行
texdef -t latex LaTeXe
在终端中,您可以获得 LaTeX2e 徽标的实现:
\mbox {\m@th
\if b\expandafter \@car \f@series \@nil \boldmath \fi
\LaTeX \kern .15em2$_{\textstyle \varepsilon }$}
由于该\LaTeXe
命令是建立在使用该\LaTeX
命令的基础上的,而该命令又使用该\TeX
命令(您可以使用该命令texdef
查看它们的定义),因此我定义了三个命令\ClrTeX
、\ClrLaTeX
和 ,\ClrLaTeXe
为三个徽标的每个字符分配一种颜色:
\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}
答案2
另一种解决方案是\ClrLaTeXe
根据和的局部补丁来定义\TeX
:\LaTeX
\LaTeXe
\documentclass{article}
\usepackage{etoolbox}
\usepackage{xcolor}
\newrobustcmd*{\ClrLaTeXe}[7]{%
\bgroup%
\def\unskippp{\unskip\unskip\unskip}%
\expandafter\patchcmd\csname LaTeX \endcsname {L} {\textcolor{#1}{L}} {\unskippp}{}%
\expandafter\patchcmd\csname LaTeX \endcsname {A} {\textcolor{#2}{A}} {\unskippp}{}%
\patchcmd\TeX {T} {\textcolor{#3}{T}} {\unskippp}{}%
\patchcmd\TeX {E} {\textcolor{#4}{E}} {\unskippp}{}%
\patchcmd\TeX {X} {\textcolor{#5}{X}} {\unskippp}{}%
\expandafter\patchcmd\csname LaTeXe \endcsname{2} {\textcolor{#6}{2}} {\unskippp}{}%
\expandafter\patchcmd\csname LaTeXe \endcsname{\varepsilon}{\textcolor{#7}{\varepsilon}}{\unskippp}{}%
\LaTeXe%
\egroup%
}
\begin{document}
\noindent
\ClrLaTeXe{magenta}{cyan}{blue}{green}{orange}{red}{brown}
\end{document}
输出结果为: