Skip to content

Instantly share code, notes, and snippets.

@tailriver
Last active December 10, 2015 20:08
Show Gist options
  • Save tailriver/4486003 to your computer and use it in GitHub Desktop.
Save tailriver/4486003 to your computer and use it in GitHub Desktop.
makeによるTeX論文作成用タイプセット
\setcounter{chapter}{0}
\chapter{Introduction}
\section{Background}
Lorem ipsum dolor sit amet ...
\section{Purpose}
Lorem ipsum dolor sit amet ...
\setcounter{chapter}{4}
\chapter{Conclusion}
Lorem ipsum dolor sit amet ...
\begin{thebibliography}{99}
% snip
\end{thebibliography}
\frontmatter
\maketitle
\tableofcontents
\mainmatter
SERIALIZER=./serialize.pl $(TEX_PREAMBLE)
PLATEX=platex -interaction=batchmode -halt-on-error -kanji=utf8 -shell-escape
DVIPDFMX=dvipdfmx
TEX_PREAMBLE=preamble.tex
TEX_COVER=cover.tex
TEX_CHAPTER=1_introduction.tex\
5_conclusion.tex\
7_bibliography.tex\
PDF_THESIS=thesis.pdf
PDF_CHAPTER=$(TEX_CHAPTER:tex=pdf)
.PHONY: all chapter thesis clean
.INTERMEDIATE: $(PDF_THESIS:pdf=dvi)
all: chapter thesis
chapter: $(PDF_CHAPTER)
thesis: $(PDF_THESIS)
clean:
$(RM) $(PDF_THESIS) $(PDF_CHAPTER) $(PDF_THESIS:pdf=log)
%.pdf: %.dvi
$(DVIPDFMX) $<
-$(RM) $*.aux $*.toc
thesis.dvi: $(TEX_COVER) $(TEX_CHAPTER) $(TEX_PREAMBLE)
$(SERIALIZER) $(TEX_COVER) $(TEX_CHAPTER) >temp.tex
@$(PLATEX) -jobname=$(@:.dvi=) temp.tex
@$(PLATEX) -jobname=$(@:.dvi=) temp.tex
$(PLATEX) -jobname=$(@:.dvi=) temp.tex
-$(RM) temp.tex
%.dvi: %.tex $(TEX_PREAMBLE)
$(SERIALIZER) $< >temp.tex
$(PLATEX) -jobname=$* temp.tex || (less $*.log && false)
@$(PLATEX) -jobname=$* temp.tex
-$(RM) temp.tex $*.log
\documentclass[a4j,11pt]{jsbook}
\usepackage[dvipdfm]{graphicx}
\title{Sein und Zeit}
\author{Martin Heidegger}
\date{1927}
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
binmode STDOUT => ':utf8';
my $preamble = shift @ARGV;
open my $PREAMBLE, '<:utf8', $preamble or die $!;
print while <$PREAMBLE>;
close $PREAMBLE;
print "\\begin{document}\n";
for my $chapter (@ARGV) {
open my $CHAPTER, '<:utf8', $chapter or die $!;
while (<$CHAPTER>) {
s/、/,/g;
s/。/./g;
print $_;
}
close $CHAPTER;
}
print "\\end{document}\n";
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment