Colour and links
此页面需较新浏览器(支持 SharedArrayBuffer)。请升级 Chrome、Edge、Firefox 或 Safari 至最新版本。
English
Adding colour
- The
xcolorpackage lets you colour text. Load it, then wrap words:
\usepackage{xcolor}
...
\textcolor{red}{This is red} and \textcolor{blue}{this is blue}.
- Built-in names include
red,blue,green,orange,gray, and more.

English
Highlights and your own colours
\colorbox{yellow}{text}puts a highlight behind the words.- You can even mix your own:
\textcolor{red!60}{...}is 60% red (lighter).
English
Clickable links
- The
hyperrefpackage turns cross-references and web addresses into clickable links:
\usepackage{hyperref}
...
Visit \href{https://ctan.org}{CTAN} for packages.
- Load
hyperreflast in your preamble — it likes to have the final word.
English
Common mistakes
\textcolorwithoutxcolor. LaTeX stops with! Undefined control sequence.- A misspelt colour name.
\textcolor{rd}{...}gives! Package xcolor Error: Undefined color 'rd'. - Loading
hyperrefearly. Other packages can then break its links. Load it last in the preamble.
难度 2/5 · 今日首次完成可获 140 金币及少量额外奖励
负载 xcolor, then make the word warning red with \textcolor{red}{warning}. You need both the package and the command.
点击“运行”编译并预览 PDF。
难度 2/5 · 今日首次完成可获 140 金币及少量额外奖励
Make a clickable link. Load hyperref, then turn the word CTAN into a link with \href{https://ctan.org}{CTAN}. Load hyperref last in the preamble.
点击“运行”编译并预览 PDF。
难度 2/5 · 今日首次完成可获 140 金币及少量额外奖励
Highlight the word Note with a yellow background using \colorbox{yellow}{Note}. xcolor is already loaded.
点击“运行”编译并预览 PDF。