Makefile für Latex

Hier ein Teil das mir viel hilft. Ein Makefile für LaTeX. was kann es denn?

  • make all: Kreiert alle Ausgaben
  • make filename.pdf: Kreiert das pdf mit Thumbnails
  • make build: Kreiert das pdf und kopiert es ins Verzeichnis build/
  • make pdfview: Kreiert das pdf und zeigt es an
  • make fast: Schnelldurchlauf pdf und Anzeigen
  • make filename.rtf: Richtextversion
  • make filename.ps: Post Script
  • make clean: Aufräumen

Durch Switches zu Beginn können Glossar- und Indexerzeugung gesteuert werden… Für Verbesserungen bin ich sehr dankbar.

# Makefile to create different LaTeX Outputs
#
# 2001-2006 by Stefan Birrer and Michael Schneider
#
# Supports the following Targets:
#
# all     Creates html and pdf
# html   Creates html in the specified directory
#         Creates pdf and copies it into the html-directory
# pdfview      Creates pdf and views it
# FILENAME.pdf Creates a pdf with thumbnails
# FILENAME.ps  Creates Postscript and DVI
# FILENAME.dvi Creates DVI
# FILENAME.rtf TRIES to create a RTF
# clean :) Cleans up your room !

target = documentname
WITH_INDEX = Yes
WITH_GLOSSARY = No
latex_SOURCES = $(target).tex sec/*.tex
html = html

all: html

html: $(target).pdf $(latex_SOURCES)
#   -rm $(target).aux
    echo "Running latex2html..."
    latex2html -dir $(html) -local_icons -show_section_numbers -white -antialias -no_math -html_version 4.0,math,frame -split +1 $(target)
    cp $(html)/$(target).html $(html)/index.html
#   latex2html -dir $(html) -white -antialias -no_math -html_version 4.0,math -split +1 $(target)
#   echo "Copying PDF"
#   cp $(target).pdf $(html)

build: $(target).pdf
    cp $(target).pdf ./build/

pdfview: $(target).pdf
    acroread $(target).pdf

fast: $(latex_SOURCES)
    pdflatex -shell-escape $(target)
    acroread $(target).pdf

%.pdf: $(target).ps $(latex_SOURCES)
    @echo "*"
    @echo "* Running pdflatex..."
    @echo "*"
    pdflatex -shell-escape $(target)
    @echo "*"
    @echo "* Rerunning pdflatex..."
    @echo "*"
    pdflatex -shell-escape $(target)
    @echo "*"
    @echo "* Thumbnails..."
    @echo "*"
    thumbpdf $(target).pdf
ifeq ($(WITH_INDEX),Yes)
        @echo "*"
        @echo "* Running makeindex for index..."
        @echo "*"
        makeindex -g -s include/bbbind.idx $(target)
endif
ifeq ($(WITH_GLOSSARY),Yes)
        @echo "*"
        @echo "* Running makeindex for glossary..."
        @echo "*"
        makeindex -s nomencl.ist -o $(target).gls $(target).glo
endif
    @echo "*"
    @echo "* Rerunning pdflatex..."
    @echo "*"
    pdflatex -shell-escape $(target)

%.rtf:  %.dvi $(latex_SOURCES)
    @echo "*"
    @echo "* Running latex2rtf..."
    @echo "*"
    latex2rtf -l -o $(target).rtf $(latex_SOURCES)
    makeindex $(target).idx
    @echo "*"
    @echo "* Rerunning latex2rtf..."
    @echo "*"
    latex2rtf -l -o $(target).rtf $(latex_SOURCES)
    @echo "*"
    @echo "*"
    @echo "* WARNING:"
    @echo "* THIS IS KIND OF EXPERIMENTAL"
    @echo "* Haven't found something better yet :("
    @echo "*"
    @echo "*"

%.ps: %.dvi
    dvips -o $(*F).ps $(*F).dvi

%.dvi: $(latex_SOURCES)
    @echo "*"
    @echo "* Running latex..."
    @echo "*"
    latex -shell-escape $(target)
    @echo "*"
    @echo "* Rerunning latex..."
    @echo "*"
    latex -shell-escape $(target)
ifeq ($(WITH_INDEX),Yes)
        @echo "*"
        @echo "* Running makeindex for index..."
        @echo "*"
        makeindex -g -s include/bbbind.idx $(target)
endif
ifeq ($(WITH_GLOSSARY),Yes)
        @echo "*"
        @echo "* Running makeindex for glossary..."
        @echo "*"
        makeindex -s nomencl.ist -o $(target).gls $(target).glo
endif
    @echo "*"
    @echo "* Rerunning latex...."
    @echo "*"
    latex -shell-escape $(target)

clean:
    -rm -rf tmp.tmp *.tpt $(html)/*
          $(target).ps $(target).dvi $(target).pdf
          *.gls *.glo *.lot *.aux *.toc *.idx *.ind *.ilg *.log *.out *.brf *.cb *~
          thumb* *.rtf *.backup include/*.backup sec/*.backup sec/*.log images/*.log

Ein Gedanke zu “Makefile für Latex

  1. Hallo,

    danke fürs Script. Ich hab noch folgendes hinzugefügt:

    check: $(target).dvi
    @echo „*“
    @echo „* Checking LaTeX file…“
    @echo „*“
    chktex $(target)
    @echo „*“
    @echo „* Checking hyphenation…“
    @echo „*“
    hyphen_show $(target).dvi

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.