2

For the following set of long equations, how to

1- aesthetically align and line-break them in a single- and two-column modes without crossing the single column dedicated space and

2- separately control the vertical spacing inside both align and aligned in order to enhance the readability since, for instance ,I need \begin{spreadlines}{1em} to only affect align while having another setting for aligned (e.g. \begin{spreadlines}{0.5em} without manually using \\[<spacing>]?

enter image description here

\documentclass{article}
\usepackage{mathtools,multicol,lipsum}
\usepackage[bold-style=TeX]{unicode-math}
\setmathfont[math-style=ISO]{Cambria Math}
\usepackage[showframe]{geometry}
\begin{document}
    \begin{spreadlines}{1em} 
    \begin{align}
    &\frac{1}{\sigma(1-\alpha)} \sum_{j=0}^{k-1} \frac{T^{j+1}-T^j}{\tau_{j+1}} \left(1-\exp\left(-\sigma\tau_{j+1}\right)\right)\cdot\exp\left(-\sigma(k-j-1)\tau_{j+1}\right) = \nabla^2 T^{k}\\
    %
    &\frac{1}{\sigma(1-\alpha)} \begin{bmatrix*}[l] \left(T^k-T^{k-1}\right) \frac{1-\exp\left(-\sigma\tau_k\right)}{\tau_k} \\
    + \sum_{j=0}^{k-2} \left( T^{j+1} - T^j \right) \cdot (1-\exp\left(-\sigma\tau_{j+1}\right)) \cdot \exp \left( - \sigma (k-j-1) \tau_{j+1} \right)\end{bmatrix*} = \nabla^2 T^{k}\\
     %
     & \begin{aligned} &\left(T^k-T^{k-1}\right) \frac{1-\exp\left(-\sigma\tau_k\right)}{\tau_k} - [\sigma(1-\alpha)]\nabla^2 T^{k} \\
     &= - \sum_{j=0}^{k-2} \left( T^{j+1} - T^j \right) \cdot (1-\exp\left(-\sigma\tau_{j+1}\right)) \cdot \exp \left( - \sigma (k-j-1) \tau_{j+1} \right) \end{aligned}\\
     %
     &\begin{aligned} &T^k \frac{1-\exp\left(-\sigma\tau_k\right)}{\tau_k} - [\sigma(1-\alpha)]\nabla^2 T^{k} = \\
     &T^{k-1} \frac{1-\exp\left(-\sigma\tau_k\right)}{\tau_k} - \sum_{j=0}^{k-2} \left( T^{j+1} - T^j \right) \cdot (1-\exp\left(-\sigma\tau_{j+1}\right)) \cdot \exp \left( - \sigma (k-j-1) \tau_{j+1} \right) \end{aligned}
    \end{align}
    \end{spreadlines}

    \newpage

    \begin{multicols}{2}
        the above set of equations is needed to be typeset here again in a two-column mode.
    \end{multicols}
\end{document}
1
  • I've used an interesting system to get two columns, but I don't know how to control the spacing...
    – Someone
    Commented May 1, 2020 at 13:31

2 Answers 2

4

This is still a bit overfull but might give you a start

enter image description here

Main changes:

  • don't use spreadlines, just use \\[\jot] on outer level line breaks and \\ on inner ones.
  • don't use bmatrix for displayed equations (it uses textstyle math for matrices)
  • use multlined (or similar) not align when there is no alignment.
\documentclass{article}
\usepackage{mathtools,multicol,lipsum}
\usepackage[bold-style=TeX]{unicode-math}
\setmathfont[math-style=ISO]{Cambria Math}
\usepackage[showframe]{geometry}
\allowdisplaybreaks
\begin{document}
    \begin{gather}
    \frac{1}{\sigma(1-\alpha)} \sum_{j=0}^{k-1} \frac{T^{j+1}-T^j}{\tau_{j+1}} \left(1-\exp\left(-\sigma\tau_{j+1}\right)\right)\cdot\exp\left(-\sigma(k-j-1)\tau_{j+1}\right) = \nabla^2 T^{k}\\[\jot]
    %
    \frac{1}{\sigma(1-\alpha)} \left[\begin{multlined} \left(T^k-T^{k-1}\right) \frac{1-\exp\left(-\sigma\tau_k\right)}{\tau_k} \\
    + \sum_{j=0}^{k-2} \left( T^{j+1} - T^j \right) \cdot (1-\exp\left(-\sigma\tau_{j+1}\right)) \cdot \exp \left( - \sigma (k-j-1) \tau_{j+1} \right)\end{multlined}\right] = \nabla^2 T^{k}\\[\jot]
     %
   \begin{multlined} \left(T^k-T^{k-1}\right) \frac{1-\exp\left(-\sigma\tau_k\right)}{\tau_k} - [\sigma(1-\alpha)]\nabla^2 T^{k} \\
     = - \sum_{j=0}^{k-2} \left( T^{j+1} - T^j \right) \cdot (1-\exp\left(-\sigma\tau_{j+1}\right)) \cdot \exp \left( - \sigma (k-j-1) \tau_{j+1} \right) \end{multlined}\\[\jot]
     %
     \begin{multlined} T^k \frac{1-\exp\left(-\sigma\tau_k\right)}{\tau_k} - [\sigma(1-\alpha)]\nabla^2 T^{k} = \\
     T^{k-1} \frac{1-\exp\left(-\sigma\tau_k\right)}{\tau_k} - \sum_{j=0}^{k-2} \left( T^{j+1} - T^j \right) \cdot (1-\exp\left(-\sigma\tau_{j+1}\right)) \cdot \exp \left( - \sigma (k-j-1) \tau_{j+1} \right) \end{multlined}
    \end{gather}


    \begin{multicols}{2}
        the above set of equations is needed to be typeset here again in a two-column mode.
    \begin{gather}
   \begin{multlined}
    \frac{1}{\sigma(1-\alpha)} \sum_{j=0}^{k-1} \frac{T^{j+1}-T^j}{\tau_{j+1}} \left(1-\exp\left(-\sigma\tau_{j+1}\right)\right)\cdot\\\exp\left(-\sigma(k-j-1)\tau_{j+1}\right)\\  = \nabla^2 T^{k}
   \end{multlined}\\[\jot]
    %
\begin{multlined}
    \frac{1}{\sigma(1-\alpha)} \bigl[ \left(T^k-T^{k-1}\right) \frac{1-\exp\left(-\sigma\tau_k\right)}{\tau_k} \\
    + \sum_{j=0}^{k-2} \left( T^{j+1} - T^j \right) \cdot (1-\exp\left(-\sigma\tau_{j+1}\right)) \cdot\\
 \exp \left( - \sigma (k-j-1) \tau_{j+1} \right)\bigr]\\ = \nabla^2 T^{k}
\end{multlined}\\[\jot]
     %
   \begin{multlined} \left(T^k-T^{k-1}\right) \frac{1-\exp\left(-\sigma\tau_k\right)}{\tau_k} - [\sigma(1-\alpha)]\nabla^2 T^{k} \\
     = - \sum_{j=0}^{k-2} \left( T^{j+1} - T^j \right) \cdot (1-\exp\left(-\sigma\tau_{j+1}\right)) \cdot\\
 \exp \left( - \sigma (k-j-1) \tau_{j+1} \right) \end{multlined}\\[\jot]
     %
     \begin{multlined} T^k \frac{1-\exp\left(-\sigma\tau_k\right)}{\tau_k} - [\sigma(1-\alpha)]\nabla^2 T^{k} = \\
     T^{k-1} \frac{1-\exp\left(-\sigma\tau_k\right)}{\tau_k}\\ - \sum_{j=0}^{k-2} \left( T^{j+1} - T^j \right) \cdot (1-\exp\left(-\sigma\tau_{j+1}\right)) \cdot\\ \exp \left( - \sigma (k-j-1) \tau_{j+1} \right) \end{multlined}
    \end{gather}

\end{multicols}
\end{document}
3
  • For the set of equations in the single-column mode, I needed to left align them, so I used the align environment. Is there another recommendation?
    – Diaa
    Commented May 1, 2020 at 23:48
  • How to make the second line in multilined left-aligned with the first one? Additionally, what are the other alternatives to multilined in this example? Thanks
    – Diaa
    Commented May 2, 2020 at 10:22
  • @Diaa I would say if you want left aligned equations you should use fleqn as a document option and left align them all, but nothing bad actually happens if you use align and and empty first cell as you did originally. I think if you are splitting a long equation the multilined layout with left aligned first line centred middle and right aligned last line is clearer and distinguishes it from a normal align where you are aligning on &= for semantic reasons not just for space. But there are lots of possibilities.... Commented May 2, 2020 at 11:58
2

A small variation of nice @DavidCarlisle answer (+1):

  • instead of \exp(...) are used e^{-....}
  • in multicolum are used \medmath defined in the nccmath package
\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage[bold-style=TeX]{unicode-math}
\setmathfont[math-style=ISO]{Cambria Math}

\usepackage{nccmath, mathtools}
\makeatletter
\let\origexp\exp
\DeclareRobustCommand{\exp}{\@ifnextchar^{\Exp^{}}{\origexp }}
\def\Exp^#1{\,\mathop{\mathrm{\mathstrut e}\!\!}\nolimits^{#1}\,}
\makeatother
\allowdisplaybreaks
\usepackage{multicol,lipsum}

\begin{document}

    \begin{gather}
\frac{1}{\sigma(1-\alpha)}
    \sum_{j=0}^{k-1}\frac{T^{j+1} - T^j}{\tau_{j+1}}
                    \bigl(1-\exp^{-\sigma\tau_{j+1}}\bigr)
                    \cdot\exp^{(-\sigma(k-j-1)\tau_{j+1})}
    = \nabla^2 T^{k}      \\
%
\frac{1}{\sigma(1-\alpha)}
    \left[
\left(T^k-T^{k-1}\right)
    \frac{1-\exp^{-\sigma\tau_k}}{\tau_k} +
    \displaystyle\sum_{j=0}^{k-2} \bigl( T^{j+1} - T^j \bigr)
     \cdot \bigl(1-\exp^{-\sigma\tau_{j+1}}\bigr)
    \cdot \exp^{-\sigma(k-j-1)\tau_{j+1}}
    \right]
     = \nabla^2 T^{k}  \\
%
\bigl(T^k-T^{k-1}\bigr) \frac{1-\exp^{-\sigma\tau_k}}{\tau_k}
    - \bigl[\sigma(1-\alpha)\bigr]\nabla^2 T^{k}
    = - \sum_{j=0}^{k-2} \bigl( T^{j+1} - T^j \bigr)
    \cdot \bigl(1-\exp^{-\sigma\tau_{j+1}}\bigr)
    \cdot \exp^{- \sigma(k-j-1)\tau_{j+1}} \\
%
    \begin{multlined}[0.75\linewidth]
T^k \frac{1-\exp^{-\sigma\tau_k}}{\tau_k}
    - \bigl[\sigma(1-\alpha)\bigr]\nabla^2 T^{k} = \\[-1ex]
         T^{k-1} \frac{1-\exp^{-\sigma\tau_k}}{\tau_k}
         - \sum_{j=0}^{k-2} \left( T^{j+1} - T^j \right)
         \cdot \bigl(1-\exp^{-\sigma\tau_{j+1}}\bigr)
         \cdot \exp^{- \sigma (k-j-1) \tau_{j+1}}
     \end{multlined}
        \end{gather}
%%%%
\hrule
%%%%
\begin{multicols}{2}
The above set of equations is needed to be typeset here again in a two-column mode.
    \begin{gather}
%\begin{gathered}
\medmath{\begin{multlined}[0.8\linewidth]
\frac{1}{\sigma(1-\alpha)}
    \sum_{j=0}^{k-1}\frac{T^{j+1} - T^j}{\tau_{j+1}}=  \\[-1ex]
        \left(1-\exp^{-\sigma\tau_{j+1}}\right)
        \cdot\exp^{-\sigma(k-j-1)\tau_{j+1}}
        = \nabla^2 T^{k}      
    \end{multlined}}     \\[2ex]
%
\medmath{\begin{multlined}[0.8\linewidth]
\frac{1}{\sigma(1-\alpha)}
    \Biggl[
\bigl(T^k - T^{k-1}\bigr)
    \frac{1-\exp^{-\sigma\tau_k}}{\tau_k} +   \\[-1ex]
        \sum_{j=0}^{k-2} \bigl( T^{j+1} - T^j \bigr)
         \cdot \bigl(1-\exp^{-\sigma\tau_{j+1}}\bigr) \\[-1ex]
        \cdot \exp^{-\sigma(k-j-1)\tau_{j+1}}
    \Biggr]
    = \nabla^2 T^{k}  
    \end{multlined}}     \\[2ex]
%
\medmath{\begin{multlined}[0.8\linewidth]   
\bigl(T^k-T^{k-1}\bigr) \frac{1-\exp^{-\sigma\tau_k}}{\tau_k}
    - \bigl[\sigma(1-\alpha)\bigr]\nabla^2 T^{k} =      \\[-1ex]
        - \sum_{j=0}^{k-2} \bigl( T^{j+1} - T^j \bigr)
        \cdot \bigl(1-\exp^{-\sigma\tau_{j+1}}\bigr)    
        \cdot \exp^{- \sigma(k-j-1)\tau_{j+1}}
    \end{multlined}}     \\[2ex]
%
\medmath{\begin{multlined}[0.8\linewidth]
T^k \frac{1-\exp^{-\sigma\tau_k}}{\tau_k} - \bigl[\sigma(1-\alpha)\bigr]\nabla^2 
    = T^{k-1} \frac{1-\exp^{-\sigma\tau_k}}{\tau_k}     \\[-1ex]
         - \sum_{j=0}^{k-2} \bigl( T^{j+1} - T^j \bigr)
         \cdot \bigl(1-\exp^{-\sigma\tau_{j+1}}\bigr)
         \cdot \exp^{- \sigma (k-j-1) \tau_{j+1}}
    \end{multlined}}
    \end{gather}
\end{multicols}
\end{document}

enter image description here

You must log in to answer this question.

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