For and fragments I use the =texfrag= package. This allows to insert math fragments inside documents.

Example: