TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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 '13 at 19:22
For reference, see \eqnarray vs \align. – Werner Mar 1 '13 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. – barbara beeton Mar 1 '13 at 21:26
up vote 6 down vote accepted

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})
share|improve this answer
+1 for the really wretched example. – barbara beeton Mar 1 '13 at 19:50
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}} – Michal Wolodzko Mar 1 '13 at 20:08
I love your example code, as it so perfectly demonstrates the shortcomings of the eqnarray environment. – Mico Mar 1 '13 at 20:13
@MichalWolodzko try it now with \par before each of the skips – David Carlisle Mar 1 '13 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} – Michal Wolodzko Mar 1 '13 at 21:21

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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