2

The new environment

Hi, I want to define a new environment like the figure above. It has two text blocks with different background color. Block 1 has a short numbered title, such as 'Note' or 'Definition'. Block 2 has a specific indent.

I tried several ways. The first is package mdframed. I need two blocks, but the package usually provides one block. All the examples in the manual also have only one block.

The second way is to use tabular environment. But I don't know how to make this a new environment with numbers.

Would anybody please give me an example? Thank you.

3

Something like this? The tcolorbox package can do this using the tcblower code. In order to make full use of the package, an environment with \DeclareTColorbox should be used, for some options and to use an automated \tcblower.

\documentclass{article}

\usepackage[most]{tcolorbox}

\newtcolorbox[auto counter]{mynote}[1][]{
  enhanced,
  sharp corners,
  bicolor,
  colback={white!60!yellow},
  colbacklower={white!20!yellow},
  coltitle={black},
  title={Note},
  detach title,before upper={\tcbtitle~\thetcbcounter~\par},
  before lower={\parindent20pt},
  #1
}



\begin{document}

\begin{mynote}
  Foo
  \tcblower
  Bar
\end{mynote}

\begin{mynote}[colbacklower={white},before lower={\parindent40pt}]
  Foo
  \tcblower
  Bar
\end{mynote}



\end{document}

enter image description here

  • Thank you, Christian. Your answer solved my question. tcolorbox is really a useful package. After reading part of the manual of this package, I learned a lot. With the use of detach title, I can get what exact I want (put the title in the upper box with thetcbcunter). – Changjie GUAN Dec 10 '15 at 21:22
  • @ChangjieGUAN: I would say, tcolorbox is one of the most powerful packages concerning colored boxes etc. I wished I had invented it ;-) If you don't mind you can accept my answer ;-) – user31729 Dec 10 '15 at 21:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.