Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am not sure if this is recreate-able through a MWE. Whenever I compile a standalone TikZ picture, it compiles all my standalone figures in the same folder. I am using Ubuntu 13.04 and Emacs with server mode running.

enter image description here

Some of this information may be irrelevant, but I am not sure what is needed to troubleshoot such an issue. From the screen shot, I have the main document on the left and my TikZ picture I am creating on the right. As you can see, I compiled the figure and Latexmk compiled every other standalone .tex file too.

Output written on sunplanetspacecraft.pdf (1 page, 1117 bytes).
SyncTeX written on sunplanetspacecraft.synctex.gz.
Transcript written on sunplanetspacecraft.log.
Latexmk: Log file says output to 'sunplanetspacecraft.pdf'
Latexmk: All targets (sunplanetspacecraft.pdf) are up-to-date
Latexmk: All targets (transferchoices.pdf) are up-to-date
Latexmk: All targets (transfergeoa.pdf) are up-to-date
Latexmk: All targets (transfergeob.pdf) are up-to-date
Latexmk: All targets (trigidentities.pdf) are up-to-date
Latexmk: All targets (twobodies3D.pdf) are up-to-date
Latexmk: All targets (unitvec.pdf) are up-to-date
Latexmk: All targets (velcomp.pdf) are up-to-date

Latexmk finished at Thu Jul 25 14:12:06

I am compiling sunplanetspacecraft.tex and none of the files are related to the to this .tex file but yet they still were compiled.

I looked through the log file, but I didn't see anything that related to the other files Latexmk compiled. Below is my preamble in case that helps.

\documentclass[convert = false]{standalone}

\usepackage[utf8]{inputenc}
\renewcommand{\rmdefault}{ppl}                                  
\linespread{1.05}          
\usepackage[scaled]{helvet}                                  
\usepackage{courier}                                                    
\usepackage{eulervm}                       
\normalfont
\usepackage[T1]{fontenc}
\usepackage{textcomp}

\usepackage[usenames, dvipsnames, svgnames, table]{xcolor}                                             
\usepackage{tikz}
\usetikzlibrary{arrows}

The reason I want to resolve this is because one of the another standalone TikZ pictures takes about 2minutes to compile which slows down compiling a simple picture.


This problem cropped up with another document. This time my document that calls all my standalones in it tried calling an unrelated standalone just because it was in the same folder.

So a MWE (concept) would be to have a a folder, in the folder at a main.tex, in the main.tex, you need have \usepackage{standalone}, then we have two cases:

  1. create two standalones to be called in the main.tex and compile the first one. When you compile the second one, it will also compile the first one. This wont cause the problem I am having since you are probably creating simple documents (not an issue though). Just check the output to see if it compile the other one too. This will be the first issue at the top I mention. Create a folder called test.

    main.tex

        \documentclass{article}
        \usepackage{standalone}
        \usepackage{tikz}
        \begin{document}
        test
        \includestandalone{test1}
        \includestandalone{test2}
        \end{document}
    

    test1.tex

        \documentclass[tikz, convert = false]{standalone}
        \begin{document}
        \begin{tikzpicture}
          \draw (0, 0) -- (2, 0);
        \end{tikzpicture}
        \end{document}
    

    test2.tex

        \documentclass[tikz, convert = false]{standalone}
        \begin{document}
        \begin{tikzpicture}
          \draw (0, 0) -- (-2, 0);
        \end{tikzpicture}
        \end{document}
    

    So if I compile test2.tex, test1.tex compiles also. This hardly causes a slow down but you get the idea.

  2. create a standalone not called in the main.tex, but this time don't add anything in the file. Just name it and save it no preamble. Even though this file isn't being called by the main.tex, compiling the main.tex file will try and compile this file that doesn't even have a preamble. It calls because it has a .tex extension. In the same folder, create test3.tex which is blank no pre-amble or code and save it. Now add a line to main.tex and compile. This should cause the error no \begin{document} in the main file. The document will compile fine though but will constantly have that error. main.tex is forcing the compiling of a blank .tex file even though it isn't included.
;; ============ Latexmk setup ==============                                        
(defun run-latexmk ()
  (interactive)
  (let ((TeX-save-query nil)
        (TeX-process-asynchronous nil)
        (master-file (TeX-master-file)))
    (TeX-save-document "")
    (TeX-run-TeX "latexmk"
                 (TeX-command-expand "latexmk -pdf %O %S" 'TeX-master-file)
                 master-file))
    (if (plist-get TeX-error-report-switches (intern master-file))
        (TeX-next-error t)
      (progn
        (demolish-tex-help)
        (minibuffer-message "latexmk: done."))))

(add-hook 'LaTeX-mode-hook (lambda ()
    (push
     '("Latexmk" "latexmk -pdf %S" TeX-run-TeX nil t
       :help "Run Latexmk on file")
     TeX-command-list)))

