10

I have a summary of equations which is written in an align environment. I want to make a box around it but don't know how to do this efficiently. Here is a MWE

\documentclass{article}
\usepackage[fleqn]{amsmath}

\setlength\mathindent{1cm}
\linespread{1.3}

\begin{document}

\textbf{\Large Solution.} Here is a summary of what we obtained in class for the case of periodic distribution of eigen-strain
\begin{align*}
&\text{Given the system of PDEs} \\
&C_{ijkl}u_{k,lj} = C_{ijkl} \varepsilon^*_{kl,j} \\
&\text{with a periodic distribution of eigen-strain} \\
&\varepsilon^*_{kl}(\mathbf{x},\boldsymbol{\xi})=\bar{\varepsilon}^*_{kl}(\boldsymbol{\xi})\exp(\mathrm{i}\,\boldsymbol{\xi}\cdot\mathbf{x}) \\
&\text{the general solution can be obtained as} \\
&K_{ik} = C_{ijkl}\xi_l\xi_j \\
&D(\boldsymbol{\xi}) = \epsilon_{mnl} K_{m1} K_{n2} K_{l3} \\
&N_{ij}(\boldsymbol{\xi}) = \frac{1}{2} \epsilon_{ikl}\epsilon_{jmn} K_{km} K_{ln} \\
&u_i(\mathbf{x},\boldsymbol{\xi}) = -\mathrm{i}\,C_{jlmn} \bar{\varepsilon}^*_{mn} \xi_l N_{ij}(\boldsymbol{\xi}) D^{-1}(\boldsymbol{\xi})\exp(\mathrm{i}\,\boldsymbol{\xi}\cdot\mathbf{x}) \\
&\varepsilon_{ij}(\mathbf{x},\boldsymbol{\xi}) = C_{klmn} \bar{\varepsilon}^*_{mn} \xi_l ( \xi_j N_{ik}(\boldsymbol{\xi}) + \xi_i N_{jk}(\boldsymbol{\xi})) D^{-1}(\boldsymbol{\xi})\exp(\mathrm{i}\,\boldsymbol{\xi}\cdot\mathbf{x}) \\
&\sigma_{ij}(\mathbf{x},\boldsymbol{\xi}) = C_{ijkl} ( C_{pqmn} \bar{\varepsilon}^*_{mn} \xi_q \xi_l N_{kp}(\boldsymbol{\xi}) D^{-1}(\boldsymbol{\xi})\exp(\mathrm{i}\,\boldsymbol{\xi}\cdot\mathbf{x})-\varepsilon^*_{kl}(\mathbf{x}))
\end{align*}

\end{document}
8
  • 4
    Packages mdframed, empheq, tcolorbox and perhaps some more provide means for this
    – user31729
    Commented Feb 26, 2017 at 16:23
  • @ChristianHupfer: Thanks. :) You know what, I am really tired of using a special package for each work! :) I wish some day, somebody make an integrated environment for all of this in TeX. :) Commented Feb 26, 2017 at 16:26
  • 3
    Well, but this is the philosophy of TeX etc. -- each one can redefine the way LaTeX (etc.) commands and environments work, so some users like what package or class author A provides, others dislike it and have another idea of design and features... --- there is no GUT -- Grand Unified TeX for anything...
    – user31729
    Commented Feb 26, 2017 at 16:29
  • 2
    @H.R.: Go ahead ;-)
    – user31729
    Commented Feb 26, 2017 at 16:58
  • 1
    use context if you want a all-in-one tex. But imho it doesn't make searching for the suitable code much easier when everything is in one large box. In real life the super-mega-store isn't necessarly better than a bunch of smaller, specialized shops. Commented Feb 26, 2017 at 17:09

3 Answers 3

10

I see you use amsmath, which has a nice \boxed command. The only catch is you should use aligned instead of align* inside it:

\documentclass{article}
\usepackage[fleqn]{amsmath}
\thispagestyle{empty}
\setlength\mathindent{1cm}
\linespread{1.3}

\begin{document}

\textbf{\Large Solution.} Here is a summary of what we obtained in class for the case of periodic distribution of eigen-strain

