It took me a while to figure this out so I thought it might be useful to a few other people.
When you have used htseq-count on each of your RNA-seq'ed samples and have combined all of your samples in a read count matrix, you might want to turn the absolute read counts into FPKM at some time. Therefore you need the total amount (maybe TMM/quartile-normalized) of mapped reads for each sample (easy) and the total exonic length for each gene (tricky).
The problem is that a gene can have multiple transcripts where the exons of transcript 1 might be partially overlapping with the exons of transcript2. So simply adding up the length of all exons annotated for a specific gene overestimates the gene size while taking the length of just 1 of the transcripts underestimates. Using the GenomicFeatures package from Bioconductor you can easily handle this issue.
# First, import the GTF-file that you have also used as input for htseq-count library(GenomicFeatures) txdb <- makeTxDbFromGFF("yourFile.gtf",format="gtf") # then collect the exons per gene id exons.list.per.gene <- exonsBy(txdb,by="gene") # then for each gene, reduce all the exons to a set of non overlapping exons, calculate their lengths (widths) and sum then exonic.gene.sizes <- sum(width(reduce(exons.list.per.gene)))