Created
November 12, 2012 20:21
-
-
Save Mikulas/4061641 to your computer and use it in GitHub Desktop.
Mac OS X LaTeX build script for Sublime Text 2
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
{ | |
"cmd": ["php", "/Volumes/Data/Scripts/latex_build.php", "$file"], | |
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)", | |
//"target": "exec_in_window", // https://github.com/vhyza/exec-in-window | |
"selector": "text.tex.latex" | |
} |
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
<?php | |
$file = $argv[1]; | |
$res = file_get_contents($file); | |
list($line) = explode("\n", $res); | |
$match = []; | |
preg_match('~^%build\s+(?P<file>.*?)$~ims', $line, $match); | |
$info = pathinfo($file); | |
$target = $info['dirname'] . '/' . $match['file']; | |
passthru('/usr/texbin/pdflatex ' . escapeshellarg($target)); | |
$pdf = $info['dirname'] . '/' . $info['filename'] . '.pdf'; | |
exec('open ' . escapeshellarg($pdf)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
Set the main/root file in each included tex file such as