0

Is there a robust equation-numbering environment
in which I can:

  • Have as many columns as I would like (default centered, like a matrix).
  • Mark start and end of line(s) I would like numbered.
  • Center the numbering across multiple lines which were group numbered.
  • Use multicolumn / multirow wherever.

Actual MWE:

\documentclass{scrreprt}
\usepackage{amsmath}

\begin{document}

\begin{gather}
\begin{array}{ccccccccccccc}
K_{\ddot{\phi}}
& \cdot 
\begin{bmatrix}
\ddot{\phi}_{x}\\
\ddot{\phi}_{y}\\
\end{bmatrix}
& + &
K_{\dot{\phi}} 
& \cdot 
\begin{bmatrix}
\dot{\phi}_{x}\\
\dot{\phi}_{y}\\
\end{bmatrix}
& + &
K_{\phi}
& \cdot 
\begin{bmatrix}
\phi_{x}\\
\phi_{y}\\
\end{bmatrix}
& = &
K_{v}
& \cdot
\begin{bmatrix}
v_{mtr.l}\\
v_{mtr.r}\\
\end{bmatrix}
%%
\\[+2em]
%%
I
& \cdot
\begin{bmatrix}
\ddot{\phi}_{x}\\
\ddot{\phi}_{y}\\
\end{bmatrix}
& = &
-K_{\ddot{\phi}}^{-1}
\cdot 
K_{\dot{\phi}} 
& \cdot 
\begin{bmatrix}
\dot{\phi}_{x}\\
\dot{\phi}_{y}\\
\end{bmatrix}
& + &
-K_{\ddot{\phi}}^{-1}
\cdot 
K_{\phi}
& \cdot 
\begin{bmatrix}
\phi_{x}\\
\phi_{y}\\
\end{bmatrix}
& + &
K_{\ddot{\phi}}^{-1}
\cdot 
K_{v}
& \cdot
\begin{bmatrix}
v_{mtr.l}\\
v_{mtr.r}\\
\end{bmatrix}
\end{array}
%%
\end{gather}

\end{document}

This MWE does not encapsulate all requested features,
but, for example, I would have liked to have centered all depicted vectors.

Desired Example:

\begin{Equation}
%%
\begin{numbered}
\label{EQN:A}
y & = & m \cdot x
\end{numbered}
%%
\\
%%
y & = & m & \cdot & x
%%
\\
\begin{numbered}
\label{EQN:B}
%%
y & = & M & \cdot & x
%%
\\
%%
Y & = & M & \cdot & X
%%
\end{numbered}
%%
\end{Equation}

(Sorry for the lack of originality in the example.)

Effectively, the Equation environment would allow
the entire list of equations to act as a matrix* or tabular,
and the nested enviroment numbered would encapsulate numbering,
without disrupting the indexing of the matrix.

kando
  • 1,338
  • But the Equation environment remains to be defined? – Bernard Jul 16 '17 at 18:57
  • @Bernard Can you elaborate that? If it's what I think you mean: I used Equation with a capitol E because I assumed that it doesn't exist yet. Just a generic name.. – kando Jul 16 '17 at 19:21
  • please make your examples documents so that people can see the intended output. – David Carlisle Jul 16 '17 at 21:24
  • @DavidCarlisle Alright, the 'actual' example should now be an MWE. The 'desired' example shouldn't compile because it, to my knowledge, does not exist. – kando Jul 16 '17 at 21:57
  • it's really not clear what you want to change, the mwe has two equations and three equation numbers (the third row being blank) but it isn't really clear why you have the nested array environment which is just forcing everything not to be in displaystyle and bad spacing around the + ? I can't guess what parts of the output you want to change – David Carlisle Jul 16 '17 at 22:10
  • @DavidCarlisle I'd like each line to be numbered, but to break all equations into multiple c column components such that the equals signs are vertically aligned, the vectors are vertically aligned, etcetera. Align only allows for two columns, before expecting there are multiple equations on one line and making undesired horizontal spacing adjustments. Array allows for multiple 'c' columns, but I cannot, to my knowledge, have multiple numbered lines within the same array environment. – kando Jul 16 '17 at 22:13
  • @DavidCarlisle So, I'm looking for a hybrid of align and array. On top of that, I'd like improved control over which lines are numbered, which lines are not numbered, and which sets of multiple lines are numbered. – kando Jul 16 '17 at 22:17
  • @kando probably you are looking for alignat but it is hard to guess – David Carlisle Jul 16 '17 at 22:25

1 Answers1

1

array is designed for matrices (like the AMS bmatrix that you are using) it is unsuitable for setting displayed equations as it puts the cells in textstyle and the spacing is incorrect. Also if the array only have one row then the ccc doesn't really centre anything, lll would have the same effect, as the cell is just as wide as its content.

example from the updated question

For the updated example you could use alignat rather than gather but the alignment here, aligning = with + seems very strange and designed to imply a symmetry that is not in the underlying mathematics.

enter image description here

\documentclass{scrreprt}
\usepackage{amsmath}

\begin{document}

