[Tex/LaTex] How to format a system of differential equations in latex

amsmathcasesequationsformattingmath-mode

Which is the best way of formatting system of differential equations ? Is there a special package maybe ?
I'm actually using the environment

\begin{cases} ... \end{cases} 

But I'am having trouble to align all the boundary condition to the right ? Do you have any suggestion here a sample of the code

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{physics}

\begin{document}


\begin{equation}
\begin{cases}
\displaystyle
\chi \bigg[ C_{m} \frac{\partial v}{\partial t} + I_{ion}\big( v,\mathbf{w},\mathbf{c} \big) \bigg]  =  \div \big( \mathbf{D_{M}} \div v \big) + I_{app} \qquad & \Omega_{0}^{s} \times \big(0,T\big]\\[20pt] 

\displaystyle
\frac{\partial \mathbf{w}}{\partial t}  = \mathbf{R}(v,\mathbf{w},\mathbf{c} \big)  \qquad & \Omega_{0}^{s} \times \big(0,T\big]  \\[20pt] 

\displaystyle 
\frac{\partial \mathbf{w} }{ \partial t} = \mathbf{S} \big(v,\mathbf{w},\mathbf{c} \big) \qquad & \Omega_{0}^{s} \times \big(0,T\big] \\[20pt]

\displaystyle
\big( \mathbf{D_M} \nabla v ) \cdot  \mathbf{N_S} = 0 \qquad & \partial \Omega_{0}^{s} \times \big(0,T\big] \\[20pt]

\displaystyle
 v = v_{0} \quad \mathbf{w} = \mathbf{w_{0}} \quad  \mathbf{c} = \mathbf{c_{0}} &  \partial  \Omega_{0}^{s}  \times \{ 0 \}  \\[20pt]
\end{cases}
\end{equation}

\end{document}

In the picture the boundary condition are aligned on the left side instead I would like to align them on the right ( as the red line )

enter image description here

Best Answer

You might find some of the environments in mathtools useful for this. In particular, dcases is like cases, but each line is in display mode, and spreadlines changes the line spacing of aligned environments. I also used aligned, from amsmath, to add more alignment points.

I also took the liberty of defining a \vectorsym macro, for readability and so you can change the formatting of all your vectors in one place.

This MWE uses LuaLaTeX, but the body should work fine with your own preamble (You can use isomath for \vectorsym in PDFTeX, should you need to.)

i also declared some of your paired delimiters with a \DeclarePairedDelimiter command, which takes an optional size argument.

\documentclass[10pt,a4paper]{article}
\usepackage[english]{babel}
\usepackage{mathtools}
\usepackage{newcomputermodern}

\newcommand\vectorsym[1]{\symbfit{#1}}
\DeclarePairedDelimiter\closedopen{\lbrack}{\rparen}

\begin{document}

\begin{spreadlines}{2ex}
\begin{equation}
\begin{dcases}
\begin{aligned}
\chi \bigg[ C_{m} \frac{\partial v}{\partial t} + I_{ion}\big( v,\vectorsym{w},\vectorsym{c} \big) \bigg]  &= 
  \nabla \big( \vectorsym{D_{M}} \nabla v \big) + I_{app} \qquad  &\Omega_{0}^{s} &\times \closedopen[\big]{0,T} \\
\frac{\partial \vectorsym{w}}{\partial t}  &=
  \vectorsym{R}(v,\vectorsym{w},\vectorsym{c} \big)  \qquad  &\Omega_{0}^{s} &\times \closedopen[\big]{0,T}  \\
\frac{\partial \vectorsym{w} }{ \partial t} &=
  \vectorsym{S} \big(v,\vectorsym{w},\vectorsym{c} \big) \qquad  &\Omega_{0}^{s} &\times \closedopen[\big]{0,T} \\
\big( \vectorsym{D_M} \nabla v ) \cdot  \vectorsym{N_S} &=
  0 \qquad &\partial \Omega_{0}^{s} &\times \closedopen[\big]{0,T} \\
 v = v_{0} \quad \vectorsym{w} = \vectorsym{w_{0}} \quad  \vectorsym{c} &=
  \vectorsym{c_{0}} &\partial  \Omega_{0}^{s}  &\times \{ 0 \} 
\end{aligned}
\end{dcases}
\end{equation}
\end{spreadlines}

\end{document}

mathtools sample

Also, physics (which I’m not too familiar with) seems to redefine \div to mean \nabla\cdot, but in standard LaTeX, that means ÷. I’m editing now because that tripped me up, and I’d recommend you not use ambiguous code like this.