code: def run(self):
          '''Run the LaTeX compilation.'''
          self.old_dir = []
          if self.opt.clean:
              self.old_dir = os.listdir('.')
          cite_counter, toc_file, gloss_files = self._read_latex_files()
          self.latex_run()
          self.read_glossaries()
          gloss_changed = self.makeindex_runs(gloss_files)
          if gloss_changed or self._is_toc_changed(toc_file):
              self.latex_run()
          if self._need_bib_run(cite_counter):
              self.bibtex_run()
              self.latex_run()
          while (self.latex_run_counter < MAX_RUNS):
              if not self.need_latex_rerun():
                  break
              self.latex_run()
          if self.opt.check_cite:
              cites = set()
              with open('%s.aux' % self.project_name) as fobj:
                  aux_content = fobj.read()
              for match in BIBCITE_PATTERN.finditer(aux_content):
                  name = match.groups()[0]
                  cites.add(name)
              with open('%s.bib' % self.bib_file) as fobj:
                  bib_content = fobj.read()
              for match in BIBENTRY_PATTERN.finditer(bib_content):
                  name = match.groups()[0]
                  if name not in cites:
                      self.log.info('Bib entry not cited: "%s"' % name)
          if self.opt.clean:
              ending = '.dvi'
              if self.opt.pdf:
                  ending = '.pdf'
              for fname in os.listdir('.'):
                  if not (fname in self.old_dir or fname.endswith(ending)):
                      try:
                          os.remove(fname)
                      except IOError:
                          pass
          if self.opt.preview:
              self.open_preview()