Created
January 31, 2017 22:52
-
-
Save amosr/46b2d419d22dbeaa90a36f8b38024f64 to your computer and use it in GitHub Desktop.
latex bullshit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
my $last_file, $last_file_used = 1; | |
while (<>) { | |
my $current = $_; | |
my $cat = $current; | |
while (length $current == 80 && | |
!($current =~ m/\.\.\.$/)) { | |
$current = <>; | |
$cat =~ s/\s*$//; | |
$cat .= $current; | |
} | |
$_ = $cat; | |
for (m,\./([-a-zA-Z/.0-9_]*).tex,g) { | |
$last_file = $1; | |
$last_file_used = 0; | |
} | |
if (m,l\.(\d+),) { | |
$last_file_used = 1; | |
print "\033[4;31m"; | |
print $last_file . ":" . $1; | |
print "\033[0m"; | |
print "\n"; | |
s,l\.\d+, ,; | |
} | |
s,(\s|^|\(|\{)[-a-zA-Z0-9_.]*/[-a-zA-Z/.0-9_]*\b, ,g; | |
s,[()]+, ,g; | |
s,\[[0-9.{} ]*\],,g; | |
next if (m/^\s*$/); | |
next if (m/Warning/); | |
next if (m/\*geometry\*/); | |
next if (m/Document Class/); | |
next if (m/version\s*\d+\.\d/i); | |
next if (m/v\d+\.\d/i); | |
next if (m/latexmk/i); | |
next if (m/LaTeX2e/); | |
next if (m/Babel.*hyphenation patterns.*loaded/); | |
next if (m/Package/); | |
next if (m/Transcript written/); | |
next if (m/Excluding comment/); | |
next if (m/For additional information/); | |
next if (m/You'll need to convert/); | |
next if (m/initializing/); | |
next if (m/Underfull.*badness/); | |
next if (m/restricted.*enabled/); | |
next if (m/entering extended mode/); | |
print; | |
} | |
if ($last_file_used == 0) { | |
print "\033[4;31m"; | |
print $last_file . ":???"; | |
print "\n"; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ -s out.pdf ]; then | |
open -a /Applications/Skim.app out.pdf | |
fi | |
fswatch -i ".*\.tex$" -i ".*\.sty$" -e "." -l 0.1 . | xargs -n1 -I {} latex-make | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# The top-level tex without the .tex extension | |
ROOT=${1:-Main} | |
# Where latexmk will put the output | |
PDF=$ROOT.pdf | |
TEX=$ROOT.tex | |
# We copy it to a separate output file so we can do an atomic(ish) write | |
OUT=out.pdf | |
# Where to put the error log | |
ERRTMP=.texout | |
# Create pdf in non-interactive mode so errors don't wait for input | |
# The stderr stuff is more or less garbage, so ignore that. | |
# Redirect stdout to a file so we can show it only if there's an error | |
# Take stdin from /dev/null, so if it does try to be interactive it'll kill itself | |
latexmk --view=pdf -halt-on-error 2>/dev/null </dev/null >$ERRTMP | |
# Did it succeed? | |
if [ $? -eq 0 ]; then | |
# Yes, success. | |
# Only copy the new pdf to output if they are different | |
diff $PDF $OUT 2>/dev/null > /dev/null | |
if [ $? -ne 0 ]; then | |
echo | |
echo | |
echo 'Updated at:' | |
date | |
cp $PDF $OUT | |
fi | |
else | |
# No luck - tex error | |
echo | |
echo | |
echo 'Latex error!' | |
echo | |
latex-error-filter $ERRTMP | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment