From: Benjamin Mako Hill Date: Tue, 29 Dec 2015 21:21:14 +0000 (-0800) Subject: a series of updates to the mako-mem template X-Git-Url: https://code.communitydata.science/cdsc_tex.git/commitdiff_plain/d449d749d8456a657f61509a355b2b0b9e7e5dca?ds=inline a series of updates to the mako-mem template - Padded right/left margins to decrease line length based on research into general typographic standards. - Shrunk linespacing to decrease line-spacing to bring this in line with general typographic standards. - Added comments explaining the changes and basic typographic decisions. - Renamed some variables to make it more clear about the relationships between pagestyles. - Added the vc-git and vc-awk scripts into the repository so folks don't have to go hunting for them. - Made VC stuff generated by default in Makefile. - Increased the amount of sample text so we can actually see the effects on full pages of text. --- diff --git a/paper_template/Makefile b/paper_template/Makefile index f03bafe..05b7746 100644 --- a/paper_template/Makefile +++ b/paper_template/Makefile @@ -12,7 +12,7 @@ refs-processed.bib: perl -0pe 's/,\s+(file|abstract) = \{.*?\}(,\n|\n)/\2/sg' refs-processed.bib |sponge refs-processed.bib recode -d u8..ltex < refs-processed.bib | sponge refs-processed.bib -%.pdf: %.tex refs-processed.bib +%.pdf: %.tex refs-processed.bib vc latexmk -f -pdf $< clean: @@ -28,7 +28,7 @@ viewpdf: all evince *.pdf vc: - vc-git + resources/vc-git pdf: all diff --git a/paper_template/mako-mem.sty b/paper_template/mako-mem.sty index e453b01..5f80e40 100644 --- a/paper_template/mako-mem.sty +++ b/paper_template/mako-mem.sty @@ -192,8 +192,8 @@ %%% version control info in footers; requires vc package % Make the style for vc-git revision control headers and footers -\makepagestyle{kjhgit} -\newcommand{\@kjhgitmarks}{% +\makepagestyle{mako-mem-git} +\newcommand{\@gitmarks}{% \let\@mkboth\markboth \def\chaptermark##1{% \markboth{% @@ -206,11 +206,11 @@ \def\sectionmark##1{% \markright{##1}} } -\makepsmarks{kjhgit}{\@kjhgitmarks} -\makeevenhead{kjhgit}{}{}{\scshape\thepage} -\makeoddhead{kjhgit}{}{}{\scshape\thepage} -\makeevenfoot{kjhgit}{}{\texttt{\footnotesize{\textcolor{Blue}{git revision \VCRevision\ on \VCDateTEX}}}}{} -\makeoddfoot{kjhgit}{}{\texttt{\footnotesize \textcolor{Blue}{git revision \VCRevision\ on \VCDateTEX}}}{} +\makepsmarks{mako-mem-git}{\@gitmarks} +\makeevenhead{mako-mem-git}{}{}{\scshape\thepage} +\makeoddhead{mako-mem-git}{}{}{\scshape\thepage} +\makeevenfoot{mako-mem-git}{}{\texttt{\footnotesize{\textcolor{Blue}{git revision \VCRevision\ on \VCDateTEX}}}}{} +\makeoddfoot{mako-mem-git}{}{\texttt{\footnotesize \textcolor{Blue}{git revision \VCRevision\ on \VCDateTEX}}}{} %% Create a command to make a note at the top of the first page describing the %% publication status of the paper. diff --git a/paper_template/resources/vc-git b/paper_template/resources/vc-git new file mode 100755 index 0000000..557a573 --- /dev/null +++ b/paper_template/resources/vc-git @@ -0,0 +1,24 @@ +#!/bin/sh +# This is file 'vc' from the vc bundle for TeX. +# The original file can be found at CTAN:support/vc. +# This file is Public Domain. + +# Parse command line options. +full=0 +mod=0 +while [ -n "$(echo $1 | grep '-')" ]; do + case $1 in + -f ) full=1 ;; + -m ) mod=1 ;; + * ) echo 'usage: vc [-f] [-m]' + exit 1 + esac + shift +done +# English locale. +LC_ALL=C +git --no-pager log -1 HEAD --pretty=format:"Hash: %H%nAbr. Hash: %h%nParent Hashes: %P%nAbr. Parent Hashes: %p%nAuthor Name: %an%nAuthor Email: %ae%nAuthor Date: %ai%nCommitter Name: %cn%nCommitter Email: %ce%nCommitter Date: %ci%n" |gawk -v script=log -v full=$full -f ~/bin/vc-git.awk > vc +if [ "$mod" = 1 ] +then + git status |gawk -v script=status -f ~/bin/vc-git.awk >> vc +fi diff --git a/paper_template/resources/vc-git.awk b/paper_template/resources/vc-git.awk new file mode 100644 index 0000000..66b3526 --- /dev/null +++ b/paper_template/resources/vc-git.awk @@ -0,0 +1,89 @@ +# This is file 'vc-git.awk' from the vc bundle for TeX. +# The original file can be found at CTAN:support/vc. +# This file is Public Domain. +BEGIN { + +### Process output of "git status". + if (script=="status") { + modified = 0 + } + +} + + + +### Process output of "git log". +script=="log" && /^Hash:/ { Hash = substr($0, 2+match($0, ":")) } +script=="log" && /^Abr. Hash:/ { AbrHash = substr($0, 2+match($0, ":")) } +script=="log" && /^Parent Hashes:/ { ParentHashes = substr($0, 2+match($0, ":")) } +script=="log" && /^Abr. Parent Hashes:/ { AbrParentHashes = substr($0, 2+match($0, ":")) } +script=="log" && /^Author Name:/ { AuthorName = substr($0, 2+match($0, ":")) } +script=="log" && /^Author Email:/ { AuthorEmail = substr($0, 2+match($0, ":")) } +script=="log" && /^Author Date:/ { AuthorDate = substr($0, 2+match($0, ":")) } +script=="log" && /^Committer Name:/ { CommitterName = substr($0, 2+match($0, ":")) } +script=="log" && /^Committer Email:/ { CommitterEmail = substr($0, 2+match($0, ":")) } +script=="log" && /^Committer Date:/ { CommitterDate = substr($0, 2+match($0, ":")) } + +### Process output of "git status". +### Changed index? +script=="status" && /^# Changes to be committed:/ { modified = 1 } +### Unstaged modifications? +script=="status" && /^# Changed but not updated:/ { modified = 2 } + + + +END { + +### Process output of "git log". + if (script=="log") { +### Standard encoding is UTF-8. + if (Encoding == "") Encoding = "UTF-8" +### Extract relevant information from variables. + LongDate = substr(AuthorDate, 1, 25) + DateRAW = substr(LongDate, 1, 10) + DateISO = DateRAW + DateTEX = DateISO + gsub("-", "/", DateTEX) + Time = substr(LongDate, 12, 14) +### Write file identification to vc.tex. + print "%%% This file has been generated by the vc bundle for TeX." + print "%%% Do not edit this file!" + print "%%%" +### Write Git specific macros. + print "%%% Define Git specific macros." + print "\\gdef\\GITHash{" Hash "}%" + print "\\gdef\\GITAbrHash{" AbrHash "}%" + print "\\gdef\\GITParentHashes{" ParentHashes "}%" + print "\\gdef\\GITAbrParentHashes{" AbrParentHashes "}%" + print "\\gdef\\GITAuthorName{" AuthorName "}%" + print "\\gdef\\GITAuthorEmail{" AuthorEmail "}%" + print "\\gdef\\GITAuthorDate{" AuthorDate "}%" + print "\\gdef\\GITCommitterName{" CommitterName "}%" + print "\\gdef\\GITCommitterEmail{" CommitterEmail "}%" + print "\\gdef\\GITCommitterDate{" CommitterDate "}%" +### Write generic version control macros. + print "%%% Define generic version control macros." + print "\\gdef\\VCRevision{\\GITAbrHash}%" + print "\\gdef\\VCAuthor{\\GITAuthorName}%" + print "\\gdef\\VCDateRAW{" DateRAW "}%" + print "\\gdef\\VCDateISO{" DateISO "}%" + print "\\gdef\\VCDateTEX{" DateTEX "}%" + print "\\gdef\\VCTime{" Time "}%" + print "\\gdef\\VCModifiedText{\\textcolor{red}{with local modifications!}}%" + print "%%% Assume clean working copy." + print "\\gdef\\VCModified{0}%" + print "\\gdef\\VCRevisionMod{\\VCRevision}%" + } + +### Process output of "git status". + if (script=="status") { + print "%%% Is working copy modified?" + print "\\gdef\\VCModified{" modified "}%" + if (modified==0) { + print "\\gdef\\VCRevisionMod{\\VCRevision}%" + } else { + print "\\gdef\\VCRevisionMod{\\VCRevision~\\VCModifiedText}%" + } + } + +} diff --git a/paper_template/text.tex b/paper_template/text.tex index 53facf8..2ae4f95 100644 --- a/paper_template/text.tex +++ b/paper_template/text.tex @@ -1,8 +1,11 @@ \documentclass[12pt]{memoir} -% based on kieran healy's memoir modifications +% article-1 and article-2 styles were originally based on kieran healy's +% templates \usepackage{mako-mem} \chapterstyle{article-2} + +% with article-3 \chapterstyle, change to: \pagestyle{memo} \pagestyle{mako-mem} \usepackage{ucs} @@ -12,7 +15,7 @@ \usepackage{textcomp} \usepackage[garamond]{mathdesign} -\usepackage[letterpaper,left=1.2in,right=1.2in,top=1.2in,bottom=1.2in]{geometry} +\usepackage[letterpaper,left=1.65in,right=1.65in,top=1.3in,bottom=1.2in]{geometry} % packages i use in essentially every document \usepackage{graphicx} @@ -38,21 +41,30 @@ % memoir function to take out of the space out of the whitespace lists \firmlists -% import vc stuff after running `make vc`: \input{vc} \pagestyle{kjhgit} +% LATEX NOTE: these lines will import vc stuff after running `make vc` which +% will add version control information to the bottom of each page. This can be +% useful for keeping track of which version of a document somebody has: +% \input{vc} +% \pagestyle{mako-mem-git} \begin{document} \setlength{\parskip}{4.5pt} -\baselineskip 18.5pt +% LATEX NOTE: Ideal linespacing is usually said to be between 120-140% the +% typeface size. So, for 12pt (default in this document, we're looking for +% somewhere between a 14.4-17.4pt \baselineskip. Single; 1.5 lines; and Double +% in MSWord are equivalent to ~117%, 175%, and 233%. + +\baselineskip 16pt \title{Title} \author{Benjamin Mako Hill\\ \href{mailto:makohill@uw.edu}{makohill@uw.edu}} \date{} -% \published{\textsc{\textcolor{BrickRed}{This document is an -% unpublished draft.\\ Please do not distribute or cite without -% permission.}}} +\published{\textsc{\textcolor{BrickRed}{This document is an + unpublished draft.\\ Please do not distribute or cite without + permission.}}} \maketitle @@ -68,6 +80,31 @@ fox jumps over the lazy dog. \section{Section} +% LATEX NOTE: This alphabet below is here so we can measure the line-length of +% different layouts. Typesetters suggest that an average line-length of +% between 45-90 characters and a rule of thumb for typesetting is that you +% should be able to fit between 2-3 alphabets on one line. Generally speaking, +% the shorter the line length, the better -- and the smaller the linespacing +% can become. The following line is 3 alphabets (73 characters). + +abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz + +The quick brown fox jumps over the lazy dog. The quick brown fox jumps +over the lazy dog. The quick brown fox jumps over the lazy dog. The +quick brown fox jumps over the lazy dog. The quick brown fox jumps over +the lazy dog. The quick brown fox jumps over the lazy dog. The quick +brown fox jumps over the lazy dog. The quick brown fox jumps over the +lazy dog. The quick brown fox jumps over the lazy dog. The quick brown +fox jumps over the lazy dog \citep{989866}. + +The quick brown fox jumps over the lazy dog. The quick brown fox jumps +over the lazy dog. The quick brown fox jumps over the lazy dog. The +quick brown fox jumps over the lazy dog. The quick brown fox jumps over +the lazy dog. The quick brown fox jumps over the lazy dog. The quick +brown fox jumps over the lazy dog. The quick brown fox jumps over the +lazy dog. The quick brown fox jumps over the lazy dog. The quick brown +fox jumps over the lazy dog \citep{989866}. + The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over @@ -76,6 +113,53 @@ brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog \citep{989866}. +The quick brown fox jumps over the lazy dog. The quick brown fox jumps +over the lazy dog. The quick brown fox jumps over the lazy dog. The +quick brown fox jumps over the lazy dog. The quick brown fox jumps over +the lazy dog. The quick brown fox jumps over the lazy dog. The quick +brown fox jumps over the lazy dog. The quick brown fox jumps over the +lazy dog. The quick brown fox jumps over the lazy dog. The quick brown +fox jumps over the lazy dog \citep{989866}. + +The quick brown fox jumps over the lazy dog. The quick brown fox jumps +over the lazy dog. The quick brown fox jumps over the lazy dog. The +quick brown fox jumps over the lazy dog. The quick brown fox jumps over +the lazy dog. The quick brown fox jumps over the lazy dog. The quick +brown fox jumps over the lazy dog. The quick brown fox jumps over the +lazy dog. The quick brown fox jumps over the lazy dog. The quick brown +fox jumps over the lazy dog \citep{989866}. + +The quick brown fox jumps over the lazy dog. The quick brown fox jumps +over the lazy dog. The quick brown fox jumps over the lazy dog. The +quick brown fox jumps over the lazy dog. The quick brown fox jumps over +the lazy dog. The quick brown fox jumps over the lazy dog. The quick +brown fox jumps over the lazy dog. The quick brown fox jumps over the +lazy dog. The quick brown fox jumps over the lazy dog. The quick brown +fox jumps over the lazy dog \citep{989866}. + +The quick brown fox jumps over the lazy dog. The quick brown fox jumps +over the lazy dog. The quick brown fox jumps over the lazy dog. The +quick brown fox jumps over the lazy dog. The quick brown fox jumps over +the lazy dog. The quick brown fox jumps over the lazy dog. The quick +brown fox jumps over the lazy dog. The quick brown fox jumps over the +lazy dog. The quick brown fox jumps over the lazy dog. The quick brown +fox jumps over the lazy dog \citep{989866}. + +The quick brown fox jumps over the lazy dog. The quick brown fox jumps +over the lazy dog. The quick brown fox jumps over the lazy dog. The +quick brown fox jumps over the lazy dog. The quick brown fox jumps over +the lazy dog. The quick brown fox jumps over the lazy dog. The quick +brown fox jumps over the lazy dog. The quick brown fox jumps over the +lazy dog. The quick brown fox jumps over the lazy dog. The quick brown +fox jumps over the lazy dog \citep{989866}. + +The quick brown fox jumps over the lazy dog. The quick brown fox jumps +over the lazy dog. The quick brown fox jumps over the lazy dog. The +quick brown fox jumps over the lazy dog. The quick brown fox jumps over +the lazy dog. The quick brown fox jumps over the lazy dog. The quick +brown fox jumps over the lazy dog. The quick brown fox jumps over the +lazy dog. The quick brown fox jumps over the lazy dog. The quick brown +fox jumps over the lazy dog \citep{989866}. % bibliography here \renewcommand{\bibsection}{\section{\bibname}\prebibhook}