commit 987a896f787e6ffd3953742deb89b51954a1b29c
parent a594b2f175f59da2b1fdf9ea2009a67b131f7cf7
Author: lumidify <nobody@lumidify.org>
Date: Sat, 11 Apr 2020 15:09:03 +0200
Remove fm.tex; clean up a bit
Diffstat:
4 files changed, 16 insertions(+), 37 deletions(-)
diff --git a/README b/README
@@ -7,8 +7,13 @@ using Gtk2.
The flashcard files are stored in `latex/`. You need to have a master
copy of them somewhere else, then run `./gen_cache.pl path/to/flashcards/`
to copy the new or changed flashcard files to `latex/` and render them.
+Note that you need to give the top-level flashcard directory, not the
+one with the actual flashcards in it. See the repository `flashcard-tools`
+for a description of the directory structure.
+
This uses `pdflatex`, `pdfcrop`, and `pdftoppm` to convert the LaTeX files
-to PNG, pasting `fm.tex` at the beginning of the flashcard before rendering it.
+to PNG, pasting the contents of `defs.tex` (from the flashcard directory)
+at the beginning before rendering so that the definitions are all there.
The top line of each flashcard file has the theorem number or something
similar, the second line has the front side of the card, and the rest
diff --git a/fm.tex b/fm.tex
@@ -1,31 +0,0 @@
-\documentclass[12pt]{article}
-\usepackage[utf8]{inputenc}
-\usepackage[T1]{fontenc}
-\usepackage{amsmath}
-\usepackage{amssymb}
-\usepackage{amsfonts}
-\usepackage{mathrsfs}
-\usepackage{enumitem}
-\usepackage{tikz-cd}
-
-\newcommand{\Bild}{\mathop{\text{Bild}}}
-\newcommand{\chara}{\mathop{\text{char}}}
-\newcommand{\Pol}{\mathop{\text{Pol}}}
-\newcommand{\ggT}{\mathop{\text{ggT}}}
-\newcommand{\Hom}{\mathop{\text{Hom}}}
-\newcommand{\evx}{\mathop{\text{ev}_x}}
-\newcommand{\End}{\mathop{\text{End}}}
-\newcommand{\Alt}{\mathop{\text{Alt}}}
-\newcommand{\sgn}{\mathop{\text{sgn}}}
-\newcommand{\Det}{\mathop{\text{Det}}}
-\newcommand{\Sym}{\mathop{\text{Sym}}}
-\newcommand{\spec}{\mathop{\text{spec}}}
-\newcommand{\Id}{\mathop{\text{Id}}}
-\newcommand{\GL}{\mathop{\text{GL}}}
-\newcommand{\diag}{\mathop{\text{diag}}}
-\newcommand{\K}{\mathop{\mathbb{K}}}
-\newcommand{\N}{\mathop{\mathbb{N}}}
-\newcommand{\sB}{\mathop{\mathscr{B}}}
-\newcommand{\sG}{\mathop{\mathscr{G}}}
-
-\pagestyle{empty}
diff --git a/gen_cache.pl b/gen_cache.pl
@@ -13,11 +13,13 @@ if ($#ARGV != 0) {
}
my $path = shift;
-opendir my $dir, $path or die "ERROR: Failed to open flashcard directory!\n";
+opendir my $dir, "$path/flashcards/" or die "ERROR: Failed to open flashcard directory!\n";
while (my $filename = readdir($dir)) {
next if ($filename =~ /\A\.\.?\z/);
- next if (-e "latex/$filename" && compare("latex/$filename", "$path/$filename") == 0);
- system "./render_card.sh", "$path/$filename";
- copy "$path/$filename", "latex/$filename";
+ next if (-e "latex/$filename" && compare("latex/$filename", "$path/flashcards/$filename") == 0);
+ if (system("./render_card.sh", "$path/flashcards/$filename", "$path/defs.tex") != 0) {
+ die "Error processing file $path/flashcards/$filename";
+ }
+ copy "$path/flashcards/$filename", "latex/$filename";
}
closedir $dir;
diff --git a/render_card.sh b/render_card.sh
@@ -2,6 +2,7 @@
filename="`basename $1`"
+defs=`cat "$2"`
meta1=`head -n 1 "$1" | tr -d '\n' | sed 's/|.*$//'`
meta2=`sed '2!d' "$1" | tr -d '\n'`
body=`tail -n +3 "$1"`
@@ -9,7 +10,9 @@ body=`tail -n +3 "$1"`
mkdir tmp
cd tmp
-cat ../fm.tex > tmp.tex
+echo '\\documentclass[12pt]{article}' > tmp.tex
+printf '%s' $defs >> tmp.tex
+echo '\\pagestyle{empty}' >> tmp.tex
printf '\\begin{document}\n%s\n\\newpage\n%s\n\\newpage\n%s\n\\end{document}\n' "$meta1" "$meta2" "$body" >> tmp.tex
pdflatex tmp.tex
pdfcrop --margins "5 5 5 5" tmp.pdf tmp1.pdf