1004
LPT Do it. (mander.xyz)
you are viewing a single comment's thread
view the rest of the comments
[-] qjkxbmwvz@startrek.website 44 points 6 months ago

I also added a Makefile for mine (LaTeX), and it would add the commit hash to the front page (with an asterisk if the repository had uncommitted changes).

So, if I gave a draft to someone and got feedback, I'd know exactly which revision it was.

[-] GarlicToast@programming.dev 6 points 6 months ago

This is brilliant

[-] flango@lemmy.eco.br 2 points 6 months ago

Hey, amazing idea, can you share the code?

[-] qjkxbmwvz@startrek.website 5 points 6 months ago

Makefile in other comments. You'll need something like this on the title page (this assumes you use my Makefile which puts the version in VERSION.tex [that's the literal name of the file, not a placeholder]):

{\bf{\color{red}DOCUMENT REVISION:}} {\color{blue}\input{VERSION}}

[-] qjkxbmwvz@startrek.website 5 points 6 months ago

Sure thing. This also includes the beamer bit which I used for my defense. It's all pretty hacky but hope it's useful!

#
# Errors aren't handled gracefully (tex doesn't write to stderr, it seems)
# If you encounter errors, use "make verbose"
#
# For small changes (probably those without references), use "make quick"
#
# Thanks to https://gist.github.com/Miliox/4035649 for dependency outline

TEX = pdflatex
BTEX = biber
MAKE = make -s
TEXFLAGS = -halt-on-error
# $(MAIN).log is dumb if we have multiple targets!
SILENT = > /dev/null || cat $(MAIN).log
SILENT_NOER = 2>/dev/null 1>/dev/null
EDITOR = vim -p
PDFVIEW = evince
MAIN = main
PRES = presentation
ALL = $(MAIN).pdf
RECURS = media/ manuscripts/
VERSION := $(shell git rev-parse --short HEAD | cut -c 1-4)$(shell git diff-index --quiet HEAD && (echo -n ' ';git log -1 --format=[%cd]) || (echo -n '* '; date -u '+[%c]'))

all: recurs $(ALL)
pres: $(PRES).pdf
scratch: scratch.pdf

scratch.pdf: scratch.tex
	@echo "TEX	(final)	$<"
	@$(TEX) $(TEXFLAGS) $< $(SILENT)

verbose: SILENT = ''
verbose: $(ALL)

recurs: $(RECURS)
	@$(foreach DIR, $(RECURS), \
		echo "MAKE	(CD)	$(CURDIR)/$(DIR)"; \
		$(MAKE) -C $(DIR) $(MAKECMDGOALS);)
	@echo "MAKE	(CD)	./"

clean:
	@echo "SH	(RM)	Not recursing; 'make allclean' to clear generated files."
	@rm -f *.aux *.log *.out *.pdf *.bbl *.blg *.toc *.lof *.lot *.bcf *.run.xml

allclean: recurs
	@echo "SH	(RM)	A clean directory is a happy directory"
	@rm -f *.aux *.log *.out *.pdf *.bbl *.blg *.toc *.lof *.lot *.bcf *.run.xml
version:
	@echo "SH      (ver) $(VERSION)"
	@echo $(VERSION) > VERSION.tex

nixpages: main.pdf
	@echo "PDF     (pdftk)"
	@pdftk main.pdf cat 1 4-end output final.pdf

quick: $(MAIN).tex version
	@echo "TEX	(final)	$<"
	@$(TEX) $(TEXFLAGS) $< $(SILENT)

$(MAIN).pdf: $(MAIN).tex $(MAIN).bbl all.tex tex/abstract.tex tex/intro.tex tex/appendix.tex tex/some_section.tex tex/some_other_section.tex
	@echo "TEX	(draft)	$<"
	@$(TEX) $(TEXFLAGS) --draftmode  $< $(SILENT)
	@echo "TEX	(final)	$<"
	@$(TEX) $(TEXFLAGS) $< $(SILENT)

$(MAIN).bbl: $(MAIN).aux
	@echo "BIB	(bib)	$(MAIN)"
	@$(BTEX) $(MAIN) > /dev/null
	
$(MAIN).aux: $(MAIN).tex $(MAIN).bib version
	@echo "TEX	(draft)	$<"
	@$(TEX) $(TEXFLAGS) --draftmode  $< $(SILENT)

$(PRES).pdf: $(PRES).tex $(PRES).bbl tex/beamer*.tex tex/slides/*.tex
	@echo "TEX	(draft)	$<"
	@$(TEX) $(TEXFLAGS) --draftmode  $< $(SILENT)
	@echo "TEX	(final)	$<"
	@$(TEX) $(TEXFLAGS) $< $(SILENT)
$(PRES).bbl: $(PRES).aux
	@echo "BIB	(bib)	$(PRES)"
	@$(BTEX) $(PRES) > /dev/null
$(PRES).aux: $(PRES).tex $(MAIN).bib
	@echo "TEX	(draft)	$<"
	@$(TEX) $(TEXFLAGS) --draftmode  $< $(SILENT)

edit:
	@echo "EDIT	(fork)	$(EDITOR)"
	@$(EDITOR) ./tex/*.tex *.tex

view:
	@echo "VIEW	(fork)	$(PDFVIEW)"
	@$(PDFVIEW) $(ALL) $(SILENT_NOER) &
[-] qjkxbmwvz@startrek.website 3 points 6 months ago

I also had some Makefiles in other directories, e.g., for my media/ I had:

MAKE = make -s
RECURS = svgs/

recurs: $(RECURS)
        @$(foreach DIR, $(RECURS), \
                echo "MAKE      (CD)    $(CURDIR)/$(DIR)"; \
                $(MAKE) -C $(DIR) $(MAKECMDGOALS);)
        @echo "MAKE     (CD)    $(CURDIR)/"

all: recurs

clean:

allclean: recurs clean

and for media/svgs/:

SVG_FILES := $(wildcard *.svg)
PDFDIR := ./
PDF_FILES := $(patsubst %.svg,$(PDFDIR)/%.pdf,$(SVG_FILES))

all: $(PDF_FILES)

clean:
        @rm -f $(PDF_FILES)
        @echo "SH       (RM)    Tidying up derived PDFs"

allclean: clean

$(PDFDIR)/%.pdf: %.svg
        @inkscape -T --export-pdf=$@ $<
        @echo "INK      (PDF)   $<"

[-] flango@lemmy.eco.br 2 points 6 months ago

Thank you!!! I'll see if I manage to make it work for me.

this post was submitted on 22 May 2024
1004 points (97.9% liked)

Science Memes

11148 readers
3259 users here now

Welcome to c/science_memes @ Mander.xyz!

A place for majestic STEMLORD peacocking, as well as memes about the realities of working in a lab.



Rules

  1. Don't throw mud. Behave like an intellectual and remember the human.
  2. Keep it rooted (on topic).
  3. No spam.
  4. Infographics welcome, get schooled.

This is a science community. We use the Dawkins definition of meme.



Research Committee

Other Mander Communities

Science and Research

Biology and Life Sciences

Physical Sciences

Humanities and Social Sciences

Practical and Applied Sciences

Memes

Miscellaneous

founded 2 years ago
MODERATORS