Why does $\int\frac{1}{2x+1}dx=\frac{1}{2}\ln|2x+1|+C$? The way I am thinking is as follows:
$$\int\frac{1}{2x+1}\,dx = \int\frac{1}{2}\frac{1}{x+\frac{1}{2}}\,dx = \frac{1}{2}\int\frac{1}{x+\frac{1}{2}}\,dx = \frac{1}{2}\ln\left|x+\frac{1}{2}\right|+C$$
However, the textbook answer is $\frac{1}{2}\ln|2x+1|+C$. Where is my thinking wrong?

You forgot to add a constant, $C$. This is important: your answer differs from the textbook's only by a constant. 
$$\frac{1}{2}\ln\left|x + \frac{1}{2}\right| = \frac{1}{2}\ln\left|\frac{2x + 1}{2}\right| = \frac{1}{2}[\ln|2x + 1| - \ln(2)] = \frac{1}{2}\ln|2x + 1| - \frac{1}{2}\ln(2)$$
So 
$$\int \frac{1}{2x+1}\, dx = \frac{1}{2}\ln\left|x + \frac{1}{2}\right| + C = \frac{1}{2}\ln|2x + 1| + C.$$
