Could you help me to create an environment out of this code:

I & = & -\mu\frac{W}{L}\int_{V_{S}}^{V_{D}} Q_{m} \cdot \ud{}V_{ch} \\
v_{g} - \Delta\phi_{i} - v_{ch} + \ln(\frac{q_{int}}{2}) & = & 4 q_{g} + \ln(q_{g}) + \ln\left( 1 + q_{g}\frac{C_{ox}}{C_{Si}} \right) \\
i & \approx & -q_{mD}^2 + q_{mD} - (-q_{mS}^2 + q_{mS})
\[\mathrm{where:} \quad v_{x} = \frac{V_{x}}{U_{T}},\ q_{int} = \frac{e n_{i} t_{Si}}{4 C_{ox} U_{T}},\ q_{x} = \frac{Q_{x}}{4 C_{ox} U_{T}},\ C_{Si} = \frac{\varepsilon_{Si}} {t_{Si}}\]

I have in mind something like:


The eqnarray block must be implementable inside the environment.

  • Welcome to TeX.sx! Please, load the package \usepackage{amsmath}, change {eqnarray} to {align} and remove the 2nd & on each line, i.e. change & = & to & =. It will be much nicer :) Ane related question / possible duplicate: tex.stackexchange.com/questions/20575/…
    – yo'
    Mar 1, 2013 at 19:22
  • 3
    For reference, see \eqnarray vs \align.
    – Werner
    Mar 1, 2013 at 19:24
  • you might want to look at the package mdframed. it's overkill, but it should probably allow you to do what you want. Mar 1, 2013 at 21:26

2 Answers 2


enter image description here

Please always post complete documents defining all commands used (I made up something for \ud.

You need lrbox to save the contents into a box register which you can then put a frame around. As the comments have noted it's usually better to use ams alignments than eqnarray. (Not least as it handles moving the label out of the way of large entries, as shown in the image eqnarray isn't so good at that.)




I & = & -\mu\frac{W}{L}\int_{V_{S}}^{V_{D}} Q_{m} \cdot \ud{}V_{ch} \\
v_{g} - \Delta\phi_{i} - v_{ch} + \ln(\frac{q_{int}}{2}) & = & 4 q_{g} + \ln(q_{g}) + \ln\left( 1 + q_{g}\frac{C_{ox}}{C_{Si}} \right) \\
i & \approx & -q_{mD}^2 + q_{mD} - (-q_{mS}^2 + q_{mS})
  • It's almost perfect, there is just a problem with $\medskip$ command which doesn't seem to produce any result in the environment. \newcommand{\ud}{\mathrm{d}} Mar 1, 2013 at 20:08
  • 3
    I love your example code, as it so perfectly demonstrates the shortcomings of the eqnarray environment.
    – Mico
    Mar 1, 2013 at 20:13
  • @MichalWolodzko try it now with \par before each of the skips Mar 1, 2013 at 20:28
  • No, it still doesn't work: \newcommand{\ud}{\mathrm{d}} \newenvironment{mymathbox} {\par\smallskip\centering\begin{lrbox}{0}% \begin{minipage}[c]{0.8\textwidth}} {\end{minipage}\end{lrbox}% \framebox[0.9\textwidth]{\usebox{0}}% \par\medskip \ignorespacesafterend} Mar 1, 2013 at 21:21
  • well that puts a medskip, perhaps you want more space: test with changing \medskip to \vspace{5cm} to check you get a big space to following text then reduce as desired... This is space after the box so doesn't show unless you add some following text Mar 1, 2013 at 22:16

Have you seen the solution with TiKZ at TeXample?

Here is a minimal working example:



% Define box and box title style
\tikzstyle{mybox} = [draw=red, fill=blue!20, very thick,
    rectangle, rounded corners, inner sep=10pt, inner ysep=20pt]
\tikzstyle{fancytitle} =[fill=red, text=white]

\newcommand{\fancybox}[2][Title of the box]{%
\node [mybox] (box){%
\node[fancytitle, right=10pt] at (box.north west) {#1};
\node[fancytitle, rounded corners] at (box.east) {$\clubsuit$};


\fancybox[MyTitle]{How is that?
I can put equations here as well
   E \Psi &= \hat H \Psi


enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .