latex - 逐字着色环境?

标签 latex

这是 Pragmatic Bookshelf 书中的屏幕截图。

http://img13.imageshack.us/img13/3168/screenshot20100717at123.png

看起来像带有着色的逐字环境,但我不确定。

如图所示,如何将颜色逐字用于环境?

使用逐行方法将是一个解决方案,但我希望有更好的方法。

{\color{红色}\begin{逐字}
1号线
2号线
\end{逐字}}
\color{蓝色}{\begin{逐字}
3号线
4号线
\end{逐字}}

最佳答案

一个使用fancyvbr包的例子

\documentclass[a4paper,10pt]{scrartcl}
\usepackage{color}
\usepackage[utf8]{inputenc}
\usepackage{fancyvrb}
\usepackage[usenames,dvipsnames]{xcolor}

\fvset{frame=single,framesep=1mm,fontfamily=courier,fontsize=\scriptsize,numbers=left,framerule=.3mm,numbersep=1mm,commandchars=\\\{\}}

\begin{document}
   \begin{Verbatim}[label={My orange command sample output}]
# \textcolor{Orange}{My orange command}
My black output
that it can be
many lines long
but this specific \textbf{\textcolor{OliveGreen}{word}}
and the following 2
\textbf{\textcolor{red}{lines are important so they}}
\textbf{\textcolor{red}{need to be highlighted and bold}}
   \end{Verbatim}
\end{document}

Sample output of this code

关于latex - 逐字着色环境?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3272903/

相关文章:

matlab - "pdfLatex has stopped working"Matlab调用时提示

latex - R markdown:如何创建包含图像和文本的表格,这些表格应被编织为PDF?

haskell 阴谋 : Generate latex haddock documentation

python - 如何将文本保存在可在 svg 文件中编辑的 python 图中?

latex - LaTeX中矩阵的行和列标签

documentation - 控制 Doxygen 的 LaTeX 输出以制作 PDF 文档

java - 将源代码转换为 LaTeX

latex - 在 LaTeX TOC 中添加包含的 PDF

latex - 是否可以使用 Latex 源文件执行 'unity build'?

java - 将 Java 字符串数组转换为 LaTeX 表