I found an answer. This is achieved with a \phantom{} command that takes the width of a given parameter, i.e. in the example above to insert a phantom minus write:
Code: Select all
\phantom{-}(E_1 - E_2)/\dx
- (E_3 - E_4)/\dy
- \Jsrc
to obtain the desired result:
Code: Select all
(E1 - E2)/dx
- (E3 - E4)/dy
- Jsrc
You may also wish to create a custom shortcut for a \phantom command to enable a faster access to this feature:
Code: Select all
\newcommand{\p}[1]{\phantom{#1}}
\p{-}(E_1 - E_2)/\dx
- (E_3 - E_4)/\dy
- \Jsrc
Full solution example:
Code: Select all
\documentclass[a4paper,10pt]{article}
% enable advanced mathematics support
\usepackage{amsmath}
% enable pmatrix environment
\usepackage{mathtools}
% define custom mathematics commands
\newcommand{\dx}{\partial x}
\newcommand{\dy}{\partial y}
\newcommand{\Jsrc}{J_{src}}
% define \phantom shortcut
\newcommand{\p}[1]{\phantom{#1}}
\begin{document}
\[
\begin{pmatrix*}[l]
\p{-}(E_1 - E_2)/\dx \\
- (E_3 - E_4)/\dy \\
- \Jsrc
\end{pmatrix*}
\]
\end{document}