.latexmkrc setup:

$pdflatex = 'pdflatex --shell-escape -interaction=nonstopmode %O %S -file-line-error -synctex=1';

share|improve this question
    
How are you running Latexmk? By default it runs on every .tex file (according to users.phys.psu.edu/~collins/software/latexmk-jcc/…) –  Jim Paris Jul 25 '13 at 19:51
    
It will be a lot easier for us to help you if you make a real MWE -- put a zip file up somewhere that has an entire directory tree that shows the problem. Then tell us exactly what commands to run, and what behavior you're seeing, and what behavior you expect. –  Jim Paris Aug 3 '13 at 15:02
    
You also still need to tell us exactly what command line was used to invoke latexmk. The behavior you are seeing is exactly what happens when the command line is "latexmk", without any file name, whereas the command line should have been "latexmk sunplanetspacecraft.tex". This was what @JimParis was getting at in his first comment. Since you are using emacs to invoke latexmk, it is possible that emacs is misconfigured. The value of $pdflatex that you quoted is irrelevant for this issue. –  John Collins Aug 5 '13 at 14:45
    
How have you customized emacs/auctex to have a latexmk command? The answers in stackoverflow.com/questions/2199678/… suggest how to do this. Did you possibly omit "%s" in the definition of how to run latexmk? That would be consistent with the symptoms you observe (and I can reproduce them). –  John Collins Aug 6 '13 at 15:18
2  
Try the following: First, in .emacs only, change the %O %S and %S to %s (lower case). Second, in latexmkrc only, move the %O %S to the end of the defined command line, just inside the single quotes, but keeping it as %O %S (upper case). That works for me. If it works for you, I'll convert this to an answer (with explanation). –  John Collins Aug 6 '13 at 17:09

1 Answer 1

up vote 4 down vote accepted

The difficulty is that both emacs/auctex and latexmk need to be configured, and there has been a confusion about what belongs where. Auctex invokes latexmk, and then latexmk has the job of invoking other programs, like pdflatex as needed.

The code in .emacs is for configuring emacs/auctex so that it will be able to call latexmk. It needs to contain

;; ============ Latexmk setup ==============                                        
(defun run-latexmk ()
  (interactive)
  (let ((TeX-save-query nil)
        (TeX-process-asynchronous nil)
        (master-file (TeX-master-file)))
    (TeX-save-document "")
    (TeX-run-TeX "latexmk"
                 (TeX-command-expand "latexmk -pdf %s" 'TeX-master-file)
                 master-file))
    (if (plist-get TeX-error-report-switches (intern master-file))
        (TeX-next-error t)
      (progn
        (demolish-tex-help)
        (minibuffer-message "latexmk: done."))))

(add-hook 'LaTeX-mode-hook (lambda ()
    (push
     '("Latexmk" "latexmk -pdf %s" TeX-run-TeX nil t
       :help "Run Latexmk on file")
     TeX-command-list)))

Compared with the listing given in the question, there appears %s (with lower case) instead of %O %S and %S. The %s denotes the name of the source file on the command line used to start latexmk.

The code in .latexmkrc is for configuring latexmk. It needs to contain

$pdflatex = 'pdflatex --shell-escape -interaction=nonstopmode -file-line-error -synctex=1 %O %S';

This specifies to latexmk how to make the command line it uses to invoke pdflatex. The %O and %S (with upper case) say where to put extra options and the source file. Because of how pdflatex parses its command line, the %O %S needs to be at the end of the template for the command line.

This answer makes obsolete what appears in an answer to an earlier question on configuring emacs to use latexmk, at How to make `latexmk` run the appropriate amount of times However, the answers for a basic configuration of emacs given in another related question http://stackoverflow.com/questions/2199678/how-to-call-latexmk-in-emacs-and-jump-to-next-error are correct.

share|improve this answer
    
Just one question. Why does %O %S and %S cause the compiling of every figure in the folder when one is compiled and the compiling of non-called .tex files when the the master file was compiled? I am just curious. –  dustin Aug 6 '13 at 21:31
    
@dustin: When %S instead of %s appears in the specification of the latexmk command line in the file .emacs, it gets replaced by an empty string when the command line is built. So latexmk is invoked with a command line with no filename. As explained by @JimParis in his first comment to your question, latexmk's default behavior in this situation is to compile all .tex files in the directory, just as you saw. –  John Collins Aug 7 '13 at 11:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.