Technik, Gothic und Anderes

Technik ist Spiel, Gothic ist ernst und Zeit hat man zuviel

Makefile für Latex

Geschrieben von skaldrom am 13. December 2006

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
Teile und geniesse:
  • Technorati
  • del.icio.us
  • MisterWong
  • Digg
  • StumbleUpon
  • blogmarks
  • Furl
  • Simpy
  • Spurl
  • YahooMyWeb

Eine Antwort zu “Makefile für Latex”

Kommentare

  1. Manuel Schreibt:

    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

Lassen Sie eine Antwort hier...

XHTML: Sie können folgende Tags verwenden: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>