         sagetex_file = @base_filename + '.sagetex.sage'
         not_latexmk = command.indexOf('latexmk') == -1
         sha_marker = 'sha1sums'
-        @_need_to_run.latex = false
+        @_need_to_run =
+            latex  : false
+            sage   : false  # either false or a filename
+            bibtex : false
         # yes x business recommended by http://tex.stackexchange.com/questions/114805/pdflatex-nonstopmode-with-tikz-stops-compiling
         @_exec
             command : "touch '#{@filename_tex}'; yes x | " + command + "; echo '#{sha_marker}'; sha1sum '#{sagetex_file}'"

                    if not_latexmk and log.indexOf(no_bbl) != -1
                        @_need_to_run.bibtex = true

                    @last_latex_log = log
                    cb?(false, log)

    _run_sage: (target, cb) =>
        if not target?
            target = @base_filename + '.sagetex.sage'
        @_exec

        @pdf_updated = true
        if not opts.latex_command?
            opts.latex_command = @default_tex_command()
        @_need_to_run =
            latex  : true   # initially, only latex is true
            sage   : false  # either false or a filename
            bibtex : false
        log = ''
        status = opts.status

