. Is the former to reinforce repetition of a desired behavior? For example, taking away a toy that a dog wants until it sits (desired behavior)? And would negative punishment be taking away a toy that a dog wants until it stops barking (undesired behavior)?
Not exactly. Negative reinforcement usually refers a stimulus that compels the behaviour, removing it when you get the behaviour. e.g. with horses it's very clear.....apply pressure to the reins or the sides of the horse, remove the pressure when the horse responds. An example with dogs would be e-collar training, for instance when teaching the recall, where you use a low level stim which goes away when the dog comes to you. In practice, you let the dog walk around on a long line, apply the stim at the lowest level he can feel, then use the line to draw him in to you while you turn off the stim. Very quickly the dog learns that that annoying sensation goes away when he comes to you. As you can see, the reinforcement is taken away when the animal responds correctly.
Negative punishment is taking away something the animal desires when he doesn't behave as required. Example, not giving the treat he knows you have because he did not respond to your command. Another example, removing his freedom (putting him in a crate) when his behaviour is unacceptable. A "time out" is negative punishment. In both of your examples you are describing negative punishment, as you want the undesired behaviour (refusing a command, unnecessary barking) to cease.