Added grffile package to latex templates
Added idx_nearest function to dom