LaTex下tcolorbox宏包的安装及使用

本文详细介绍了在texlive2011环境下如何安装tcolorbox宏包,并逐步讲解了其基本使用、listing环境、theorems环境以及documentation环境的配置和应用,为LaTex用户提供丰富的框环境排版方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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 code
and 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 code
and in compiled form. Additionally, we use line numbers here.
\end{tcblisting}


2.3 theorems环境

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

2.4 documentation环境

感觉用处不是太大
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值