Skip to content

Commit

Permalink
Add aynumeric.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
LSYS committed Oct 23, 2024
1 parent 95467b8 commit c038e55
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 10 deletions.
91 changes: 81 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
# .SUFFIXES: .pdf .tex
.DEFAULT_GOAL := help

#==============================================================================
# Clean/purge aux files
#==============================================================================
TEXAUX := *.aux *.bbl *.fdb_latexmk *.fls *.log *.nav *.out *.snm *.synctex.gz *.toc
.PHONY: cleantex
cleantex: ## Clean aux output files in LaTex compilation
@echo "+ $@"
rm -f $(TEXAUX)


#==============================================================================
# Inspecting
#==============================================================================
Expand Down Expand Up @@ -94,6 +84,87 @@ inspect: duplicated_labels \
dueto \
wordcount


#==============================================================================
# Additional utilities
#==============================================================================
AY2NUMERIC_SRC = ./inspecting/ay2numeric.sh
.PHONY: aynumeric
aynumeric: ## Change author-year to numeric citation
@echo "==> $@"
@echo "Change author-year to numeric citations"
dos2unix $(AY2NUMERIC_SRC)
chmod +x $(AY2NUMERIC_SRC)
$(AY2NUMERIC_SRC)

#==============================================================================
# Define tex sources
#==============================================================================
# Define sources and outut
SRC_TEX := paper.tex
SRC_EXHIB := $(wildcard figures/* tables/*.tex)
OUT := $(SRC_TEX:%.tex=%.pdf)

.PHONY: list
list: ## List manifest
@echo "=> Src TeX files:"
@echo " $(SRC_TEX)"
@echo "=> Output (to make):"
@echo " $(OUT)"
@echo "=> Exhibits in ms:"
@echo " $(SRC_EXHIB)"

#==============================================================================
# Clean/purge aux files
#==============================================================================
TEXAUX := *.aux *.bbl *.fdb_latexmk *.fls *.log *.nav *.out *.snm *.synctex.gz *.toc
.PHONY: cleantex
cleantex: ## Clean aux output files in LaTex compilation
@echo "+ $@"
rm -f $(TEXAUX)

#==============================================================================
# Build the paper
#==============================================================================
WORDCOUNT_SCR := ./inspecting/wordcount.sh

paper.pdf: $(SRC_TEX) $(SRC_EXHIB)
@echo "+ $@"
rm -f $@ && latexmk -pdf $(<F) && latexmk -c

.PHONY: paperc
paperc: ## Make paper and purge aux
paperc: $(SRC_TEX) $(SRC_EXHIB)
@echo "+ $@"
rm -f $(OUT)
latexmk -pdf $(<F)
ps2pdf -dPDFSETTINGS=/screen $(OUT) _build/main-compressed.pdf
latexmk -c
rm -f $(OUT)
chmod +x $(WORDCOUNT_SCR)
dos2unix $(WORDCOUNT_SCR)
$(WORDCOUNT_SCR)
# gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=_build/main-compressed-optimized.pdf _build/main-compressed.pdf
# rm _build/main-compressed.pdf
# mv _build/main-compressed-opti
#https://web.mit.edu/ghostscript/www/Ps2pdf.htm
# /screen selects low-resolution output similar to the Acrobat Distiller "Screen Optimized" setting.
# /printer selects output similar to the Acrobat Distiller "Print Optimized" setting.
# /prepress selects output similar to Acrobat Distiller "Prepress Optimized" setting.
# /default selects output intended to be useful across a wide variety of uses, possibly at the expense of a larger output file.

.PHONY: paper
paper: ## Make paper (useful if still working w/ TexStudio)
paper: $(SRC_TEX) $(SRC_EXHIB)
@echo "+ $@"
rm -f $(OUT)gs ,
latexmk -pdf $(<F)
ps2pdf -dPDFSETTINGS=/screen $(OUT) _build/main-compressed.pdf
# chmod +x $(WORDCOUNT_SCR)
# dos2unix $(WORDCOUNT_SCR)
# $(WORDCOUNT_SCR)


#==============================================================================
# Help
#==============================================================================
Expand Down
1 change: 1 addition & 0 deletions inspecting/acronyms.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ acronyms() {
sed 's/\\citealt{[^}]*}//g' | # Drop citations with \citealt{} that may contain numbers
sed 's/\\citep{[^}]*}//g' | # This seems to work for \citep and not line 16..
sed 's/\\citet{[^}]*}//g' | # This seems to work for \citep and not line 16..
# =======================================================================
grep -wo "[A-Z]\+\{2,20\}" | sort | uniq -c | sort -gr |
tee -a "$LOG_FILE" # Log results to file
}
Expand Down
27 changes: 27 additions & 0 deletions inspecting/ay2numeric.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

SRC_TEX="paper.tex"

#==================================================================================
# Citations after periods.
# Expected behavior is:
# Before---This citation should appear after the period \cite{multi, citation, here}.
# After----This citation should appear after the period.\cite{multi, citation, here}
#==================================================================================
sed -i 's/\s*\\cite{\([^}]*\)}\./.\\cite{\1}/g' $SRC_TEX #Change \cite{} with periods

sed -i 's/\s*\\citep{\([^}]*\)}\./.\\citep{\1}/g' $SRC_TEX #same as above, but for \citep

sed -i 's/\s*\\citealt{\([^}]*\)}\./.\\citep{\1}/g' $SRC_TEX #same as above, but for \citealt

#==================================================================================
# Citations after commas.
# Expected behavior is:
# Before---This citation \cite{einstein}, should be after the comma.
# After----This citation,\cite{einstein} should be after the comma.
#==================================================================================
sed -i 's/\s*\\cite{\([^}]*\)},/,\\cite{\1}/g' $SRC_TEX #Change \cite{} with commas

sed -i 's/\s*\\citep{\([^}]*\)},/,\\citep{\1}/g' $SRC_TEX #same as above, but for \citep

sed -i 's/\s*\\citealt{\([^}]*\)},/,\\citep{\1}/g' $SRC_TEX #same as above, but for \citealt

0 comments on commit c038e55

Please sign in to comment.