aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--README.md1
-rw-r--r--citations.tex32
-rw-r--r--example.tex8
-rw-r--r--sort.py4
-rw-r--r--sort.tex1
6 files changed, 32 insertions, 16 deletions
diff --git a/.gitignore b/.gitignore
index bda7ee5..83a15b5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,7 @@
.sort.py.swp
*.log
*.pdf
+<<<<<<< HEAD
*.DS_STORE
*.swp
+sort.tex
diff --git a/README.md b/README.md
index bd7e9ac..4a2b0d8 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,6 @@ This repository is designed to organize and make portable all of Holden Rohrer's
- mla8.tex % a general mla formatter for typical written assignments
- citations.tex % a citation generator and aggregator for MLA 8th Edition
- .gitignore % exactly what you expect
-- sort.tex % a temporary file to hold data to sort for alphabetization
- sort.py % a Python script which sorts sort.tex when called
- example.tex % an example of the capability of mla8.tex
```
diff --git a/citations.tex b/citations.tex
index addb4ec..11428ad 100644
--- a/citations.tex
+++ b/citations.tex
@@ -1,8 +1,8 @@
\long\edef\citations{}
-\long\def\newcitation#1{%
- \long\edef\citations{
- \hangafter=-1 \hangindent=0.5in%hanging indents must be inserted every paragraph
- \citations\par #1}%
+\long\def\newcitation#1#2{%
+ \long\edef\citations{\citations{#2}%allows alphabetization by including sanitized relevant data
+ \hangafter=-1 \hangindent=0.5in\relax%hanging indents must be inserted every paragraph
+ #1\par}%
}
\def\cite#1{%the actual citation request made by users
\def\cltitle{}\def\clcontain{}%"clean" data intended for alphabetization in bibliography
@@ -12,12 +12,12 @@
\def\@last{}\def\@namedisp{}\def\name##1##2{\def\@last{##1}\def\@namedisp{\ifx\@title\empty ##2.\fi}}%takes a last name and how names ought display, allowing multiple authors
\def\@title{}\def\title##1{\def\@title{``##1.''}\def\cltitle{##1}}%individual source like chapter or webpage
\def\@contain{}\def\contain##1{\def\@contain{ {\twelveit ##1}\ifx\@title\empty .\else, by \@namedisp \comma \fi}\def\clcontain{##1}}%container (book contains chapter)
- \def\@contrib{}\def\contrib##1{\def\@contrib{ ##1\comma}}%other contributors with roles
- \def\@version{}\def\version##1{\def\@version{ ##1\comma}}%version, if notable or unique
- \def\@relnums{}\def\relnums##1{\def\@relnums{ ##1\comma}}%relevant numbers like journal issue or volume number
- \def\@publish{}\def\publish##1{\def\@publish{ ##1\comma}}%publisher
- \def\@pubdate{}\def\pubdate##1{\def\@pubdate{ ##1\comma}}%publication date
- \def\@locator{}\def\locator##1{\def\@locator{ ##1}}%page numbers or web address
+ \def\@contrib{}\def\contrib##1{\def\@contrib{\ ##1\comma}}%other contributors with roles
+ \def\@version{}\def\version##1{\def\@version{\ ##1\comma}}%version, if notable or unique
+ \def\@relnums{}\def\relnums##1{\def\@relnums{\ ##1\comma}}%relevant numbers like journal issue or volume number
+ \def\@publish{}\def\publish##1{\def\@publish{\ ##1\comma}}%publisher
+ \def\@pubdate{}\def\pubdate##1{\def\@pubdate{\ ##1\comma}}%publication date
+ \def\@locator{}\def\locator##1{\def\@locator{\ ##1}}%page numbers or web address
\def\@pagenum{}\def\pagenum##1{\def\@pagenum{##1}}%page number, as relevant to inline citations
\countdef\commas=11\count11=0%
#1%
@@ -28,7 +28,7 @@
\ifx\@pubdate\empty \else \advance \commas by 1\fi%
\ifx\@locator\empty \else \advance \commas by 1\fi%
\def\comma{\advance\commas by -1 \noexpand\ifnum\noexpand\commas>0 ,\noexpand\fi}%
- \ifnewcite\newcitation{\@namedisp \@title \@contain \@contrib \@version \@relnums \@publish \@pubdate \@locator.}\fi%
+ \ifnewcite\newcitation{\@namedisp \@title \@contain \@contrib \@version \@relnums \@publish \@pubdate \@locator.}{\@namedisp\cltitle\clcontain}\fi%
(\ifnameinline
\ifx\@last\empty
\@title
@@ -41,5 +41,13 @@
\long\def\biblio{ %generates a bibliography
\vfil \eject %prints all previous pages and starts bibliography
\line{\hfil Works Cited \hfil}%
- \citations%
+%%Alphabetization
+ \immediate\openout0=sort.tex%
+ \immediate\write0{\unexpanded\expandafter{\citations}}%
+ \immediate\closeout0%
+ \immediate\write18{python3 sort.py}%sort sort.tex alphabetically by the first group (also remove first group)
+ \immediate\openin0=sort.tex%
+ \immediate\read0 to \data%
+ \immediate\data%
+ \immediate\closein0%
}
diff --git a/example.tex b/example.tex
index 3eeee42..0528d44 100644
--- a/example.tex
+++ b/example.tex
@@ -19,5 +19,13 @@ This stuff is back outside of the blockquote \cite{%
\locator{www.ncjrs.gov/pdffiles1/nij/grants/203968.pdf}%
\nameinline \newcite
}
+
+Second paragraph with new citation \cite{%
+ \name{Bhwartz}{Bhwartz, Aaron}%
+ \contain{TeX Academy}%
+ \publish{Not really}%
+ \pubdate{44 Sep. 2001}%
+ \nameinline \newcite%
+}
\biblio
\bye
diff --git a/sort.py b/sort.py
index 00007bc..1a38450 100644
--- a/sort.py
+++ b/sort.py
@@ -2,7 +2,7 @@
#Inputs file sort.tex, to sort as read, takes all data, and then reopens as write
f = open('sort.tex','r')
-dat = f.readlines()
+dat = f.readline().split('\\par ')
f.close()
f = open('sort.tex','w')
@@ -24,4 +24,4 @@ for lineind in range(len(dat)):
dat[lineind] = firstgroup(line)
dat.sort(key=lambda text : [ord(char) for char in text[0]])
-f.write(''.join([line[1] for line in dat]))
+f.write('\\par'.join([line[1] for line in dat]))
diff --git a/sort.tex b/sort.tex
deleted file mode 100644
index c93cae4..0000000
--- a/sort.tex
+++ /dev/null
@@ -1 +0,0 @@
-real text