\boxed{\begin{aligned}
&\text{Given the system of PDEs} \\
&C_{ijkl}u_{k,lj} = C_{ijkl} \varepsilon^*_{kl,j} \\
&\text{with a periodic distribution of eigen-strain} \\
&\varepsilon^*_{kl}(\mathbf{x},\boldsymbol{\xi})=\bar{\varepsilon}^*_{kl}(\boldsymbol{\xi})\exp(\mathrm{i}\,\boldsymbol{\xi}\cdot\mathbf{x}) \\
&\text{the general solution can be obtained as} \\
&K_{ik} = C_{ijkl}\xi_l\xi_j \\
&D(\boldsymbol{\xi}) = \epsilon_{mnl} K_{m1} K_{n2} K_{l3} \\
&N_{ij}(\boldsymbol{\xi}) = \frac{1}{2} \epsilon_{ikl}\epsilon_{jmn} K_{km} K_{ln} \\
&u_i(\mathbf{x},\boldsymbol{\xi}) = -\mathrm{i}\,C_{jlmn} \bar{\varepsilon}^*_{mn} \xi_l N_{ij}(\boldsymbol{\xi}) D^{-1}(\boldsymbol{\xi})\exp(\mathrm{i}\,\boldsymbol{\xi}\cdot\mathbf{x}) \\
&\varepsilon_{ij}(\mathbf{x},\boldsymbol{\xi}) = C_{klmn} \bar{\varepsilon}^*_{mn} \xi_l ( \xi_j N_{ik}(\boldsymbol{\xi}) + \xi_i N_{jk}(\boldsymbol{\xi})) D^{-1}(\boldsymbol{\xi})\exp(\mathrm{i}\,\boldsymbol{\xi}\cdot\mathbf{x}) \\
&\sigma_{ij}(\mathbf{x},\boldsymbol{\xi}) = C_{ijkl} ( C_{pqmn} \bar{\varepsilon}^*_{mn} \xi_q \xi_l N_{kp}(\boldsymbol{\xi}) D^{-1}(\boldsymbol{\xi})\exp(\mathrm{i}\,\boldsymbol{\xi}\cdot\mathbf{x})-\varepsilon^*_{kl}(\mathbf{x}))
\end{aligned}}

\end{document}

enter image description here

5

Here is another solution, which allows for breaking boxed equations across pages. I defined a mathframed environment, derived from framed, and use flalign* to align at the left margin. Using the shortintertext command from mathtools simplifies the code:

\documentclass{article}
\usepackage[fleqn]{mathtools}
\usepackage{framed}
\newenvironment{mathframed}{\framed%
\allowdisplaybreaks
\vspace*{-\abovedisplayskip}\noindent}{%
\vspace*{-\dimexpr\baselineskip+\topsep}\endframed}

\linespread{1.3}

\begin{document}
\vspace*{13cm}
\textbf{\Large Solution.} Here is a summary of what we obtained in class for the case of periodic distribution of eigen-strain
\begin{mathframed}
\begin{flalign*}
\shortintertext{Given the system of PDEs}
   & C_{ijkl}u_{k,lj} = C_{ijkl} \varepsilon^*_{kl,j} & & \\
\shortintertext{with a periodic distribution of eigen-strain}
 &\varepsilon^*_{kl}(\mathbf{x},\boldsymbol{\xi})=\bar{\varepsilon}^*_{kl}(\boldsymbol{\xi})\exp(\mathrm{i}\,\boldsymbol{\xi}\cdot\mathbf{x}) \\
\shortintertext{the general solution can be obtained as}
 & K_{ik} = C_{ijkl}\xi_l\xi_j \\
 & D(\boldsymbol{\xi}) = \epsilon_{mnl} K_{m1} K_{n2} K_{l3} \\
 & N_{ij}(\boldsymbol{\xi}) = \frac{1}{2} \epsilon_{ikl}\epsilon_{jmn} K_{km} K_{ln} \\
 & u_i(\mathbf{x},\boldsymbol{\xi}) = -\mathrm{i}\,C_{jlmn} \bar{\varepsilon}^*_{mn} \xi_l N_{ij}(\boldsymbol{\xi}) D^{-1}(\boldsymbol{\xi})\exp(\mathrm{i}\,\boldsymbol{\xi}\cdot\mathbf{x}) \\
 & \varepsilon_{ij}(\mathbf{x},\boldsymbol{\xi}) = C_{klmn} \bar{\varepsilon}^*_{mn} \xi_l ( \xi_j N_{ik}(\boldsymbol{\xi}) + \xi_i N_{jk}(\boldsymbol{\xi})) D^{-1}(\boldsymbol{\xi})\exp(\mathrm{i}\,\boldsymbol{\xi}\cdot\mathbf{x}) \\
 & \sigma_{ij}(\mathbf{x},\boldsymbol{\xi}) = C_{ijkl} ( C_{pqmn} \bar{\varepsilon}^*_{mn} \xi_q \xi_l N_{kp}(\boldsymbol{\xi}) D^{-1}(\boldsymbol{\xi})\exp(\mathrm{i}\,\boldsymbol{\xi}\cdot\mathbf{x})-\varepsilon^*_{kl}(\mathbf{x}))
