Results 1 to 5 of 5

Thread: LaTeX Makefile

  1. #1
    Join Date
    Jan 2008
    Location
    Madison, WI
    Beans
    69
    Distro
    Ubuntu 12.04 Precise Pangolin

    LaTeX Makefile

    Does anyone know what's wrong with this Makefile? I thought the Makefile would be smart enough to know whether or not any of the .tex files have changed, and therefore not run pdflatex if they weren't ...

    Code:
    # List all the files that are used when producing the pdf
    FILES = \
        main.tex \
        chap1.tex \
        chap2.tex \
        chap3.tex \
        chap4.tex \
        chap5.tex \
        appendix.tex
    
    # this line should only execute when a single file from above has been altered
    # The only problem is that isn't the case ...
    all: $(FILES)
    	pdflatex main.tex
    Of course, that's a tab before the pdflatex command ...

  2. #2
    Join Date
    Nov 2005
    Location
    Sendai, Japan
    Beans
    11,296
    Distro
    Kubuntu

    Re: LaTeX Makefile

    Code:
    # List all the files that are used when producing the pdf
    FILES = \
        main.tex \
        chap1.tex \
        chap2.tex \
        chap3.tex \
        chap4.tex \
        chap5.tex \
        appendix.tex
    
    # this line should only execute when a single file from above has been altered
    # The only problem is that isn't the case ...
    main.pdf: $(FILES)
    	pdflatex main.tex
    If you don't say what the output file is, make can't check if a source file is more recent than it.
    「明後日の夕方には帰ってるからね。」


  3. #3
    Join Date
    Jan 2008
    Location
    Madison, WI
    Beans
    69
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: LaTeX Makefile

    I think I'm going to run with latexmk, which is available in the repositories. If you have a project that depends on a few different .tex files, and main.tex is your main file, you can get away with simply typing:
    Code:
    latexmk main.tex
    I think this is the makefile I'm going to roll with:
    Code:
    TEX = latexmk
    
    # List all the files that are used when producing the pdf
    MAIN_FILE = main.tex
    
    FILES = \
        chap1.tex \
        chap2.tex \
        chap3.tex \
        chap4.tex \
        chap5.tex \
        appendix.tex
    
    FLAGS = -bibtex -pdf
    
    all: $(FILES)
    	$(TEX) $(FLAGS) $(MAIN_FILE)
    
    clean:
    	rm *.pdf *.aux *.log *.toc *.lof
    http://www.phys.psu.edu/~collins/software/latexmk-jcc/
    Last edited by dankdave; May 3rd, 2012 at 05:05 AM. Reason: adding link for latexmk

  4. #4
    Join Date
    Jan 2008
    Location
    Madison, WI
    Beans
    69
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: LaTeX Makefile

    Quote Originally Posted by Bachstelze View Post
    If you don't say what the output file is, make can't check if a source file is more recent than it.
    What's the order that the dependencies get resolved in? I originally wanted to run pdflatex only when one of the .tex files gets changed.

    However, with that being said, maybe that's not such a hot idea. Sometimes you need to run pdflatex a few times in order to get all the citations and references to actually show up in your pdf.

  5. #5
    Join Date
    Nov 2005
    Location
    Sendai, Japan
    Beans
    11,296
    Distro
    Kubuntu

    Re: LaTeX Makefile

    Quote Originally Posted by dankdave View Post
    What's the order that the dependencies get resolved in? I originally wanted to run pdflatex only when one of the .tex files gets changed.
    The command will be run if any of the files listed as a dependency was modified, so the order is unimportant. If you want to check for only one file, include only that file as a dependency. What you said about running it several times is true, though...
    「明後日の夕方には帰ってるからね。」


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •