如何定制tcolorbox环境?

2019-09-24 16:15发布

MWE如下: ```tex \documentclass{ctexart} \usepackage{amsmath} \usepackage{tcolorbox} \newtcolorbox{mybo...

MWE如下: ```tex \documentclass{ctexart} \usepackage{amsmath} \usepackage{tcolorbox} \newtcolorbox{mybox}{sidebyside,halign upper = flush center,halign lower=flush center} \begin{document} \begin{mybox} \verb*|(abc)/d | \tcblower $\frac{abc}{d}$ \end{mybox} \end{document} ``` 效果如下 ![](https://wenda.latexstudio.net/data/attach/190924/f1YXZlbG.png) 我想要的效果是,左边默认为`\verb*||`模式,即代码环境,右边默认为数学环境,即只需输入 ```tex \begin{mybox} (abc)/d \tcblower \frac{abc}{d} \end{mybox} ``` 就可得到同样的效果
2条回答
下面有一个例子: ```tex \documentclass{article} \usepackage{listings} \usepackage{tcolorbox} \tcbuselibrary{listings}% \usepackage{xcolor} \lstset{ % General setup for the package language={[LaTeX]TeX}, basicstyle=\small\sffamily, numbers=left, numberstyle=\tiny, frame=tb, tabsize=4, columns=fixed, showstringspaces=false, showtabs=false, keepspaces, commentstyle=\color{red}, keywordstyle=\color{blue} }% \tcbset{listing engine={listings}} \usepackage[english]{babel} \usepackage{blindtext} \begin{document} \section{First Section} \blindtext % Redefine the document environment within a group \begingroup \renewenvironment{document}{}{} \renewcommand\documentclass[2][]{} \begin{tcblisting}{colback=red!5!white,colframe=red!25,left=6mm, listing options={style=tcblatex,numbers=left,numberstyle=\tiny\color{red!75!black}}} \documentclass{article} \begin{document} \section{Test Section} Welcome to \LaTeX. \end{document} \end{tcblisting} \endgroup \section{Second Section} \blindtext \end{document} ``` ![](https://wenda.latexstudio.net/data/attach/190924/A9TgyfUT.png)

一周热门 更多>