\end{flalign*}
\end{mathframed}

\end{document} 

enter image description here

4

You can define your own environment; probably tcolorbox is better for the purpose, but we can do without it for such a simple situation.

This way the syntax is more natural and you can preserve the fleqn setting you chose for the whole document.

\documentclass{article}
\usepackage[fleqn]{amsmath}
\usepackage{bm}% recommended

\newenvironment{boxedmaterial}
  {\begin{flushleft}% this produces some space around
   \hspace*{-\fboxsep}\hspace*{-\fboxrule}%
   \begin{lrbox}{\boxedmaterialbox}\begin{minipage}{\textwidth}}
  {\end{minipage}\end{lrbox}%
   \fbox{\usebox{\boxedmaterialbox}}%
   \hspace*{-\fboxsep}\hspace*{-\fboxrule}\hspace*{0pt}%
   \end{flushleft}}
\newsavebox{\boxedmaterialbox}

\setlength\mathindent{1cm}
\linespread{1.3}

\begin{document}

\textbf{Solution.} Here is a summary of what we obtained in class 
for the case of periodic distribution of eigen-strain
\begin{boxedmaterial}
Given the system of PDEs
\begin{equation*}
C_{ijkl}u_{k,lj} = C_{ijkl} \varepsilon^*_{kl,j}
\end{equation*}
with a periodic distribution of eigen-strain
\begin{equation*}
\varepsilon^*_{kl}(\mathbf{x},\bm{\xi})=
\bar{\varepsilon}^*_{kl}(\bm{\xi})\exp(\mathrm{i}\,\bm{\xi}\cdot\mathbf{x})
\end{equation*}
the general solution can be obtained as
\begin{align*}
K_{ik} &= C_{ijkl}\xi_l\xi_j \\
D(\bm{\xi}) &= \epsilon_{mnl} K_{m1} K_{n2} K_{l3} \\
N_{ij}(\bm{\xi}) &= \frac{1}{2} \epsilon_{ikl}\epsilon_{jmn} K_{km} K_{ln} \\
u_i(\mathbf{x},\bm{\xi}) &= 
  -\mathrm{i}\,C_{jlmn} \bar{\varepsilon}^*_{mn} \xi_l N_{ij}(\bm{\xi})
  D^{-1}(\bm{\xi})\exp(\mathrm{i}\,\bm{\xi}\cdot\mathbf{x}) \\
\varepsilon_{ij}(\mathbf{x},\bm{\xi}) &=
  C_{klmn} \bar{\varepsilon}^*_{mn} \xi_l ( \xi_j N_{ik}(\bm{\xi}) + 
  \xi_i N_{jk}(\bm{\xi})) D^{-1}(\bm{\xi})\exp(\mathrm{i}\,\bm{\xi}\cdot\mathbf{x}) \\
\sigma_{ij}(\mathbf{x},\bm{\xi}) &=
  C_{ijkl} ( C_{pqmn} \bar{\varepsilon}^*_{mn} \xi_q \xi_l N_{kp}(\bm{\xi})
  D^{-1}(\bm{\xi})\exp(\mathrm{i}\,\bm{\xi}\cdot\mathbf{x})-\varepsilon^*_{kl}(\mathbf{x}))
\end{align*}
\end{boxedmaterial}

\end{document}

The bm package with its \bm command is superior to the \boldsymbol feature provided by amsmath.

enter image description here

1
  • Thanks. :) How can I learn to write my own codes like you? :) Commented Feb 26, 2017 at 17:55

You must log in to answer this question.

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