# Grouping two lines inside align environment to put smth. to the left of them

I have an equation which is alligned at 1st equal sign like this:

\begin{align}
a &= b + c \nonumber\\
d &= e + f \label{eq1}\\    %this is row 1
g &= h + i \nonumber\\      %this is row 2
j &= k + l \nonumber\\
m &= n + o \nonumber
\end{align}


How can i group row 1 and row 2 so i can put something on the left side of them? I ll be more speciffic about this. I have constructed an arrow using TiKz like this:

\begin{tikzpicture}
\path (0,0.80) coordinate(c1)
(-0.32,0.65) coordinate(c2)
(-0.32,0.25) coordinate(c3)
(0.0,0) coordinate(c4)
(-0.32,0.4) coordinate(c5);
\draw [-latex] (c1) .. controls (c2) and (c3) .. (c4);
\draw (c5) node [anchor=east] {\scriptsize \text{\eqref{eq1}}};
\end{tikzpicture}


It looks like this on the paper by itself:

Now i want to moove this element to the left of rows row 1 and row 2. What i am striving to is something like this:

-
Could you please clarify? Are you trying to group two rows of align environment? There are simpler solutions to that! Why do you need to arrow thing, if all you need is grouping them? – kan May 6 '13 at 11:04

You can use the remember picture and overlay TikZ methods to mark points and connect them with a tikzpicture later on.

\documentclass{article}
\usepackage{tikz}
\tikzstyle{math atom}=[inner sep=0pt,outer sep=0pt,baseline=0,anchor=base]
\usepackage{amsmath}
\begin{document}
\begin{align}
\tikz[remember picture,overlay]{\node[math atom] (a) {$a$};}\;
&= b + c \nonumber\\
\tikz[remember picture,overlay]{\node[math atom] (d) {$d$};}\;
&= e + f \label{eq1}\\    %this is row 1
g &= h + i \nonumber\\      %this is row 2
j &= k + l \nonumber\\
m &= n + o \nonumber
\end{align}
\begin{tikzpicture}[remember picture,overlay]
\draw [-latex] (a) .. controls ([xshift=-0.5cm]a) and ([xshift=-0.5cm]d) .. (d)
node [midway,anchor=east] {\scriptsize \text{\eqref{eq1}}};
\end{tikzpicture}
\end{document}


This requires two runs of LaTeX to position the coordinates in the right place, but you need two runs to get the cross-references right anyway.

-
What is a role of this line: \tikzstyle{math atom}=[inner sep=0pt,outer sep=0pt,baseline=0,anchor=base]? – 71GA May 6 '13 at 15:37
Why not tikzmark? – Ryan Reich May 6 '13 at 15:49
@71GA: If you comment out inner sep and outer sep, you'll see that the arrow got "pushed out" to the left. These two keys are used to specify the separation space between the text and the node border (inner sep) and that between the border and the anchors (outer sep, actually I'm not 100% sure about this one). I don't think baseline=0 is necessary, because the default is 0pt anyway. anchor controls the vertical alignment of the node--if you comment it out, you'll see that the letters are shifted down. – Herr K. May 6 '13 at 17:07
I tried this and i love this solution as it is very universal, but it happens sometimes that Berziers cant be drawn and i get blank space. Why is that? Can you explain what does a baseline do? – 71GA May 6 '13 at 17:30
@Ryan: one could use tikzmark. I used a roll-my-own version of tikzmark but didn't like the arrows coming out/going into the southwest corner of the letters. So I decided to make the left-hand side of the equation a node. – Matthew Leingang May 6 '13 at 17:48

You can just put the TikZ picture in the align, but smashing it, so it does not consume vertical space.

\begin{align}
a &= b + c \nonumber\\
d &= e + f \label{eq1}\\    %this is row 1
\smash{%
\begin{tikzpicture}
\path (0,0.80) coordinate(c1)
(-0.32,0.65) coordinate(c2)
(-0.32,0.25) coordinate(c3)
(0.0,0) coordinate(c4)
(-0.32,0.4) coordinate(c5);
\draw [-latex] (c1) .. controls (c2) and (c3) .. (c4);
\draw (c5) node [anchor=east] {\scriptsize \text{\eqref{eq1}}};
\end{tikzpicture}%
}\ %% here is some horizontal space
g &= h + i \nonumber\\      %this is row 2
j &= k + l \nonumber\\
m &= n + o \nonumber
\end{align}%


-
This is a very simple idea. – 71GA May 6 '13 at 15:18
+1 for the idea, but -1 again for using arbitrary numbers in the coordinates. – Ryan Reich May 6 '13 at 15:48
@RyanReich I took the OP's code, with its coordinates. I just pasted it into the align, \smash, be done. But of course a more robust solution with tikzmark is preferable. – mafp May 6 '13 at 16:34
Ah, I see. I hadn't really looked at their code. – Ryan Reich May 6 '13 at 17:19

Do you know tkz-linknodes? It does something similar to what you want, except links are on the right side and squared. It's based on TiKZ and its remember picture, so you need two runs to get the correct result.

Next it's a simple example, although I suggest to look at its manual to see if its worth to try it.

\documentclass[]{article}
\usepackage[utf8]{inputenc}
\usepackage[upright]{fourier}
\begin{document}
\begin{NodesList}
\begin{align}
a &= b + c \nonumber\\
d &= e + f \label{eq1} \AddNode \\    %this is row 1
g &= h + i \nonumber \AddNode \\      %this is row 2
j &= k + l \nonumber\\
m &= n + o \nonumber
\end{align}