I understand that the similar triangles are the red and blue triangles. I'm trying to understand where $T + x_r - x_l$ comes from. I understand we are trying to compute the length of the base of the blue triangle, but I'm not sure how this expression is finding that.
You are computing the base of the red triangle, not the blue one. The blue triangle's base is already indicated as $T$.
Not very clear from the given figure, but as the only consistent answer I could find, assume that the coordinate of the right corner, $P_r$ of the blue triangle $P_l P P_r$ is measured with respect to the second origin $O_r$ indicated in the bottom right, and it seems to be a negative number by definition.
Therefore the length of the base of the triangle $P_l P P_r$ can be given as $$ L = |T| - |x_l| - |x_r|$$
where $T$ is a positive quantity by default, $x_l$ is measured wrtt left point $O_l$ and is positive by default, and $x_r$ will be a negative number as stated above; hence the absolute values can be expanded as
$$ L = T - x_l + x_r = T + x_r - x_l$$
Note that actually you do not have to use absolute values, but just proper adition of the signed quantities would suffice to derive the result. I've used the absolute values to provide some intuition into the signs of the summing coordinates.