\begin{alignat}{7}
K_{\ddot{\phi}}
\cdot 
\begin{bmatrix}
\ddot{\phi}_{x}\\
\ddot{\phi}_{y}\\
\end{bmatrix}
&+
K_{\dot{\phi}} 
&\cdot 
\begin{bmatrix}
\dot{\phi}_{x}\\
\dot{\phi}_{y}\\
\end{bmatrix}
& + 
K_{\phi}
&\cdot 
\begin{bmatrix}
\phi_{x}\\
\phi_{y}\\
\end{bmatrix}
& = 
K_{v}
\cdot
&\begin{bmatrix}
v_{mtr.l}\\
v_{mtr.r}\\
\end{bmatrix}
%%
\\[+2em]
%%
I
\cdot
\begin{bmatrix}
\ddot{\phi}_{x}\\
\ddot{\phi}_{y}\\
\end{bmatrix}
&1= 
-K_{\ddot{\phi}}^{-1}
\cdot 
K_{\dot{\phi}} 
&\cdot 
\begin{bmatrix}
\dot{\phi}_{x}\\
\dot{\phi}_{y}\\
\end{bmatrix}
& + 
-K_{\ddot{\phi}}^{-1}
&\cdot 
K_{\phi}
\cdot 
\begin{bmatrix}
\phi_{x}\\
\phi_{y}\\
\end{bmatrix}
& + 
K_{\ddot{\phi}}^{-1}
\cdot 
K_{v}
&\cdot
\begin{bmatrix}
v_{mtr.l}\\
v_{mtr.r}\\
\end{bmatrix}
%%
\end{alignat}

\end{document}

original example

For a setting such as the example I would use gather that does centre the expressions and set them in display math mode.

enter image description here

\documentclass{scrreprt}
\usepackage{amsmath}

\begin{document}

\begin{gather}
K_{\ddot{\phi}} 
\cdot 
\begin{bmatrix}
\ddot{\phi}_{x}\\
\ddot{\phi}_{y}\\
\end{bmatrix}
 + 
K_{\dot{\phi}} 
\cdot 
\begin{bmatrix}
\dot{\phi}_{x}\\
\dot{\phi}_{y}\\
\end{bmatrix}
 + 
K_{\phi}
\cdot 
\begin{bmatrix}
\phi_{x}\\
\phi_{y}\\
\end{bmatrix}
 = 
K_{v}
\cdot
\begin{bmatrix}
v_{mtr.l}\\
v_{mtr.r}\\
\end{bmatrix}
\\[+1em]
%%
\begin{bmatrix}
\ddot{\phi}_{x}\\
\ddot{\phi}_{y}\\
\end{bmatrix}
 = 
-K_{\ddot{\phi}}^{-1}
\cdot 
K_{\dot{\phi}} 
\cdot 
\begin{bmatrix}
\dot{\phi}_{x}\\
\dot{\phi}_{y}\\
\end{bmatrix}
 + 
-K_{\ddot{\phi}}^{-1}
\cdot 
K_{\phi}
\cdot 
\begin{bmatrix}
\phi_{x}\\
\phi_{y}\\
\end{bmatrix}
 + 
K_{\ddot{\phi}}^{-1}
\cdot 
K_{v}
\cdot
\begin{bmatrix}
v_{mtr.l}\\
v_{mtr.r}\\
\end{bmatrix}
\end{gather}

\end{document}
David Carlisle
  • 757,742
  • I think you misunderstood - I'm looking for independent equations to be aligned with each other, as if in an array. – kando Jul 16 '17 at 22:19
  • 1
    @kando there is no alignment in the example you posted, and no alignment really possible as the terms either side of the = are so diferent – David Carlisle Jul 16 '17 at 22:19
  • hmm, hold on - I'll make a better example. – kando Jul 16 '17 at 22:20
  • alright - MWE updated. now there is one array, which is seen as one equation by gather. but I would like certain lines of the array to be numbered, as each line is an independent equation. – kando Jul 16 '17 at 22:28
  • @kando OK (I suppose I could post an alignat version) although the desired alignment looks very odd! what is the intended meaning of aligning an = with a + ? – David Carlisle Jul 16 '17 at 22:38
  • 1
    @kando answer updated, but I would use gather not aligned here. – David Carlisle Jul 16 '17 at 22:53
  • Sometimes it is helpful to retain the placement of the immutable variables, (usually to form fit those variables and their coefficients to a certain equation template.) – kando Jul 16 '17 at 22:55
  • Is it possible to center align the columns? Is it possible to increase space between columns as array/matrix does? – kando Jul 16 '17 at 22:59
  • 1
    @kando several answers with code for that, eg https://tex.stackexchange.com/questions/102816/centering-equations-within-alignat-command – David Carlisle Jul 16 '17 at 23:02
  • Although your link did not specifically solve my problem, due to your progression of the question, I was able to more specifically ask about it. I reimplemented the question here, with more focus on alignat vs array with the hope that one can be altered to meet my needs. (I performed additional searching based on your suggestions, but still found no method of creating an environment which effectively breaks separate portions of multiple equations into a matrix.) – kando Jul 17 '17 at 03:21