LaTex下tcolorbox宏包的安装及使用

来源:互联网 发布:linux top命令参数 编辑:程序博客网 时间:2024/06/05 12:03

1. texlive2011安装tcolorbox


1. 在线安装:tlmgr --gui打开texlive manager,菜单tlmgr下:载入缺省的网络仓库,之后update all installed
终端 tlmgr install tcolorbox即可。(比较慢)
2. 手工安装:下载下来tcolorbox的zip包:http://ctan.org/tex-archive/macros/latex/contrib/tcolorbox
按照README中所说的:把  'tcolorbox.sty'  'tcblistings.code.tex'  'tcbtheorems.code.tex'  'tcbdocumenation.code.tex'  'tcbskins.code.tex'这几个文件放到你的local Tex file tree中,我的Texlive是\texlive\2011\texmf-dist\tex\latex\tcolorbox,把其它的文件放在texlive\2011\texmf-dist\doc\latex\tcolorbox中。dos窗口中输入texhash刷新数据库,之后texdoc tcolorbox可以打开其帮助文档说明安装成功

2. tcolorbox使用

使用包括4个方面。

2.1 基本使用

跟beamer下的定理框一样:

\documentclass{article}\usepackage{tcolorbox}\begin{document}\begin{tcolorbox}[colback=blue!5,colframe=blue!75!black,title=My title]  My box with my title.\end{tcolorbox}\begin{tcolorbox}[colback=yellow!5,colframe=yellow!75!black,title=My title]  I can do this also with a title.  \tcblower  Lower part of my box.\end{tcolorbox}\begin{tcolorbox}[colback=yellow!10,colframe=red!75!black,title=Here I am]  I'm invisible until you find me.\end{tcolorbox}\end{document}

环境中使用命令\tcblower表分隔上下部分
其中colback表背景颜色,colframe表边框颜色,title设定标题,colupper, collower分别表上下部分颜色,coltext文本颜色,coltitle标题颜色,还有一些设定边距的选项,可以用texdoc tcolorbox查看帮助。

2.2 listing环境

\tcbuselibrary{listings}来使用listings环境

该环境主要用来用做latex源码与编译结果的对照。
例如:
\begin{tcblisting}{colback=red!5,colframe=red!75!black}This is a \LaTeX\ example which displays the text as source codeand in compiled form.\end{tcblisting}

将会在上部分保持环境中的源码,而在下部分显示对应编译后结果。

还可以对源码部分显示行号:
\begin{tcblisting}{colback=red!5,colframe=red!25,left=6mm,listing options={style=tcblatex,numbers=left,numberstyle=\tiny\color{red!75!black}}}This is a \LaTeX\ example which displays the text as source codeand in compiled form. Additionally, we use line numbers here.\end{tcblisting}


2.3 theorems环境

跟beamer中作用一样用来显示定理定义之类的东西。

2.4 documentation环境

感觉用处不是太大
原创粉丝点击