Deducing the equation of the circuit which is composed of batteries in parallel and the external resistor
What you're missing is the sign convention.
You have written the ith current down as simply which flows between the endpoints of the ith battery.Sloppy thinking like this is bound to get you into trouble.



simulate this circuit &ndash; Schematic created using CircuitLab
If we define positive current as that flowing down the page, then we get your textbook's equation.
If we define positive current as that flowing from the positive terminal of each battery (admittedly the more natural way to view it), then we get your equation.
Which is correct? Both are, once you've drawn a diagram or otherwise specified your current convention for each. The textbook's convention has the advantage that it's more self consistent. If you draw a normally styled schematic, then all current arrows point down.
People starting out in this type of analysis often get stressed over the current direction. A common question is 'but what if I choose the wrong direction for the current in this branch when I'm placing my +ve current definition arrow?' The answer is it doesn't matter. When you do the sums, the current will come out with whatever sign is correct for your arrow. If it's negative, then it's flowing the other way to your arrow.
It's for this reason the textbook uses the convention it does. Label the currents consistently, so that you don't have to think when placing the arrows. Consistency means that you're less likely to make an error when creating the Kirchoff loop equations.